+ - 0:00:00
Notes for current slide
Notes for next slide

Variable Transformations Recap

1 / 19

β^ interpretation in multiple linear regression

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.

2 / 19

β^1 interpretation in

sat=β0+β1salary+β2(frac=LOW)+β3(frac=HIGH)+ϵ

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.

3 / 19

Adjusting for confoundrs

  • The lines are parallel, the slope ( β^1 ) is constant between groups
4 / 19

Interactions

5 / 19

Interactions

  • 😱 the lines cross! That means there is an interaction, that is the slopes differ based on the group
5 / 19

Interactions

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
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
  • How do you interpret β^0 now?
6 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
  • How do you interpret β^2 now?
7 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
  • How do you interpret β^2 now?
    • The difference in intercepts between boys and girls
7 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
  • How do you interpret β^3 now?
8 / 19

Interactions

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
  • What does this model become for boys (When Sex = 0)
    • Weight=β0+β1Age+ϵ
  • What does this model become for girls (When Sex = 1)
    • Weight=β0+β1Age+β21+β3Age×1+ϵ
    • Weight=(β0+β2)+(β1+β3)Age+ϵ
  • How do you interpret β^3 now?
    • How much the slope changes as we move from the regression line for boys to that for girls
8 / 19

β^ interpretation for interactions between x and a binary indicator I

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*.

9 / 19

β^ interpretation for interactions between x and a binary indicator I

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*.

  • You must include this line if there are additional variables in your model.
9 / 19

β^3 interpretation for

Weight=β0+β1Age+β2Girl+β3Age×Girl+ϵ

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.

10 / 19

Non-linear relationships

lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds)

11 / 19

Non-linear relationships

lm(TotalPrice ~ Carat + I(Carat^2), data = Diamonds)

  • What is the equation for this relationship?
11 / 19

Interpreting β^s in the presence of polynomials

TotalPrice=β0+β1Carat+β2Carat2+ϵ

  • What is the interpretation of β^1?
12 / 19

Interpreting β^s in the presence of polynomials

TotalPrice=β0+β1Carat+β2Carat2+ϵ

  • What is the interpretation of β^1?
  • Typically, in multiple linear regression, the interpretation of β^i is: a one-unit change in x yields an expected change in y of β^i holding all other variables constant.
12 / 19

Interpreting β^s in the presence of polynomials

TotalPrice=β0+β1Carat+β2Carat2+ϵ

  • What is the interpretation of β^1?
  • Typically, in multiple linear regression, the interpretation of β^i is: a one-unit change in x yields an expected change in y of β^i holding all other variables constant.
    • What does it mean to see a change in Caret holding Carat 2 constant?
12 / 19

Interpreting β^s in the presence of polynomials

TotalPrice=β0+β1Carat+β2Carat2+ϵ

  • What is the interpretation of β^1?
  • Typically, in multiple linear regression, the interpretation of β^i is: a one-unit change in x yields an expected change in y of β^i holding all other variables constant.
    • What does it mean to see a change in Caret holding Carat 2 constant?
  • When you have a polynomial term, you need to specify the values you are changing between, since the change is no longer constant across all values of x.
12 / 19

Interpreting β^ in the presence of polynomials

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?

13 / 19

Interpreting β^ in the presence of polynomials

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
13 / 19

Interpreting β^ in the presence of polynomials

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
13 / 19

Interpreting β^ in the presence of polynomials

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?

14 / 19

Interpreting β^ in the presence of polynomials

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
14 / 19

Interpreting β^ in the presence of polynomials

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
  • Can we talk about β^1 and β^2 in the context of a one-unit change in Carat?
14 / 19

Interpreting β^ in the presence of polynomials

  • β^ coefficients that are transformations of the same x variable must be interpreted together
15 / 19

Interpreting β^ in the presence of polynomials

  • β^ coefficients that are transformations of the same x variable must be interpreted together
  • You must first choose to values of x to change between, and then report the change.
15 / 19

Interpreting β^ in the presence of polynomials

  • β^ coefficients that are transformations of the same x variable must be interpreted together
  • You must first choose to values of x to change between, and then report the change.
  • A sensible choice for the two x values can be the 25th% quantile and the 75th% quantile.
15 / 19

General β^ interpretation with quadratic terms

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(ba)+β^2(b2a2) holding all other variables constant*.

16 / 19

General β^ interpretation with quadratic terms

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(ba)+β^2(b2a2) holding all other variables constant*.

  • You must include this line if there are additional variables in your model.
16 / 19

Specific β^ interpretation for y=β0+β1Carat+β2Carat2+ϵ model

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.

17 / 19

Specific β^ interpretation for y=β0+β1Carat+β2Carat2+ϵ model

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.

  • Where did I get 0.7 and 1.24?
17 / 19

Quantiles

Diamonds %>%
summarise(q1 = quantile(Carat, 0.25),
q3 = quantile(Carat, 0.75))
## q1 q3
## 1 0.7 1.24
18 / 19

Diamonds

  • Go to RStudio Cloud and open Diamonds
  • Fit the model TotalPrice=β0+β1Carat+β2Carat2+β3Color+ϵ
  • Find the 0.25 quantile and 0.75 quantile of Carat
  • What is the interpretation of β^1, β^2, and β^3?
19 / 19

β^ interpretation in multiple linear regression

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.

2 / 19
Paused

Help

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