Developing data products - Predicting the child's height

Kong, Seok-kyu
Sun Nov 15 09:53:09 2015

Contents

  • Introduction to galton data set
  • Linear regression
  • Predicting with shiny app

Introduction to galton data set

“Francis Galton, the 19th century polymath, can be credited with discovering regression. He was particularly interested in the idea that the children of tall parents tended to be tall also, but a little shorter than their parents.” [reference: Regression Models for Data Science in R]

How would one fit a model that relates parent and child height?

Linear regression

We will assume a systematic component via a line and then independent and identically distributed Gaussian errors.

We can write the model out as:

\( Y_i = \beta_0 + \beta_1 X_i + \epsilon_i \)

Using regression for prediction in shiny app

go to: prediciting app

library(UsingR)

# fitting linear model to galton data set
modFit <- lm(child ~ parent, data=galton)

plot(jitter(child) ~ parent, data=galton, xlab="Parent's height", ylab="Child's height")
lines(galton$parent, modFit$fitted.values)

plot of chunk unnamed-chunk-1