# Probability Curve from logit model

Related my earlier question here. Having "mastered" linear regression, I'm trying to learn everything I can about logistic regression and am having issues turning largely "useless" coefficients into meaningful information.

I asked in my previous question about graphing the probability curve for every permutation of a logit model. However, I was working on just plotting the main curve and was having some issues.

If I was running a logit with just one predictor, I'd run the following:

mod1 = glm(factor(won) ~ as.numeric(bid), data=mydat,

all.x <- expand.grid(won=unique(won), bid=unique(bid))
y.hat.new <- predict(mod1, newdata=all.x, type="response")
plot(bid <- 000:250, predict(mod1,newdata=data.frame(
bid <- c(000:250)), type="response"), lwd=5, col="blue",
type="l")


However, what about with multiple predictors? I tried to use the mtcars data set to mess around and couldn't get it.

Any suggestion on how to plot the main probability curve for the logit model.

head(mtcars)

m1 = glm(vs ~ disp + wt, data=mtcars,
summary(m1)

all.x <- expand.grid(vs=unique(mtcars$$vs), disp=unique(mtcars$$disp), wt=unique(mtcars$wt)) y.hat.new <- predict(m1, newdata=all.x, type="response") plot(disp <- 000:250, predict(m1, newdata=data.frame( disp <- c(000:250), wt <- c(0,250)), type="response"), lwd=5, col="blue", type="l")  EDIT = OR is my previous question what I need to do. Since Y = B0 + B1X1 + B2X2, a one unit change in X1 is associated with a exp(B1) change in Y, regardless of the value of B2. Then would it be possible that my original question is really all that should be done. My appologies on my stupidity if that is indeed the case. • What do you mean by the "main probability curve" for a logistic model? – whuber Jul 5, 2012 at 22:33 • My "main probability curve," I was thinking there was a single curve similar to that where there is one predictor. I don't know if that is correct or if it'd actually be some weird dimensional surface plot. Jul 5, 2012 at 22:41 • A curve, by definition, portrays how one quantity (the expected log odds in this case) depends on a single additional numerical value. To depict fully the variation of a dependent variable on$p$independent variables requires a$p$-dimensional surface embedded in a$p+1\$-dimensional space.
– whuber
Jul 6, 2012 at 13:16

With two predictors, you can for instance show the predicted probabilities as a function of $$x_1$$, for various choosen values of the other variable $$x_2$$, shown as a panel of plots. Extend with three or more predictors ...

I will show this with your example, using the R package visreg. We use conditional plots, that is, with predictions "ceteribus paribus", all variables not shown directly in the plot kept at a fixed, chose, value.

m1 <- glm(vs ~ disp + wt, data=mtcars,


First, a plot of the variables used in the model:

library(ggplot2)
ggplot(mtcars,  aes(disp, wt, color=as.factor(vs)))  +  geom_point() Then the conditional plot:

library(visreg)

visreg(m1, "disp", by="wt",  scale="response") But we can also show it as a 2d plot:

visreg2d(m1, "disp", "wt", scale="response")


with the same interpretation: Some similar posts where visreg was used: