Developing data product: Week 4 assignment

SY

8/16/2020

Coursera Reproducible Pitch

This is a presentation made using the R presenter of R studio for the developing data products week 4 assignment. A shiny app was created and deployed on the shiny server. The link is https://shenqiny.shinyapps.io/week4/. The code can be found at https://github.com/shenqiny/Developing_data_product.

The application allows users to predict the child’s height based on the provided midparent height, as well as view the plot and linear regression model for the prediction.

Overview of Galton dataset

The Shiny App uses the Galton dataset on the heights of parents and their children.

Galton (1886) presented these data in a table, showing a cross-tabulation of 928 adult children born to 205 fathers and mothers, by their height and their mid-parent’s height.

##   parent child
## 1   70.5  61.7
## 2   68.5  61.7
## 3   65.5  61.7
## 4   64.5  61.7
## 5   64.0  61.7

Linear regression model

We use child’s height as the outcome and parent height as the predictor, and generate a model using linear regression.

## 
## Call:
## lm(formula = child ~ parent, data = Galton)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -7.8050 -1.3661  0.0487  1.6339  5.9264 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 23.94153    2.81088   8.517   <2e-16 ***
## parent       0.64629    0.04114  15.711   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2.239 on 926 degrees of freedom
## Multiple R-squared:  0.2105, Adjusted R-squared:  0.2096 
## F-statistic: 246.8 on 1 and 926 DF,  p-value: < 2.2e-16

Galton plot with linear regression model

Given a parent height, the child’s height is predicted using the linear regression model, using the prediction function:

prediction_c<-function(height) {predict(fit, newdata = data.frame(parent=height))}