Regression to the mean

Introduction to Regression in R

Richie Cotton

Data Evangelist

The concept

  • Response value = fitted value + residual
  • "The stuff you explained" + "the stuff you couldn't explain"
  • Residuals exist due to problems in the model and fundamental randomness
  • Extreme cases are often due to randomness
  • Regression to the mean means extreme cases don't persist over time
Introduction to Regression in R

Pearson's father son dataset

  • 1078 father/son pairs
  • Do tall fathers have tall sons?
father_height_cm son_height_cm
165.2 151.8
160.7 160.6
165.0 160.9
167.0 159.5
155.3 163.3
... ...
1 Adapted from https://www.rdocumentation.org/packages/UsingR/topics/father.son
Introduction to Regression in R

Scatter plot

plt_son_vs_father <- ggplot(
  father_son, 
  aes(father_height_cm, son_height_cm)
) +
  geom_point() +
  geom_abline(color = "green", size = 1) +
  coord_fixed()

A scatter plot of sons' heights versus fathers' heights, with a line where the father and son would be the same height. As fathers get taller, so do the sons.

Introduction to Regression in R

Adding a regression line

plt_son_vs_father +
  geom_smooth(method = "lm", se = FALSE)

The scatter plot of sons' heights versus fathers' heights, annotated with a linear trend line. The trend line is less steep than the line where fathers and sons would be the same height.

Introduction to Regression in R

Running a regression

mdl_son_vs_father <- lm(
  son_height_cm ~ father_height_cm, 
  data = father_son
)
Call:
lm(formula = son_height_cm ~ father_height_cm, data = father_son)

Coefficients:
     (Intercept)  father_height_cm  
          86.072             0.514
Introduction to Regression in R

Making predictions

really_tall_father <- tibble(
  father_height_cm = 190
)
predict(mdl_son_vs_father, really_tall_father)
183.7
really_short_father <- tibble(
  father_height_cm = 150
)
predict(mdl_son_vs_father, really_short_father)
163.2
Introduction to Regression in R

Let's practice!

Introduction to Regression in R

Preparing Video For Download...