All lab tutorials

Regression modeling

From log odds to predicted risk

How do you translate a logistic coefficient into probabilities?

Population and data

Compare outcomes between two groups and report a quantity the audience can interpret. The group coefficient measures a change on the log-odds scale. To obtain an absolute risk change, you also need the starting risk.

In group 0, 10 of 100 people experience an event. In group 1, 25 of 100 do. Fit a binomial logistic model with just a group indicator.

Working data
GroupEventsNon-eventsRiskOdds
010900.101/9
125750.251/3

Notation

Y,XY,X
Binary event indicator and group indicator, both coded 0 or 1.
p(x)p(x)
Population event probability conditional on group x.
β0,β1\beta_0,\beta_1
Baseline log odds and group difference in log odds.
p^(x)\hat p(x)
Estimated group probability obtained from fitted coefficients.

Derivation

p(x)=P(Y=1∣X=x),eβ1=p(1)/(1−p(1))p(0)/(1−p(0))p(x)=P(Y=1\mid X=x),\qquad e^{\beta_1}=\frac{p(1)/(1-p(1))}{p(0)/(1-p(0))}

With one intercept and one binary predictor, the model has one free probability per group. For independent binomial observations, maximizing each group likelihood yields its observed event proportion. Finite group logits require both outcomes in each group. [1]

Start at x = 0. Its odds fix the intercept. Moving to x = 1 adds one coefficient on the log scale. Exponentiating converts that addition into multiplication of the starting odds.

log⁡p(x)1−p(x)=β0+β1x,β^0=log⁡(1/9),p^(1)1−p^(1)=19×3\log\frac{p(x)}{1-p(x)}=\beta_0+\beta_1x,\quad \hat\beta_0=\log(1/9),\quad \frac{\hat p(1)}{1-\hat p(1)}=\frac19\times3

Odds of one to three imply one event per four people. In R the response below supplies event and non-event counts in that order. Reversing the columns models the complementary outcome. [1]

Subtract the group log odds. Exponentiating the difference gives the odds ratio.

β^1=log⁡(25/75)−log⁡(10/90)=log⁡3\hat\beta_1=\log(25/75)-\log(10/90)=\log 3

Invert the logit for each group and compare on the probability scale.

p(x)=11+e−(β0+β1x),p^(1)−p^(0)=0.25−0.10=0.15p(x)=\frac{1}{1+e^{-(\beta_0+\beta_1x)}},\quad \hat p(1)-\hat p(0)=0.25-0.10=0.15

R analysis

Download the complete R script
d <- data.frame(x = 0:1, events = c(10, 25), n = 100)
fit <- glm(cbind(events, n-events) ~ x, binomial(), data = d)
round(unname(c(exp(coef(fit)[2]), fitted(fit))), 3)

R output

[1] 3.00 0.10 0.25

The odds triple, while the observed risk rises by 15 percentage points. With a separate fitted probability for each group, this model reproduces both observed proportions.

Can one odds ratio imply several risk differences?

Carry the fitted odds ratio of three to three hypothetical baseline risks. Convert each probability to odds, multiply, then convert back.

baseline <- c(.01, .10, .50)
odds1 <- 3 * baseline / (1-baseline)
risk1 <- odds1 / (1+odds1)
round(data.frame(baseline, risk1, difference = risk1-baseline), 3)

R output

  baseline risk1 difference
1     0.01 0.029      0.019
2     0.10 0.250      0.150
3     0.50 0.750      0.250

For baseline risks of 1%, 10% and 50%, the absolute increases are about 1.9, 15 and 25 percentage points. Reporting only the odds ratio hides variation that matters for decisions about absolute risk. [2]

Try a variation

What is the risk ratio?

Reveal the explanation

0.25 / 0.10 = 2.5. Odds use events divided by non-events; risks use events divided by all people.

References

The datasets and calculations are teaching examples created for this tutorial. The sources below explain the methods used.

  1. James G, Witten D, Hastie T, Tibshirani R. An Introduction to Statistical Learning: with Applications in R. 2nd ed. Springer, 2021. §4.3.

    The logit model and the conversion of fitted log odds to probabilities.

  2. Davies HTO, Crombie IK, Tavakoli M. When can odds ratios mislead? BMJ. 1998;316:989–991.

    Interpreting an odds ratio alongside baseline risk and risk ratios.