My predictions coming from a logistic regression model (glm in R) are not bounded between 0 and 1 like I would expected. My understanding of logistic regression is that your input and model parameters are combined linearly and the response is transformed into a probability using the logit link function. Since the logit function is bounded between 0 and 1, I expected my predictions to be bounded between 0 and 1.

However that's not what I see when I implement logistic regression in R:

iris.sub <- subset(iris, Species%in%c("versicolor","virginica"))
model    <- glm(Species ~ Sepal.Length + Sepal.Width, data = iris.sub, 
                family = binomial(link = "logit"))

enter image description here

If anything the output of predict(model) looks normal to me. Can anyone explain to me why the values I get are not probabilities?

  • 3
    $\begingroup$ Corone's answer below covers the details very nicely. The original figure you have above presents the log-odds values on the x-axis, which can be mathematically transformed to probabilities (i.e. as per Corone's answer, by passing back through the link function.) $\endgroup$ – James Stanley Feb 3 '13 at 23:01

The predict.glm method by default returns the predictors on the scale of the linear predictor. I.e. they haven't gone through the link function yet.


hist(predict(model, type = "response"))


enter image description here

  • 4
    $\begingroup$ You have done a great job mastering our markup and illustration capabilities in a short time: this answer is a nice example of that. Well done! $\endgroup$ – whuber Feb 4 '13 at 16:25

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.