Consider the Challenger-Disaster:
Temp <- c(66,67,68,70,72,75,76,79,53,58,70,75,67,67,69,70,73,76,78,81,57,63,70) Fail <- factor(c(0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1)) shuttle <- data.frame(Temp, Fail) colnames(shuttle) <- c("Temp", "Fail")
Now I can fit a logistic model which will explain the "Fail" of O-ring seals by Temperature:
fit <- glm(Fail~Temp,data=shuttle, family=binomial); fit
The R output looks like this:
Call: glm(formula = Ausfall ~ Temp, family = binomial, data = shuttle) Coefficients: (Intercept) Temp 15.0429 -0.2322 Degrees of Freedom: 22 Total (i.e. Null); 21 Residual Null Deviance: 28.27 Residual Deviance: 20.32 AIC: 24.32
- In general, how do you predict probabilities for specific data in logistic regressions using R?
- Or specifically, what is the command to calculate the probability of a "Fail" if temperature is at 37°? (which it was in the night before the Challenger disaster).
I thought it would be something like this:
but it won't give me "0.9984243" (which I calculated myself with:
exp(15.0429 + (37*(-0.2322))) / 1+ exp(15.0429 + (37*(-0.2322)))
predict returns a matrix of numbers that makes no sense to me.