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.
baby.weights <- matrix(c(120.07, 0.60, 199.94, 0.0000, -1.93, 1.19, -1.62, 0.1052), nrow = 2, byrow = TRUE)
row.names(baby.weights) <- c("(Intercept)", "parity")
colnames(baby.weights) <- c("Estimate", "Std. Error", "t value", "Pr(>|t|)")
baby.weights
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 120.07 0.60 199.94 0.0000
## parity -1.93 1.19 -1.62 0.1052
The regression line is y = 120.07 -1.93X or in actual variable names: baby.weight (oz) = 120.97 - 19.3 X Parity
The slope is -1.93, which indicates that we substract -1.93 is the child is not a first born, otherwise this value is not included
first_born = 120.07 -1.93 * 0 = 120.97
others = 120.07 - 1.93 * 1 = 118.14 (c) Is there a statistically significant relationship between the average birth weight and parity?
Based on the p-value, no since it is 10.52%. We should need for it to be below the 5% significance level
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).
days_absent = 18.93 - 9.11 X eth + 3.10 X sex + 2.15 X lrn
For each of the slopes: * we subtract -9.11 days of absence if the student is not aboriginal * We add 3.10 days if the student is a male, 0 if female * We add 2.15 extra days if the student is a slow learner, and 0 if not
eth <- 0
sex <- 1
lrn <- 1
actual <- 2
days_absent <- 18.93 - (9.11 * eth) + (3.10 * sex) + (2.15 * lrn)
paste0("The expected value is " , days_absent)
## [1] "The expected value is 24.18"
residual <- actual - days_absent
paste0("The residual is ", residual)
## [1] "The residual is -22.18"
n <- 146
k <- 3
var.e.i <- 240
var.y.i <- 264.17
r.squared.adj = 1 - (var.e.i/var.y.i) * ((n-1)/(n-k-1))
paste0("R Sqaured Adjusted Value is ", r.squared.adj)
## [1] "R Sqaured Adjusted Value is 0.0723003273073731"
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.
I would start with no ethicity since it has the lowest R square adjusted score.
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.
It appears that lower temperatures seem to lead to more failures. This is showed by missions 1-4.
the intercept starts with the predicted undamaged at 11.6630. For each decrease in -0.2162 degrees of temperature, we can expect a drop in undamaged rings.
Write out the logistic model using the point estimates of the model parameters. log(pi/(1-pi)) = 11.6630 -0.2162 * temp
Based on the model, do you think concerns regarding O-rings are justified? Explain.
Based on the data, it does appear that there is a valid concern
The data provided in the previous exercise are shown in the plot. The logistic model fit to these data may be written as \(log\left( \frac { \hat { p } }{ 1-\hat { p } } \right) =\quad 11.6630\quad -\quad 0.2162\quad X\quad Temperature\) where \(\hat {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: The values for 51, 53, and 55 are below:
p.i <- function(temp)
{
x <- 11.6630-(0.2162*temp)
return( exp(1)^(x)/(1+ exp(1)^x ))
}
p.i.51 <- p.i(51)
p.i.53 <- p.i(53)
p.i.55 <- p.i(55)
paste0("The probability values for 51, 53, and 55 are: ", round(p.i.51,2)," " ,round(p.i.53,2), " ", round(p.i.55, 2))
## [1] "The probability values for 51, 53, and 55 are: 0.65 0.55 0.44"
x <- c(51,53,55,57,59,61,63,65,67,69,71)
y <- c(p.i.51, p.i.53, p.i.55, 0.341, 0.251, 0.179, 0.124, 0.084, 0.056, 0.037, 0.024)
df <- as.data.frame(cbind(x,y))
ggplot(df, aes(x=df$x,y=df$y)) + geom_point() + ylim(0, 1.0) + xlim(50, 80) + xlab("Temperature (F)") + ylab("Probability of damage") + geom_smooth(method = "auto", se=TRUE, level=0.95)
## `geom_smooth()` using method = 'loess' and formula 'y ~ x'
The one concern I have with this model is that we have a few outliners in the given graph where it does not have a low probability for temperatures 70 and 75. The residuals are off. Second, The way the graph is drawn, it appears to be a very smooth inverted exponential curve. This may not be true. Also the model is only taking into account temperature. There may be other factors that may contribute to failures.