Skip to content
Scintria
ToolsGrant writerFunding
HomeLiteratureClinical trialsEvidence LabProtocol packData analysisLearnProjectsLibraryReferencesApplications
Start free
ScintriaStart free

Learn / Biostatistics / Logistic and Poisson regression

Logistic regression: modelling a yes/no outcome

15 minute read · 6-question quiz

Download this lesson as a colour Word or PDF study guide with the figures and answers. Included in paid plans; reading and quizzes stay free.Sign in

What you will learn

  • Explain why linear regression fails for binary outcomes and what the logit does

  • Interpret a logistic regression table: coefficients, odds ratios and confidence intervals

  • Convert a model to predicted probabilities

Most outcomes in health are binary: infected or not, dead or alive, readmitted or not. If we fit an ordinary straight line to a 0/1 outcome, predictions can fall below 0 or above 1, and the assumption of constant variance fails. Logistic regression solves this by modelling the log odds of the outcome, which can take any value from −∞ to +∞.

ln ((p)/(1 - p)) = β_0 + β_1 X_1 + β_2 X_2 + …

The left side is the logit of the probability p. Transforming back gives an S-shaped curve that stays between 0 and 1:

p = (1)/(1 + e^(-(β_0 + β_1 X_1 + …)))

0255075100-6-4-20246Log odds (linear predictor)Probability (%)Probability of outcome
The logistic curve turns a linear predictor into a probability between 0 and 100%.

The one fact to remember

In logistic regression, e^(β) is an odds ratio. A coefficient β = -0.63 for bed-net use means e^-0.63 = 0.53: the odds of malaria are 47% lower for children who use nets, holding the other variables constant.

Worked example: malaria in 800 children

A survey records malaria (yes/no) in 800 children, with bed-net use, age under 2 years and household poverty (simulated data for teaching; 183 had malaria).

PredictorCoefficient (β)Odds ratio95% CIp
Intercept−1.270.28
Sleeps under a net−0.630.530.38 to 0.75<0.001
Age under 2 years0.441.551.08 to 2.210.016
Poor household0.601.821.30 to 2.55<0.001

Reading it. Net users had about half the odds of malaria (OR 0.53). Children under 2 had 55% higher odds, and poor households 82% higher odds, each adjusted for the others. The CI is computed on the log scale, then exponentiated: for the net, -0.63 ± 1.96 × 0.172 gives -0.97 to -0.29, so OR = e^-0.97 to e^-0.29 = 0.38 to 0.75.

From odds ratios to probabilities

Odds ratios are not probabilities. To report risks, plug a profile into the model. For a child without a net, aged over 2 and not poor (all other variables 0), the log odds is the intercept −1.27, so odds = 0.28 and

p = (0.28)/(1 + 0.28) = 0.22

For the same child with a net: log odds = −1.27 − 0.63 = −1.90, odds 0.15, p = 0.13. The absolute risk reduction is 9 percentage points. For a poor child under 2 without a net: log odds = −1.27 + 0.44 + 0.60 = −0.23, p = 0.44. Notice that the same odds ratio gives different absolute effects in different people, which is why reporting predicted probabilities for real profiles is so helpful.

02040Predicted risk of malaria (%)21.9%No net, not poor, over 213%Net, not poor, over 244.1%No net, poor, under 2
Predicted risk from the model for three children. The same OR translates to different absolute effects.

Types of predictors

  • Binary: OR compares the two groups.
  • Continuous: OR is per one unit (or per 5 years, per 10 mmHg, whatever scale you choose). Check it is roughly linear on the log-odds scale; transform or use categories otherwise.
  • Categorical: dummy variables against a reference level.

Fitting and testing

Logistic models are fitted by maximum likelihood, not least squares. Each coefficient has a Wald test (estimate ÷ SE) and a confidence interval. To compare nested models (with and without a set of variables), use the likelihood ratio test.

Sample size

A rough guide is at least 10 events per predictor variable (events means the less frequent outcome category). With 183 malaria cases and 3 predictors the model is well within limits; with only 20 events you could safely use 2 predictors.

Common errors

  1. Quoting the OR as a risk ratio when the outcome is common (this model's outcome rate is 23%).
  2. Putting too many predictors in a model with few events.
  3. 'Perfect separation' (a predictor level where every person has the outcome) causes the fit to blow up; use Firth's penalised regression.
  4. Reading unadjusted and adjusted ORs side by side without explaining what changed. Here the crude net OR is 0.55 and the adjusted OR is 0.53, so little confounding.

Summary

  • Logistic regression models the log odds of a binary outcome; exp(β) is an odds ratio.

  • Confidence intervals are built on the log scale and then exponentiated.

  • Convert to predicted probabilities to express absolute risk for real profiles.

  • Aim for roughly 10 or more events per predictor.

  • For common outcomes, the OR overstates the RR; say 'odds'.

Check your understanding

Question 1
1

A logistic coefficient of 0.693 corresponds to an odds ratio of:

Question 2
2

An OR of 0.53 for net use means the odds of malaria are:

Question 3
3

If the log odds equal 0, the predicted probability is:

Question 4
4

Why not use ordinary linear regression for a 0/1 outcome?

Question 5
5

A model with 5 predictors is fitted to a dataset with 12 deaths. The main concern is:

Question 6
6

Logistic regression coefficients are estimated by:

Draft study guide. Spotted an error or something unclear? Tell us at hello@scintria.com. This is educational material, not clinical or regulatory advice.

Multiple regression: adjusting for several variablesPrediction models: discrimination, calibration and ROC curves