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)$?
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.