1
$\begingroup$

This is more a conceptual question.

I have the following logistic regression model in R:

Call:
glm(formula = EV ~ Genre + Speech_VP, family = binomial, data = df_ev2)

Deviance Residuals: 
    Min       1Q   Median       3Q      Max  
-2.0115  -0.4628  -0.1381   0.5326   3.0519  

Coefficients:
            Estimate Std. Error z value Pr(>|z|)    
(Intercept)  -4.6475     0.5115  -9.086  < 2e-16 ***
GenreTN       4.0611     0.4379   9.274  < 2e-16 ***
Speech_VPN    2.4675     0.3762   6.559  5.4e-11 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 434.02  on 313  degrees of freedom
Residual deviance: 227.37  on 311  degrees of freedom
AIC: 233.37

Number of Fisher Scoring iterations: 5

I'm interested in plotting the levels of the genre variable. The model says that outcome B of the response variable is more likely than outcome A when genre = TN; the log odds of this outcome is 4.0611.

Using the visreg package in R, I can make the following plot that shows this difference:

enter image description here

So here, if I'm reading this right, we have the log odds of the outcome when genre = PEN at approximately -2, and the log odds of the outcome when genre = TN at approximately 2. So the vertical distance between the two is about 4, which is what the log odds of 4.0611 represents, right?

Now, log odds aren't that intuitive, so I'd prefer to express the odds as probabilities. Thus:

> exp(4.0611)/(1+exp(4.0611))
[1] 0.9830618

So about 98%, right?

Now visreg allows you to display the regression model with probability instead of log odds, which comes out like this:

enter image description here

Here, the probability of outcome B when genre = PEN looks to be somewhere around .10, while the probability of outcome B when genre = TN looks to be around .86.

But shouldn't the vertical distance between them be .98? Because the log odds of 4.0611 = 0.9830618 in terms of probability right?

There is something I'm missing here. Any ideas?

BTW, I posed a similar quesiton regarding the code on Stack Overflow which includes the data and code, should anyone care to try it themselves: https://stackoverflow.com/questions/78289261/visreg-plot-of-glm-object-doesnt-match-glm-values?noredirect=1#comment138021764_78289261

Here’s the code to produce the two different plots:

visreg(ev2.glm, "Genre", ylab = "Log odds of outcome B", scale="response", gg = TRUE) + theme_bw()
visreg(ev2.glm, "Genre", ylab = "Log odds of outcome B", gg = TRUE) + theme_bw()
$\endgroup$
1

1 Answer 1

3
$\begingroup$

You have to keep in mind that all model parameters apart from the intercept express differences in log-odds rather than absolute numbers. To obtain a probability you should always include at least the intercept, and judging by the numbers your plot also conditions on the Speech_VPN parameter in full (i.e. it includes another offset of $2.4675$ in log-odds).

You can easily recalculate all probabilities manually, where $\text{expit}(x)=1/(1+\text{exp}(-x))$:

Prediction Log-odds Probability
$\beta_0$ (intercept or reference) $-4.6475$ $\text{expit}(-4.6475)\approx0.01$
$\beta_0+\beta_1$ (GenreTN) $-4.6475+4.0611$ $\text{expit}(-0.5864)\approx0.36$
$\beta_0+\beta_2$ (Speech_VPN) $-4.6475+2.4675$ $\text{expit}(-2.1800)\approx0.10$
$\beta_0+\beta_1+\beta_2$ (GenreTN + Speech_VPN) $-4.6475+4.0611+2.4675$ $\text{expit}(1.8811)\approx0.87$

It's these last two rows that are being shown, both in your log-odds plot and in the probability one.

To get to a predicted probability of $0.98$ you would have to add a log-odds of $4.0611$ to zero, i.e. the probability in your reference category would have to be $\text{expit}(0)=0.50$. The transformation from (difference in) log-odds to probability is not linear, or put differently, the difference in probability that a given odds ratio produces depends on the absolute value of the reference probability.

$\endgroup$
2
  • $\begingroup$ Thank you. I see now that I had a fundamental misunderstanding of the relationship between log odds, log odds ratios, and probability. $\endgroup$
    – Wangana
    Commented Apr 8 at 16:32
  • $\begingroup$ Follow up question, what accounts for how the log odds plot and the probability plot place the observed values differently? (also the probability plot is mislabelled, the ylab should be 'probability of outcome B') $\endgroup$
    – Wangana
    Commented Apr 11 at 6:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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