Back to Blog
Statistics
11 min read

Logistic Regression: A Practical Guide for Researchers

Logistic regression models a binary outcome and reports odds ratios. Learn when to use it, how to interpret coefficients, and the assumptions to check.

Dr. Sarah Mitchell

June 3, 2026

Building a logistic model and worried about overfitting or assumptions? Our statistical analysis service builds and validates the model and writes the results.

Key Takeaways

Logistic regression models a binary outcome by predicting the log odds and reporting effects as odds ratios

It replaces linear regression because the logit link keeps predicted probabilities between zero and one

An odds ratio above one increases the odds of the outcome and below one decreases it; one means no association

Odds ratios are not risk ratios and overstate the effect when the outcome is common

Check independence, linearity in the logit, multicollinearity, and events per variable before trusting the model

The coefficients are fitted by maximum likelihood with no closed form; a convergence failure usually signals separation, fixed by Firth penalized likelihood rather than by dropping the variable

The odds ratio is non-collapsible, so adjusted and unadjusted values differ even without confounding; report whether your estimate is conditional or marginal

Judge the model by discrimination (area under the ROC curve) and calibration, not by significant coefficients; the Hosmer-Lemeshow test is discouraged

Logistic regression models the relationship between one or more predictors and a binary outcome, an outcome with two categories such as alive or dead, relapsed or not, responded or not. Instead of predicting the outcome directly, it predicts the log odds of the outcome and converts each predictor's effect into an odds ratio. That is why logistic regression is the default tool whenever the thing you are trying to explain is a yes-or-no event rather than a measured quantity.

Why you cannot just use linear regression

When the outcome is binary, ordinary linear regression breaks in concrete ways: it can predict probabilities below zero and above one, and its assumptions about the residuals are violated because a two-value outcome cannot be normally distributed around a line. Logistic regression solves this with the logit link, which transforms a probability bounded between zero and one into a log-odds scale that runs from minus to plus infinity. The model is linear on that log-odds scale, which keeps predictions inside the valid probability range and gives the coefficients a clean interpretation. Choosing logistic over linear is therefore not a stylistic preference; it follows directly from the type of outcome variable you have.

Reading the output: coefficients and odds ratios

A logistic regression coefficient is on the log-odds scale, which is hard to interpret directly, so you exponentiate it to get an odds ratio. The rule of thumb is simple:

  • An odds ratio of 1 means the predictor has no association with the outcome.
  • An odds ratio above 1 means higher values of the predictor increase the odds of the outcome.
  • An odds ratio below 1 means higher values decrease the odds.

For a binary predictor, the odds ratio compares the two groups; for a continuous predictor, it gives the change in odds for a one-unit increase. When you want to sanity-check a model's odds ratio against a simple two-by-two table, our odds ratio calculator gives the unadjusted value and its confidence interval, which is a useful baseline before you trust the adjusted estimate.

Odds ratios are not risk ratios

A persistent source of error is treating the odds ratio as if it were a relative risk. The two diverge as the outcome becomes common: an odds ratio of 2 can correspond to a much smaller increase in actual risk when the outcome is frequent. For rare outcomes the two are close, which is why case-control studies can use the odds ratio as a stand-in for risk, but for common outcomes the gap is real and reporting an odds ratio as though it were a risk overstates the effect. If your audience needs an interpretable risk, our explainer on risk ratios shows when each measure is appropriate.

Univariable, then multivariable

Most analyses move from univariable models, one predictor at a time, to a multivariable logistic regression that includes several predictors together. The multivariable model is what lets you report the effect of an exposure adjusted for confounders, the central goal of most observational analysis. Building it well means deciding in advance which variables to include based on subject knowledge rather than letting an automated stepwise procedure churn through the data, which inflates false findings. A common planning rule is to allow roughly ten outcome events per predictor so the model is not overfit.

The assumptions that actually matter

Logistic regression has fewer assumptions than linear regression, but the ones it has are easy to violate:

  • Independence of observations. Clustered or repeated data need a model that accounts for the clustering, not a plain logistic regression.
  • Linearity in the logit. Continuous predictors are assumed to have a linear relationship with the log odds; if they do not, the predictor may need transformation or a spline.
  • No extreme multicollinearity. Predictors that are near-duplicates inflate standard errors and destabilize the coefficients.
  • Adequate events per variable. Too few outcome events for the number of predictors produces unstable, overfit estimates.

Checking these is part of the analysis, not an optional extra, and skipping them is how a published odds ratio turns out to be an artifact.

Variants you will meet

When the outcome has more than two categories, multinomial logistic regression generalizes the model; when the categories are ordered, ordinal logistic regression uses that ordering. When the outcome is a count rather than a binary event, you move to Poisson or negative binomial models instead. Recognizing which member of the family fits your outcome is the same kind of design decision as converting between effect sizes when you pool results: the right tool is dictated by the data, and using the wrong one quietly biases everything downstream.

Need statistical analysis support?

Our PhD statisticians handle data analysis, produce reproducible R code, and write results sections that satisfy peer reviewers.

The model written out, and how it is fitted

Behind the odds ratios sits a compact equation. Logistic regression models the log odds of the outcome as a linear function of the predictors:

logit(p) = ln( p / (1 - p) ) = b0 + b1*x1 + b2*x2 + ... + bk*xk

Rearranging for the probability gives the logistic (sigmoid) function, which is what forces every prediction back inside the zero-to-one range:

p = 1 / ( 1 + exp( -(b0 + b1*x1 + ... + bk*xk) ) )

Unlike linear regression, there is no closed-form solution for these coefficients. They are estimated by maximum likelihood, which searches for the values that make the observed pattern of ones and zeros most probable. Software finds them iteratively, almost always through a Newton-Raphson routine that statisticians call iteratively reweighted least squares, repeating until the estimates stop moving. When you read that a model "failed to converge", this is the loop that did not settle, and the cause is usually sparse data or separation, not a coding mistake.

Two quantities from that fit do most of the inferential work. The deviance measures how far the fitted model sits from a perfect fit, and the difference in deviance between two nested models is a likelihood-ratio test of whether the extra predictors earn their place. For a single coefficient the software shows a Wald test by default, but the likelihood-ratio test is more trustworthy in small samples and when an odds ratio is large, so prefer it whenever the two disagree.

Separation: the trap that sends an odds ratio to infinity

If a predictor splits the outcome perfectly, or almost perfectly, for instance every patient above a threshold had the event and none below it did, maximum likelihood has no finite answer and the coefficient is pushed toward plus or minus infinity. This is complete or quasi-complete separation, and it surfaces as an enormous odds ratio with a standard error larger still, or a warning that fitted probabilities of zero or one occurred. The fix is not to delete the offending variable. The standard remedy is Firth's penalized likelihood, which adds a small bias-reducing penalty (the Jeffreys prior) and returns finite, well-behaved estimates; for very sparse tables, exact logistic regression is the alternative.

library(logistf)            # Firth's bias-reduced logistic regression
fit <- logistf(event ~ exposure + age + sex, data = d)
summary(fit)                # finite estimates with profile-penalized intervals

Why the adjusted and unadjusted odds ratio differ even without confounding

Researchers expect an odds ratio to move when a confounder is added and to stay put when an irrelevant variable is added. The odds ratio breaks that expectation, because it is non-collapsible: adjusting for a genuine predictor of the outcome changes the odds ratio even when that predictor is unrelated to the exposure and so confounds nothing. The conditional (adjusted) odds ratio is pulled away from the marginal (population-average) odds ratio purely by the mathematics of the odds scale. This has two consequences. First, you cannot read a shift in the odds ratio between models as evidence of confounding the way you can with a risk ratio or risk difference, both of which are collapsible. Second, if the quantity you care about is the population-average effect, report an average marginal effect or a marginal odds ratio obtained by g-computation rather than the raw coefficient. Stating plainly whether your odds ratio is conditional or marginal is the kind of precision a methods reviewer looks for.

Adjusted odds ratios, assumption checks, and a clean interpretation, handled by a biostatistician. Get a free quote.

Judging the model: discrimination and calibration, not just p-values

A model with significant coefficients can still predict badly. Two distinct properties decide whether it is any good. Discrimination is how well the model separates those who had the event from those who did not, summarised by the concordance statistic, which equals the area under the receiver operating characteristic curve: 0.5 is a coin toss and values toward 1.0 are better. Calibration is whether the predicted probabilities match observed frequencies, for example whether events actually occur about 30 percent of the time among people the model assigned a risk of 0.3. Inspect calibration with a calibration plot and the calibration slope and intercept; the once-standard Hosmer-Lemeshow test is now discouraged, because its verdict depends on an arbitrary number of groups and it has weak power. For a model built to predict rather than to explain, validate it on data it has not seen, or internally by bootstrapping to estimate optimism, and report it against the TRIPOD reporting guideline.

Beyond "ten events per variable"

The familiar rule of roughly ten outcome events per predictor is a rough floor, not a guarantee. Simulation work by van Smeden and colleagues shows that the events-per-variable count alone does not determine whether estimates are stable: the number of candidate predictors, the outcome fraction, and the strength of the real effects all matter, and a well-calibrated model sometimes needs more. When events are scarce relative to predictors, do not force a large model. Penalized estimation shrinks coefficients toward zero and trades a little bias for much lower variance: ridge regression (an L2 penalty) keeps every predictor, the least absolute shrinkage and selection operator (a penalty that can set coefficients to exactly zero) performs selection, and Firth's penalty doubles as a small-sample correction. For matched case-control designs, use conditional logistic regression so the matching is respected; for clustered or repeated outcomes, use a mixed-effects logistic model or generalized estimating equations with cluster-robust standard errors rather than a plain fit that wrongly treats correlated observations as independent.

A worked fit in R

# Multivariable logistic regression with continuous and binary predictors
fit <- glm(event ~ age + sex + biomarker, data = d, family = binomial)

# Odds ratios with profile-likelihood confidence intervals
exp(cbind(OR = coef(fit), confint(fit)))

# Likelihood-ratio test for the whole model
anova(fit, test = 'LRT')

# Check linearity in the logit for a continuous predictor using a spline
library(splines)
fit_spline <- glm(event ~ ns(age, 3) + sex + biomarker, data = d, family = binomial)
anova(fit, fit_spline, test = 'LRT')   # significant means the straight line is too simple

# Discrimination: area under the ROC curve
library(pROC)
auc(d$event, predict(fit, type = 'response'))

Getting it right

Logistic regression is approachable enough to run with a few clicks and subtle enough to get wrong in ways reviewers catch: an unchecked linearity assumption, an overfit model, an odds ratio reported as a risk. If your analysis has to survive statistical review, having a biostatistician build and validate the model is usually faster than fixing it after a reviewer flags it. A professional statistical analysis service can handle the modeling and validation end to end.

Pro Tip

Choose predictors by knowledge, not by stepwise search

Automated variable selection inflates false positives. Decide which confounders to include from subject-matter reasoning before you run the model.

Pro Tip

Budget about ten events per predictor

Too few outcome events for the number of variables overfits the model and destabilizes the odds ratios. Plan the predictor count against your event count.

Pro Tip

Never report an odds ratio as a risk

When the outcome is common, the two diverge. State clearly that you are reporting odds, or convert to a risk measure your readers can interpret.

Pro Tip

Treat a convergence warning as separation

An infinite odds ratio with a huge standard error means a predictor splits the outcome almost perfectly. Use Firth penalized likelihood (the logistf package in R) to recover finite estimates instead of deleting the variable.

Frequently Asked Questions

5
Logistic regression models the relationship between predictors and a binary outcome, such as disease versus no disease. It estimates how each predictor changes the odds of the outcome and reports those effects as odds ratios.
Linear regression predicts a continuous outcome and can produce impossible probabilities for a binary one. Logistic regression uses the logit link to model the log odds of a two-category outcome, keeping predicted probabilities between zero and one.
Exponentiate the coefficient to get the odds ratio. A value above one means the predictor increases the odds of the outcome, below one means it decreases them, and one means no association. For a continuous predictor it reflects a one-unit change.
No. They are close when the outcome is rare but diverge as it becomes common, with the odds ratio overstating the effect. Report it as odds, and use a risk measure if your audience needs interpretable risk.
A common guideline is about ten outcome events per predictor to avoid overfitting. With few events, limit the number of variables or use methods designed for sparse data rather than forcing a large model.
Share

Found this useful? Share it with your colleagues.

Need statistical analysis support?

Our PhD statisticians handle data analysis, produce reproducible R code, and write results sections that satisfy peer reviewers.

Explore our Biostatistics Service, handled end-to-end by a PhD methodologist.

Biostatistics Support

Need a Statistician? Our PhD Team Handles the Numbers.

From data cleaning to advanced statistical analysis, reproducible R code, and a results section ready for peer review. We handle the stats so you focus on the science.

Our promise: Free re-run and re-write if reviewers question the analysis or reporting.

4.9 / 5Quote within a few hoursReproducible R or Stata codePhD methodologistConfidential by default
Chat on WhatsApp now
DS

Written by

Dr. Sarah Mitchell

PhD, Biostatistics & Research Methodology
Systematic Review MethodologyMeta-AnalysisBiostatistics

Dr. Sarah Mitchell holds a PhD in Biostatistics from Johns Hopkins Bloomberg School of Public Health and has over 15 years of experience in systematic review methodology and meta-analysis. She has authored or co-authored 40+ peer-reviewed publications in journals including the Journal of Clinical Epidemiology, BMC Medical Research Methodology, and Research Synthesis Methods. A former Cochrane Review Group statistician and current editorial board member of Systematic Reviews, Dr. Mitchell has supervised 200+ evidence synthesis projects across clinical medicine, public health, and social sciences.

A logistic regression is easy to run and easy to get wrong in ways reviewers notice. If your analysis has to pass statistical review, our biostatistics team specifies the model, checks every assumption, and reports defensible odds ratios. Start with a quote.

Need a Statistician? Our PhD Team Handles the Numbers.

From data cleaning to advanced statistical analysis, reproducible R code, and a results section ready for peer review. We handle the stats so you focus on the science.

Quote within a few hours. Pay only after you approve your quote. Unlimited revisions within your agreed scope. Confidential by default.