8.2 Baby weights, Part II. Exercise 8.1 introduces a data set on birth weight of babies. Another variable we consider is parity, which is 0 if the child is the first born, and 1 otherwise. The summary table below shows the results of a linear regression model for predicting the average birth weight of babies, measured in ounces, from parity.
  1. Write the equation of the regression line.
baby.b = 120.07 #intercept 
baby.m = -1.93 # parity coefficient
paste0("y = ", round(baby.b, 2), " + ", round(baby.m, 2), " * x + ")
## [1] "y = 120.07 + -1.93 * x + "
  1. Interpret the slope in this context, and calculate the predicted birth weight of first borns and others.
baby.x1 = 0
baby.x2 = 1
baby.y1 = baby.m * baby.x1 + baby.b
baby.y2 = baby.m * baby.x2 + baby.b
baby.y1
## [1] 120.07
baby.y2
## [1] 118.14

** On average, birth weight is 1.93oz lower for children born after the first. The predicted birth weight of first-born children is 120.07oz, and of non-first-born children is 118.14oz. **

  1. Is there a statistically significant relationship between the average birth weight and parity?

** p-value is .1052, so there is not sufficient evidence to dismiss the null hypothesis at the 95% or 90% confidence levels.**


8.4 Absenteeism, Part I. Researchers interested in the relationship between absenteeism from school and certain demographic characteristics of children collected data from 146 randomly sampled students in rural New South Wales, Australia, in a particular school year. Below are three observations from this data set.

The summary table below shows the results of a linear regression model for predicting the average number of days absent based on ethnic background (eth: 0 - aboriginal, 1 - not aboriginal), sex (sex: 0 - female, 1 - male), and learner status (lrn: 0 - average learner, 1 - slow learner)

  1. Write the equation of the regression line.

absent = 18.93 - 9.11 * eth + 3.10 * sex + 2.15 * lrn

  1. Interpret each one of the slopes in this context.

The strongest predictor of absenteeism in this model is aboriginal ethnicity, followed by male sex, then slow learning status. Ceteris paribus, on average non-aboriginal studnets miss 9.11 fewer days; male students miss 3.10 more days; slow learners miss 2.15 more days.

  1. Calculate the residual for the first observation in the data set: a student who is aboriginal, male, a slow learner, and missed 2 days of school.
eth = 0
sex = 1
lrn = 1
days = 2
absent = 18.93 - 9.11 * eth + 3.10 * sex + 2.15 * lrn
days - absent
## [1] -22.18

The residual is -22.18 - the model overestimated number of days absent by 22 days.

  1. The variance of the residuals is 240.57, and the variance of the number of absent days for all students in the data set is 264.17. Calculate the R2 and the adjusted R2. Note that there are 146 observations in the data set.
baby.n <- 146 
baby.k <- 3
baby.s.e <- 240.57
baby.s.y <- 264.17

baby.R2 <- 1 - (baby.s.e / baby.s.y)
baby.R2.adj <- 1 - (baby.s.e * (baby.n - 1)) / ((baby.s.y) * (baby.n - baby.k - 1))
paste0("R2 = ", round(baby.R2, 4), " and Adjusted R2 = ", round(baby.R2.adj, 4))
## [1] "R2 = 0.0893 and Adjusted R2 = 0.0701"


8.8 Absenteeism, Part II. Exercise 8.4 considers a model that predicts the number of days absent using three predictors: ethnic background (eth), gender (sex), and learner status (lrn). The table below shows the adjusted R-squared for the model as well as adjusted R-squared values for all models we evaluate in the first step of the backwards elimination process. Which, if any, variable should be removed from the model first?

We should remove learner status first. When it is not included in the model, the adjusted R^2 is .0723, which is higher than including all three predictors, removing sex, and removing ethnicity.