I have the following issue in R.
I perform logistic regression in R:
logitMod <- glm(dependent_var ~ var1, var2, varN, data=traindata, family=binomial())
Then, I run predict on the first record of the testdata set, to get the log odds:
>predict(logitMod, testdata) -44.81362
Then I calculate the probability from the log odds:
> 1/(1+ exp(-predict(logitMod, testdata))) 3.449006e-20
Then, I check with the predict function what the built-in probability-conversion would yield, and the result is very different:
>predict(logitMod, testdata, type="response") 2.220446e-16
So my question is, what am I overlooking?
predict(logitMod, testdata, type="response")produces erroneous predictions. But maybe there are good reasons for this behaviour of
predict.glmwas implemented to have this behaviour. Btw,
2.22e-16is the same as