Introduction to Regression in R
Richie Cotton
Data Evangelist
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 |
... | ... |
plt_son_vs_father <- ggplot(
father_son,
aes(father_height_cm, son_height_cm)
) +
geom_point() +
geom_abline(color = "green", size = 1) +
coord_fixed()
plt_son_vs_father +
geom_smooth(method = "lm", se = FALSE)
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
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