8.2

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.

(a) Write the equation of the regression line.
(b) Interpret the slope in this context, and calculate the predicted birth weight of first borns and others.
(c) Is there a statistically significant relationship between the average birth weight and parity?

  1. Linear regression equation: \(y = b_0 + b_1 \times parity = 120.07 - 1.93 \times x\)

  2. if x increases 
      y decreases
    else if x decreases
      y increases
  • For firstborns, consider x=0: y = 120.07 - 1.93 * 0 = 120.07
  • For non-firstborns, consider x=1: y = 120.07 - 1.93 * 1 = 118.14
  1. Let’s consider the following hypotheses:
    \(H_0\): \(b_1\) = 0
    \(H_1\): \(b_1\) != 0

Given the \(Pr_{parity}\) = 0.1052 in the table, we can reject \(H_0\) since \(Pr_{parity}\) > 0.05.

It doesn’t seem that the average birth weight and parity have a relationship.

8.4

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 sam- pled 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).

(a) Write the equation of the regression line.
(b) Interpret each one of the slopes in this context.
(c) 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.
(d) 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 R^2 and the adjusted R^2. Note that there are 146 observations in the data set

  1. Linear regression equation: \(y = b_0 + b_1 * eth + b_2 * sex + b_3 * lrn = 18.93 - 9.11 * x_1 + 3.10 * x_2 + 2.15 * x_3\)

  2. eth: “ethnic” - if ethnic is not aboriginal, the average # of absent days increases by 9.11
    sex: “sex” - if sex is male, the average # of absent days increases by 3.1
    lrn: “learner” - if learner is slow learner, the average # of absent days increases by 2.15


  3. Given:
    \(y_{missed}\) = 2
    \(x_1\) = 0 (aboriginal = 0 | not-aboriginal = 1)
    \(x_2\) = 1 (female = 0 | male = 1)
    \(x_3\) = 1 (average-learner = 0 | slow-learner = 1)

y = 18.93 - 9.11 * x_1 + 3.10 * x_2 + 2.15 * x_3
y = 18.93 - 9.11 * 0 + 3.10 * 1 + 2.15 * 1
y = 24.18

residual = \(y_{missed}\) - y = 2 - 24.18 = 26.18


  1. Given:
    Var(residual) = 240.57
    Var(y_i) = 264.17
    n = 146
    k = total_coefficents - 1 = 4 - 1 = 3

\(R^2\) = \(1 - \frac{Var(residual)}{Var(y_i)}\)
\(R^2\) = \(1 - \frac{240.57}{264.17}\)
\(R^2\) = 0.0893364

adjusted:
\(R^2_{adj}\) = \(R^2 \times \frac{n-1}{n-k-1}\)
\(R^2_{adj}\) = 0.0893364 * 1.0211268
\(R^2_{adj}\) = 0.070097

8.8

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?

library(knitr)
Model<-c("Full_model","No_ethnicity","No_sex","No_learner_status")
Adjusted_R_squared<-c(0.0701,-0.0033,0.0676,0.0723)

df<-data.frame(Model,Adjusted_R_squared)

kable(df[rev(order(df$Adjusted_R_squared)),])
Model Adjusted_R_squared
4 No_learner_status 0.0723
1 Full_model 0.0701
3 No_sex 0.0676
2 No_ethnicity -0.0033
  • We notice that 3 out of 4 models have their \(R^2\) between 6.76% and 7.23%: \(6.76\)% < \(R^2\) < \(7.23\)% and 1 around 0.33%.

  • Therefore, we can conclude from the reversed sorted list that “No learner status” model has the highest \(R^2_{adj}\) value that should be removed for better \(R^2\) results.

8.16

(a) Each column of the table above represents a different shuttle mission. Examine these data and describe what you observe with respect to the relationship between temperatures and damaged O-rings.
(b) Failures have been coded as 1 for a damaged O-ring and 0 for an undamaged O-ring, and a logistic regression model was fit to these data. A summary of this model is given below. Describe the key components of this summary table in words.

(c) Write out the logistic model using the point estimates of the model parameters.
(d) Based on the model, do you think concerns regarding O-rings are justified? Explain.

library(ggplot2)
Temperature <- c(53,57,58,63,66,67,67,67,68,69,70,70,70,70,72,73,75,75,76,76,78,79,81)
Damaged <- c(5,1,1,1,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0)
qplot(x = Temperature, y = factor(Damaged), geom = "point") + 
  geom_jitter(height = 0.4, alpha = 0.5)

By examining the data and looking at the scatterplot, we see that the temperature is behaving as the predictor of the damaged O-rings. Results are better when the temperature is above 65 degrees and no failures above 75 degrees.

Temperature: if temperature is increases, O-rings damages will decrease by 0.2162. With a p-value of 0.

\(y = log(\frac{p_i}{1 - p_i}) = b_0 + b_1 \times Temperature\)

y = 11.6630 - 0.2162 * Temperature

  1. From our observations from above, we found that the temperature is the predictor of damaged O-rings. Low temperatures will cause damages and high temperatures will lower to null these damages. With this relationship between the temperature and the damages, we validate and justify our concerns in regards the O-rings.

8.18

(a) The data provided in the previous exercise are shown in the plot. The logistic model fit to these data may be written as

where p is the model-estimated probability that an O-ring will become damaged. Use the model to calculate the probability that an O-ring will become damaged at each of the following ambient temperatures: 51, 53, and 55 degrees Fahrenheit. The model-estimated probabilities for several additional ambient temperatures are provided below, where subscripts indicate the temperature:

(b) Add the model-estimated probabilities from part (a) on the plot, then connect these dots using a smooth curve to represent the model-estimated probabilities.
(c) Describe any concerns you may have regarding applying logistic regression in this application, and note any assumptions that are required to accept the model’s validity.


  1. Formula:
    \(log(\frac{p}{1 - p}) = 11.6630 - 0.2162 \times Temperature\)
    => \(p = \frac{e^{11.6630 - 0.2162 \times Temperature}}{1 + e^{11.6630 - 0.2162 \times Temperature}}\)

\(p_{51}\) = 0.6540297 = 65.4 %
\(p_{53}\) = 0.5509228 = 55.09 %
\(p_{55}\) = 0.4432456 = 44.32 %

Temperature <- c(51,53,55,57,59,61,63,65,67,69,71)
Model_estimated_probabilities <- c(0.654,0.551,0.443,0.341,0.251,0.179,0.124,0.084,0.056,0.037,0.024)
qplot(x = Temperature, y = Model_estimated_probabilities, geom = "point") + 
  stat_smooth(method = "glm", method.args = list(family = "binomial"), se = FALSE)
## Warning in eval(family$initialize): non-integer #successes in a binomial
## glm!

  • It’s difficult to check without grouping the data
  • Additional computing may be needed like using the empirical logit function
  • The fitted logistic curve in the plot provides a better understanding about the fit
  • The shuttle missions were selected at random