statforclinicians

Logistic regression

Estimates how the odds of a yes/no outcome change with one or more factors, holding the others fixed.

Statistically reviewed by Hidde Stek on 4 November 2026.

Clinical example

Do the odds of a postoperative complication differ between patients with and without diabetes, once age and type of surgery are taken into account?

When to use it

  • The outcome is yes or no, one per patient.
  • Every patient is followed for the same fixed period, or the outcome is measured once.
  • You need to adjust for other variables, or relate the outcome to a continuous factor.
  • You have enough patients in the smaller outcome group for the number of parameters you want to include.

Assumptions to check

Independent observations

One value per patient. Repeated measurements or clustered patients need GEE or a mixed model.

Linearity on the logit scale

A continuous factor is assumed to have a straight-line relation with the log odds. To check, add a restricted cubic spline or a squared term for that factor and see whether the fit or the estimates change.

Enough events per parameter

As a rule of thumb, about 10 events per parameter (Peduzzi et al. 1996). The limiting number is the smaller of the two outcome groups, events or non-events: if 85% of patients have a complication, the 15% without one limit the model. Count parameters, not predictors: a factor with 4 levels uses 3. The rule is contested. Vittinghoff and McCulloch (2007) found 5 to 9 events per parameter often adequate for adjustment, and for prediction models Riley et al. (2019, 2020) recommend a formal sample-size calculation.

No separation or sparse data

Very large odds ratios with extremely wide confidence intervals are the warning sign, often with few events or a factor that almost perfectly predicts the outcome. Firth's penalised logistic regression (or exact logistic regression) handles this.

Check first

  • The event is the outcome coded 1: in R the second factor level, in SPSS the higher code. Coding it the other way flips every odds ratio.

What to report

  • Odds ratio with 95% CI for your main factor, crude and adjusted
  • The variables you adjusted for, and why
  • How the outcome was coded (which outcome is the event) and the reference category of each factor
  • The unit of each continuous factor (for example per year of age) and whether it was modelled as linear or with a spline
  • The number of events and of patients in the model, and how many were left out because of missing data

Common mistakes

Avoid selecting variables by stepwise or by p-value

It tends to overfit, biases the estimates and makes confidence intervals too narrow. Choose variables in advance, for example with a causal diagram (DAG).

An odds ratio is not a risk ratio

When the outcome is common (more than about 10% of patients), the odds ratio is further from 1 than the risk ratio. Log-binomial regression gives a risk or prevalence ratio instead. Don't describe an odds ratio of 2 as "twice the risk".

Don't dichotomize a measurement

Cutting a continuous variable into high and low ("BP above 140") throws away information and power, and the cut-off is often arbitrary.

Comparing odds ratios between subgroups instead of testing an interaction.

Alternatives

If your situation is…Use
Repeated measurements or clustered patientsGEE and mixed-effects logistic regression
No adjustment neededChi-square test
Common outcome in a cohort or trial and you want a risk ratio (log-binomial, or Poisson with robust SE)Log-binomial regression
Matched case-control studyConditional logistic regression
Follow-up time differs or patients are censoredCox proportional hazards regression
Ordered outcome categoriesProportional odds (ordinal logistic) regression
Three or more unordered categoriesMultinomial logistic regression
Building a prediction model rather than estimating one effect: use penalised regression (for example LASSO or ridge) instead of stepwise selectionPrediction models (not covered yet)

In your software

R
# R
# complication: 0/1, or a factor whose second level is the event
# surgery_type as a factor: its first level is the reference
cohort$surgery_type <- factor(cohort$surgery_type)
fit <- glm(complication ~ diabetes + age + surgery_type,
           family = binomial, data = cohort)
nobs(fit)   # patients used; glm drops missing values silently
or <- exp(cbind(OR = coef(fit), confint(fit)))
or[-1, ]    # intercept left out: baseline odds, not an OR
SPSS
LOGISTIC REGRESSION VARIABLES complication
  /METHOD=ENTER diabetes age surgery_type
  /CATEGORICAL=surgery_type
  /CONTRAST(surgery_type)=Indicator(1)
  /PRINT=CI(95).

Sources