Plotting GLM model gives me a linear regression


I ran a logit model, but when I try to plot it, I am having some errors. For instance, to show the distribution between two variables, I applied the GLM method in ggplot2, but instead of having the typical logistic curve, I receive a linear regression.

Here is a sample data:

  prespartyshare = c(44.7470817120623,46.3035019455253,
        approved = as.factor(c("0","1","0",

And the code I used:

ggplot(mydata, aes(x=prespartyshare, y=as.numeric(mydata$approved) - 1)) + 
  geom_point(alpha=.5) +
  stat_smooth(method="glm", se=FALSE, method.args = list(family=binomial), fullrange=TRUE)

I appreciate your help in advance.

Your curve is pretty linear in the range of the data. Add +xlim(-200,200) and you'll see a nicer looking curve.

1 Like

Thank you for the explanation

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.