HW 8

8.2

a)

y = 120.07 - 1.93 x parity

b)

The slope shows that as parity increases by 1 the weight will decrease by 1.93 ounces.

y0 <- 120.07 - 1.93 * 0
y0
## [1] 120.07
y1 <- 120.07 - 1.93 * 1
y1
## [1] 118.14

First born: 120.07 ounces
Others: 118.14 ounces

c)

With the p vaule being 0.1052 we conclude that there is no statistical significance.

8.4

a)

y = 18.93 - 9.11(eth) + 3.1(sex) + 2.15(lrn)

b)

The eth slope indicates that there will be a decrease of 9.11 days when the subject is not aboriginal.
The sex slope indicates that there will be an increase of 3.1 days when the subject is male.
The lrn slope indicates that there will be an increase of 2.15 days when the subject is a slow learner.

c)

predicted <- 18.93 - (9.11 * 0) + (3.1 * 1) + (2.15 * 1)

residual <- 2 - predicted
residual
## [1] -22.18

THe residual will be -22.18

d)

n <- 146 
k <- 3   
varResidual <- 240.57 
varall <- 264.17

R2 <- 1 - (varResidual/varall)  
R2
## [1] 0.08933641
R2adj <- 1 - (varResidual/varall) * ((n-1) / (n-k-1)) 
R2adj
## [1] 0.07009704

8.8

Lrn should be removed since it has the hightest adjusted R2.

8.16

a)

It looks like lower temperatures lead to more damages.

b)

The key components are intercept and temperature. The intercept is the value when the temperature is 0. The z and p values help us statistical significance.

c)

log(p/(1-p)) = 11.663 - 0.2162 x Temperature

d)

Based on the model we can say that concerns regarding O-rings are justified. There are more damaged O-rings at lower temperatures and O-rings are needed components.

8.18

a)

p <- function(temp)
{
  phat <- exp(11.6630 - 0.2162 * temp) / (1 + exp(11.6630 - 0.2162 * temp))
  
  return (round(phat,3))
}

p(57)
## [1] 0.341
p(59)
## [1] 0.251
p(51)
## [1] 0.654
p(53)
## [1] 0.551
p(55)
## [1] 0.443

p51 = .654
p53 = .551
p55 = .443

b)

library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.3.3
df <- data.frame(shuttle=seq(1:23),
                 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),
                 undamaged=c(c(1,5,5,5,6,6,6,6,6,6,5,6,5,6,6,6,6,5,6,6,6,6,6)))
df$rating <- df$damaged / (df$damaged + df$undamaged)

ggplot(df,aes(x=temperature,y=damaged)) + geom_point() +  stat_smooth(method = 'glm', family ='binomial')
## Warning: Ignoring unknown parameters: family

c)

Looking at our visualizations we can say that there is a linear relationship between temperature and the probability of a damaged O-ring.
Each observation of O-rings is independent of each other.