(smokers <- 123.05-8.94*(1))
## [1] 114.11
(nonsmokers <- 123.05-8.94*(0))
## [1] 123.05
Absent <- 18.93 - 9.11 * (0) + 3.10 * (1) + 2.15 * (1)
(Residual <- Absent-2)
## [1] 22.18
var_res <- 240.57
var_num <- 264.17
n <- 146
k <- 3
(R2 <- 1 - (var_res / var_num))
## [1] 0.08933641
(R2_adjusted <- 1 - (var_res/var_num) * ((n-1)/(n-k-1)))
## [1] 0.07009704
p <- function(temp)
{
phat <- exp(11.6630 - 0.2162 * temp) / (1 + exp(11.6630 - 0.2162 * temp))
return (round(phat,3))
}
p(51)
## [1] 0.654
p(53)
## [1] 0.551
p(55)
## [1] 0.443
library(ggplot2)
prob <- 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)))
ggplot(prob,aes(x=temperature,y=damaged)) + geom_point() + stat_smooth(method = 'glm')