Chapter 8 - Multiple and Logistic Regression
Practice: 8.1, 8.3, 8.7, 8.15, 8.17
Graded: 8.2, 8.4, 8.8, 8.16, 8.18
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.
Picture
y = 120.07-1.93*parity
The slope in this context means, that for each parity increase there will be a loss of 1.93 ounces in the baby’s weight.
If baby is first born: parity = 0; the baby’s weight will be 120.07 ounces.
y = 120.07-1.93*0
y
## [1] 120.07
If baby is NOT first born: parity = 1; the baby’s weight will be 118.14 ounces.
y = 120.07-1.93*1
y
## [1] 118.14
Due to the parity parameter’s p???value is 0.1052; we can conclude that there is NOT a statistically significant relationship between average birth weight and parity.
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.
Picture
Which, if any, variable should be removed from the model first?
Since Adjusted R2=0.0723, the lrn variable should be removed from the model first.
8.16 Challenger disaster, Part I.
On January 28, 1986, a routine launch was anticipated for the Challenger space shuttle. Seventy-three seconds into the flight, disaster happened: the shuttle broke apart, killing all seven crew members on board. An investigation into the cause of the disaster focused on a critical seal called an O-ring, and it is believed that damage to these O-rings during a shuttle launch may be related to the ambient temperature during the launch. The table below summarizes observational data on O-rings for 23 shuttle missions, where the mission order is based on the temperature at the time of the launch. Temp gives the temperature in Fahrenheit, Damaged represents the number of damaged O-rings, and Undamaged represents the number of O-rings that were not damaged.
Picture
After observing the data, we can conclude that the lower tepreture, the higher the chance of a damaged O-ring.
(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.
Picture
Answer: If the temperature increases by 1 degree, the chances to be damaged decreases by 0.2162.The p-values help to determine if the variable fit in the model.
$ =11.6630-0.2162Temperature $
.
Due to the p-value for temperature is 0, concerns regarding O-rings are justified.
8.18 Challenger disaster, Part II. Exercise 8.16 introduced us to O-rings that were identified as a plausible explanation for the breakup of the Challenger space shuttle 73 seconds into takeoff in 1986. The investigation found that the ambient temperature at the time of the shuttle launch was closely related to the damage of O-rings, which are a critical component of the shuttle. See this earlier exercise if you would like to browse the original data.
Picture
(a)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.
temp1 <- 51
temp2 <- 53
temp3 <- 55
x1 <- 11.663 - 0.2162*temp1
x2 <- 11.663 - 0.2162*temp2
x3 <- 11.663 - 0.2162*temp3
p1 <- exp(x1)/(1+exp(x1))
p2 <- exp(x2)/(1+exp(x2))
p3 <- exp(x3)/(1+exp(x3))
p1
## [1] 0.6540297
p2
## [1] 0.5509228
p3
## [1] 0.4432456
library(ggplot2)
temps <- c(51: 71)
values <- NULL
log_model_plot <- function(temps) {
for (temp in temps){
p <- 11.6630-(.2172*(temp))
prob <- exp(p)/(1 + exp(p))
value <- data.frame(temp, prob)
values <- rbind(values, value)
}
f <- ggplot(values, aes(temp, prob))
f + geom_smooth() + geom_point()
}
log_model_plot(temps)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
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.
First key condition for fitting a logistic regression model:
Second key condition: - Each outcome Yi is independent of the other outcomes.