knitr::opts_chunk$set(warning=FALSE,
message=FALSE)
library(tidyverse)
library(knitr)
library(broom)
library(Sleuth3)
wages <- case1202 %>%
mutate(Female = ifelse(Sex=="Female",1,0)) %>%
select(-Sal77,-Sex)
model <- lm(Bsal ~ Senior + Age + Educ + Exper + Female,
data=wages)
tidy(model,conf.int=TRUE)
## # A tibble: 6 x 7
## term estimate std.error statistic p.value conf.low conf.high
## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 6278. 652. 9.62 2.36e-15 4981. 7574.
## 2 Senior -22.6 5.30 -4.26 5.08e- 5 -33.1 -12.1
## 3 Age 0.631 0.721 0.876 3.84e- 1 -0.801 2.06
## 4 Educ 92.3 24.9 3.71 3.61e- 4 42.9 142.
## 5 Exper 0.501 1.06 0.474 6.36e- 1 -1.60 2.60
## 6 Female -768. 129. -5.95 5.39e- 8 -1024. -512.
wages <- wages %>%
mutate(SeniorCent = Senior - mean(Senior),
AgeCent = Age-mean(Age),
EducCent = Educ - mean(Educ),
ExperCent = Exper - mean(Exper))
Calculate the regression model using the mean-centered variables.
How did the model change?
Educ
.wages <- wages %>%
mutate(EducCat = as.factor(Educ))
EducCat
instead of Educ
.