Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library(tidyverse)
- library(janitor)
- library(haven)
- library(broom)
- library(foreign)
- install.packages("haven")
- healthdata <- read_spss("Health_LISS_Core_Study_Wave_12_2020_data_plus_background_small.sav")
- healthdata %>% View()
- healthdata %>%
- ggplot() +
- geom_histogram(aes(x = nettoink))
- # filter income
- healthdata <- healthdata %>%
- filter(nettoink <= 15000)
- # scatterplot
- healthdata %>%
- ggplot(aes(x = nettoink, y = BMI)) +
- geom_point() +
- geom_smooth(method = "lm", se = F)
- # linear regression
- model <- healthdata %>%
- lm(BMI ~ nettoink, data = .)
- model %>% tidy()
- summary(model)
- # 95% confidence interval
- confint(model, 'nettoink', level=0.95) %>%
- as.data.frame() %>%
- mutate_if(is.numeric, round, 6)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement