0
$\begingroup$

I'm performing a logistic regression in R.
I wanted to know if the function predict.glm outputs $p$ (probability of event occurring) or log odds i.e. $log(p/1-p)$?

$\endgroup$

1 Answer 1

2
$\begingroup$

It returns the log odds. You can see that with this basic example,

# Create a perfect correlated data.
data <- data.frame(x = c(1,0,1,0), y = c(T, F, T, F))

# Estimate the model.
model <- glm(y ~ x, data)

# Show predictions.
predict(model)
##        1         2         3         4 
## 23.56607 -23.56607  23.56607 -23.56607

# Compute the inverse of the log odd to come to your prediction. 
boot::inv.logit(predict(model))
##           1            2            3            4 
##1.000000e+00 5.826215e-11 1.000000e+00 5.826215e-11 

If logit would return probabilities you could not take the inverse to come to your predicted values.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.