# How do you predict probabilities for specific data in logistic regressions using R?

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


### Questions

• 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:

predict(fit, Temp=37)


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)))


The method predict returns a matrix of numbers that makes no sense to me.

?predict.glm

predict(fit, data.frame(Temp=37), type="response")

• I don't think glm can handle ordered regression, but you may have a look at ats.ucla.edu/stat/r/dae/ologit.htm or the web in general Jul 24 '13 at 8:06