## # A tibble: 2 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 1159. 57.7 20.1 5.13e-25## 2 salary -5.54 1.63 -3.39 1.39e- 3
## # A tibble: 2 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 1159. 57.7 20.1 5.13e-25## 2 salary -5.54 1.63 -3.39 1.39e- 3
## # A tibble: 4 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 852. 38.9 21.9 5.56e-26## 2 salary 1.09 0.988 1.10 2.76e- 1## 3 frac_groupLOW 150. 12.8 11.7 2.09e-15## 4 frac_groupMED 38.6 14.1 2.75 8.59e- 3
## # A tibble: 4 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 852. 38.9 21.9 5.56e-26## 2 salary 1.09 0.988 1.10 2.76e- 1## 3 frac_groupLOW 150. 12.8 11.7 2.09e-15## 4 frac_groupMED 38.6 14.1 2.75 8.59e- 3
## # A tibble: 4 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 852. 38.9 21.9 5.56e-26## 2 salary 1.09 0.988 1.10 2.76e- 1## 3 frac_groupLOW 150. 12.8 11.7 2.09e-15## 4 frac_groupMED 38.6 14.1 2.75 8.59e- 3
frac_groupLOW
?## # A tibble: 4 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) 852. 38.9 21.9 5.56e-26## 2 salary 1.09 0.988 1.10 2.76e- 1## 3 frac_groupLOW 150. 12.8 11.7 2.09e-15## 4 frac_groupMED 38.6 14.1 2.75 8.59e- 3
frac_groupLOW
?salary
now?The coefficient for x is ^β (95% CI: LB^β,UB^β). A one-unit increase in x yields an expected increase in y of ^β, holding all other variables constant.
The coefficient for average salary is 1.09 (95% CI: -0.90, 3.08). A one-unit increase in average salary yields an expected increase in average SAT score of 1.09, holding the fraction of students that took the SAT constant.
sex
(blue: Girl, black: Boy)sex
(blue: Girl, black: Boy)sex
(blue: Girl, black: Boy)sex
(blue: Girl, black: Boy)sex
(blue: Girl, black: Boy)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)lm(Weight ~ Age + Sex + Age * Sex, data = Kids198)
## ## Call:## lm(formula = Weight ~ Age + Sex + Age * Sex, data = Kids198)## ## Coefficients:## (Intercept) Age Sex Age:Sex ## -33.6925 0.9087 31.8506 -0.2812
Sex = 0
)Sex = 1
)Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198) %>% tidy(conf.int = TRUE)
## # A tibble: 4 x 7## term estimate std.error statistic p.value conf.low conf.high## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -33.7 10.0 -3.37 9.17e- 4 -53.4 -14.0 ## 2 Age 0.909 0.0611 14.9 6.47e-34 0.788 1.03 ## 3 Sex 31.9 13.2 2.41 1.71e- 2 5.73 58.0 ## 4 Age:Sex -0.281 0.0816 -3.44 7.00e- 4 -0.442 -0.120
lm(Weight ~ Age + Sex + Age * Sex, data = Kids198) %>% tidy(conf.int = TRUE)
## # A tibble: 4 x 7## term estimate std.error statistic p.value conf.low conf.high## <chr> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -33.7 10.0 -3.37 9.17e- 4 -53.4 -14.0 ## 2 Age 0.909 0.0611 14.9 6.47e-34 0.788 1.03 ## 3 Sex 31.9 13.2 2.41 1.71e- 2 5.73 58.0 ## 4 Age:Sex -0.281 0.0816 -3.44 7.00e- 4 -0.442 -0.120
The coefficient for the interaction between x and I is ^β (95% CI: LB^β,UB^β). This means that the effect of x on y differs by ^β when I=1 compared to I=0 holding all other variables constant*.
The coefficient for the interaction between x and I is ^β (95% CI: LB^β,UB^β). This means that the effect of x on y differs by ^β when I=1 compared to I=0 holding all other variables constant*.
The coefficient for the interaction between Age
and Sex
is -0.28 (95% CI: -0.44, -0.12). This means that the effect of Age
on Weight
lower by 0.28 among girls compared to boys.
lm(TotalPrice ~ Carat, data = Diamonds)
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds)
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds)
TotalPrice=β0+β1Carat+β2Carat2+ϵ
TotalPrice=β0+β1Carat+β2Carat2+ϵ
TotalPrice=β0+β1Carat+β2Carat2+ϵ
Caret
holding Carat
2 constant?TotalPrice=β0+β1Carat+β2Carat2+ϵ
Caret
holding Carat
2 constant?lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 0.8 to 1.8?
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 0.8 to 1.8?
(-522.7 + 2386 * 1.8 + 4498.2 * 1.8^2) - (-522.7 + 2386 * 0.8 + 4498.2 * 0.8^2)
## [1] 14081.32
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 0.8 to 1.8?
(-522.7 + 2386 * 1.8 + 4498.2 * 1.8^2) - (-522.7 + 2386 * 0.8 + 4498.2 * 0.8^2)
## [1] 14081.32
2386 * (1.8 - 0.8) + 4498.2 * (1.8^2 - 0.8^2)
## [1] 14081.32
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 1.8 to 2.8?
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 1.8 to 2.8?
2386 * (2.8 - 1.8) + 4498.2 * (2.8^2 - 1.8^2)
## [1] 23077.72
lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds) %>% tidy()
## # A tibble: 3 x 5## term estimate std.error statistic p.value## <chr> <dbl> <dbl> <dbl> <dbl>## 1 (Intercept) -523. 466. -1.12 2.63e- 1## 2 Carat 2386. 753. 3.17 1.66e- 3## 3 I(Carat^2) 4498. 263. 17.1 5.09e-48
What is the expected change in TotalPrice
for a one-unit change in Carat
, changing from 1.8 to 2.8?
2386 (2.8 - 1.8) + 4498.2 (2.8^2 - 1.8^2)
## [1] 23077.72
Carat
?The linear term in the model for x has a coefficient of ^β1 (95% CI: (LB^β1,UB^β1)). The quadratic term in the model for x has a coefficient of ^β2 (95% CI: (LB^β2,UB^β2)). A change in x from a to b yields an expected change in y of ^β1(b−a)+^β2(b2−a2) holding all other variables constant*.
The linear term in the model for x has a coefficient of ^β1 (95% CI: (LB^β1,UB^β1)). The quadratic term in the model for x has a coefficient of ^β2 (95% CI: (LB^β2,UB^β2)). A change in x from a to b yields an expected change in y of ^β1(b−a)+^β2(b2−a2) holding all other variables constant*.
The linear term in the model for Carat
has a coefficient of 2386 (95% CI: (906,3866)). The quadratic term in the model for Carat
has a coefficient of 4498 (95% CI: (3981,5016)). A change in Carat
from 0.7 to 1.24 yields an expected change in TotalPrice
of 6000.5.
The linear term in the model for Carat
has a coefficient of 2386 (95% CI: (906,3866)). The quadratic term in the model for Carat
has a coefficient of 4498 (95% CI: (3981,5016)). A change in Carat
from 0.7 to 1.24 yields an expected change in TotalPrice
of 6000.5.
Diamonds
Diamonds
Carat
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |