Guides / logistic regression
Logistic regression: a complete guide
Logistic regression predicts a yes-or-no outcome, and almost everything confusing about it comes down to one thing: the coefficients are on a log-odds scale nobody thinks in. This guide explains why that scale is necessary, how to convert coefficients into something interpretable, what the assumptions actually are, and how to report the model so a reader can follow it.
Logistic regression is a statistical model that predicts a binary outcome — such as pass or fail, readmitted or not — from one or more predictor variables. Instead of predicting the outcome directly, it models the probability of the outcome occurring, transformed onto a log-odds scale so the relationship can be expressed as a linear equation. Coefficients are exponentiated to give odds ratios, which describe how the odds of the outcome change per unit of the predictor.
Definition
What logistic regression does
Logistic regression predicts the probability of a binary outcome from one or more predictors. The outcome is a yes or no: passed or failed, readmitted or not, purchased or did not.
The crucial move is that the model does not predict the outcome. It predicts the probability of the outcome, and it does so in a way that guarantees the prediction stays between 0 and 1 — which, as it turns out, ordinary regression cannot do.
| Linear regression | Logistic regression | |
|---|---|---|
| Outcome | Continuous | Binary |
| Predicts | The value itself | The probability of the outcome |
| Equation is linear in | The outcome | The log odds |
| Coefficient means | Change in outcome per unit | Change in log odds per unit |
| Reported as | b, sometimes standardised | exp(b), an odds ratio |
Everything you know about regression carries over: you can include multiple predictors, control for covariates, test interactions and compare nested models. Only the link between predictors and outcome changes.
Rationale
Why not just use linear regression?
Fitting a straight line to a 0/1 outcome is technically possible and produces three specific problems, each fatal on its own.
p(1−p), which depends on p, so the homoscedasticity assumption fails by constructionThe relationship is also genuinely non-linear in a substantive sense. Moving from a 50% to a 60% chance is a very different change from moving from 95% to 99%, even though both are a 10-point and a 4-point shift respectively. The logistic curve is steep in the middle and flat at the ends, which matches how probabilities actually behave: they are hardest to shift when they are already near certainty.
In economics you will see linear regression applied to binary outcomes deliberately, with robust standard errors, because the coefficients read directly as percentage-point changes. It is a defensible choice in some settings. In health, psychology and education, logistic regression is the expectation, and departing from it needs justifying.
The scale
Odds, log odds and the logit
This is the section worth reading twice, because every interpretive difficulty in logistic regression traces back to it.
Probability and odds are not the same thing
| Probability | Odds | Log odds |
|---|---|---|
| 0.10 | 0.11 (1 to 9) | −2.20 |
| 0.25 | 0.33 (1 to 3) | −1.10 |
| 0.50 | 1.00 (evens) | 0.00 |
| 0.75 | 3.00 (3 to 1) | 1.10 |
| 0.90 | 9.00 (9 to 1) | 2.20 |
odds = p / (1 − p) and logit = ln(odds). Note the symmetry in the final column: log odds are centred on zero and symmetric around it, which is exactly the property a linear model needs.
The model itself is therefore:
ln(p / (1−p)) = b₀ + b₁x₁ + b₂x₂ + …
The b values come out as changes in log odds, which nobody has an intuition for. Exponentiating converts them to odds ratios: exp(b). A coefficient of 0.99 becomes an odds ratio of 2.70, meaning the odds of the outcome are 2.7 times higher per unit increase in the predictor.
Worked example
Worked example: interpreting a model
A study predicts whether students pass a statistics module from weekly study hours and whether they attended a support workshop. The model returns:
| Predictor | b | SE | Wald | p | exp(b) | 95% CI for OR |
|---|---|---|---|---|---|---|
| Intercept | −2.80 | 0.61 | 21.07 | <.001 | 0.06 | — |
| Study hours | 0.42 | 0.11 | 14.58 | <.001 | 1.52 | [1.23, 1.89] |
| Workshop (yes) | 0.99 | 0.34 | 8.48 | .004 | 2.69 | [1.38, 5.24] |
Reading each row
Study hours: exp(0.42) = 1.52. Each additional hour of weekly study multiplies the odds of passing by 1.52 — a 52% increase in the odds. The interval [1.23, 1.89] excludes 1, so the effect is significant.
Workshop: exp(0.99) = 2.69. Students who attended the workshop had odds of passing about 2.7 times those of students who did not, holding study hours constant.
Intercept: exp(−2.80) = 0.06, the odds of passing for a student with zero study hours who did not attend. That converts to a probability of 0.06 / 1.06 = 0.057, or about 6%.
Turning the model into a prediction
For a student studying 6 hours per week who attended the workshop:
logit = −2.80 + (0.42 × 6) + (0.99 × 1) = −2.80 + 2.52 + 0.99 = 0.71
odds = e⁰·⁷¹ = 2.034, so p = 2.034 / 3.034 = 0.670 — about a 67% chance of passing.
Here it describes a student who studies zero hours, which may not exist in your data. Centring continuous predictors on their mean makes the intercept interpretable as the outcome for an average case, and is worth doing routinely.
Interpretation
Reading coefficients and odds ratios
exp(b) | Direction | Meaning |
|---|---|---|
| > 1 | Increases the odds | 1.52 = 52% higher odds per unit |
| = 1 | No effect | The predictor tells you nothing |
| < 1 | Decreases the odds | 0.65 = 35% lower odds per unit |
There is a second scale worth knowing about, because reviewers in some fields ask for it. Marginal effects express the model's output as a change in probability rather than in odds, evaluated either at the average case or averaged across every case in the sample. The advantage is immediate interpretability — “attending the workshop raised the probability of passing by 18 percentage points” is a sentence anyone can read. The cost is that the number depends on where in the distribution you evaluate it, because the logistic curve is steep in the middle and flat at the ends. The same predictor can shift the probability by 20 points for a borderline student and by 2 for one already almost certain to pass. Report marginal effects when the audience is non-technical, and always say at what values they were computed.
The mistake almost everyone makes
An odds ratio of 2.7 does not mean the outcome is 2.7 times more likely. It means the odds are 2.7 times higher, and odds and probability diverge sharply once the outcome is common.
| Baseline probability | OR = 2.0 gives | Risk ratio |
|---|---|---|
| 0.05 | 0.095 | 1.90 — close to the OR |
| 0.20 | 0.333 | 1.67 |
| 0.50 | 0.667 | 1.33 — far from the OR |
| 0.80 | 0.889 | 1.11 — nothing like the OR |
When the outcome is rare, the odds ratio approximates the risk ratio well and the loose phrasing does little harm. When it is common, the odds ratio substantially overstates the relative risk, and treating them as interchangeable exaggerates your finding.
An odds ratio without an interval is uninterpretable. Note that the interval is computed on the log-odds scale and then exponentiated, which is why it is asymmetric around the point estimate — [1.38, 5.24] around 2.69, not equal distances either side. That asymmetry is correct, not an error.
Our odds ratio calculator computes the OR and its 95% confidence interval alongside the risk ratio, so you can report whichever your design calls for.
Use the calculatorAssumptions
Assumptions, and what to check
Logistic regression drops the normality and homoscedasticity requirements of linear regression, but it does not drop everything.
| Assumption | How to check | If violated |
|---|---|---|
| Binary outcome | Inspect the variable | Use multinomial or ordinal logistic regression |
| Independent observations | Study design | Use a mixed-effects or GEE model |
| Linearity in the logit | Box-Tidwell test, or plot by quantile | Add a quadratic term or categorise the predictor |
| No severe multicollinearity | VIF above about 5–10 | Drop or combine predictors |
| No complete separation | Huge coefficients and enormous SEs | Use penalised (Firth) logistic regression |
| Adequate events per variable | Count the rarer outcome | Reduce predictors or collect more data |
Multicollinearity behaves the same way it does in linear regression and produces the same symptom: coefficients that swing wildly when a predictor is added or removed, with inflated standard errors. The model as a whole may still predict well — collinearity damages the individual coefficients rather than the overall fit — so if prediction is your goal it may not matter much. If your question is which predictor matters, it matters a great deal.
Complete separation
If a predictor perfectly divides the outcome — everyone above a certain score passed, everyone below failed — the maximum likelihood estimate does not exist. The software will return a coefficient of implausible size with a standard error in the hundreds, and may or may not warn you. This is not a strong finding; it is a failure to converge. Firth's penalised likelihood is the standard remedy.
You are not checking whether the predictor relates linearly to the 0/1 outcome — it cannot. You are checking whether it relates linearly to the log odds. A predictor whose effect accelerates at high values will violate this, and the fix is usually a transformation or a quadratic term.
Fit
Model fit and classification
| Measure | What it tells you | Note |
|---|---|---|
| Omnibus / likelihood ratio test | Does the model beat the intercept alone? | Report this first |
| −2 log likelihood | Model deviance | Only useful for comparing nested models |
| Nagelkerke R² | Pseudo variance explained | Not a real R²; do not over-interpret |
| Hosmer-Lemeshow | Calibration of predicted vs observed | Sensitive to sample size; unreliable when large |
| AUC / c-statistic | Discrimination between outcomes | 0.5 is chance, 0.7 acceptable, 0.8 good |
| Classification table | Accuracy at a chosen cut-off | Misleading with imbalanced outcomes |
Why accuracy can be a trap
If 95% of your sample passes, a model predicting “pass” for everyone is 95% accurate and completely useless. Report sensitivity and specificity separately, and prefer the AUC, which assesses discrimination across every possible cut-off rather than one arbitrary threshold.
Our sensitivity and specificity calculator returns the full set of classification measures with confidence intervals from a 2×2 table.
Use the calculatorSample size
Sample size and the events-per-variable rule
Logistic regression is more demanding of sample size than linear regression, and what matters is not the total N but the number of cases in the less common outcome category.
The traditional guidance is at least 10 events per predictor variable. With 5 predictors you need at least 50 cases in the smaller outcome group — not 50 participants overall.
| Predictors | Minimum events (EPV 10) | Total N if 20% event rate |
|---|---|---|
| 2 | 20 | 100 |
| 4 | 40 | 200 |
| 6 | 60 | 300 |
| 10 | 100 | 500 |
More recent work suggests the rule of 10 is too crude — sometimes conservative, sometimes badly optimistic depending on the event rate and the predictor distributions. Treat it as a floor rather than a target, and where the model matters, run a proper sample size calculation.
Too few events per variable produces coefficients biased away from the null, standard errors that are too small, and a model that will not replicate. It is one of the most common reasons a promising prediction model fails on new data.
Send your design and expected event rate. A named statistician calculates the sample you need for the model you intend to fit, while it is still possible to act on the answer.
See sample size and powerPitfalls
Seven mistakes that cost marks
1. Reading an odds ratio as a risk ratio
“2.7 times more likely” is wrong unless the outcome is rare. Say “the odds were 2.7 times higher”.
2. Reporting b instead of exp(b)
Raw coefficients are log odds and are not interpretable. Exponentiate them.
3. Omitting the confidence interval
An odds ratio alone gives no sense of precision. Always report the interval.
4. Treating Nagelkerke R² as variance explained
It is a pseudo-R² on a different scale from the linear-model version and is not comparable to it.
5. Ignoring complete separation
Enormous coefficients with enormous standard errors mean the model did not converge, not that you found a powerful predictor.
6. Too many predictors for the number of events
Check events per variable before fitting, not after.
7. Reporting overall accuracy on imbalanced data
Give sensitivity, specificity and the AUC instead.
Reporting
Reporting logistic regression in APA style
| Element | How to write it |
|---|---|
| Model test | χ²(2, N = 210) = 38.42, p < .001 |
| A predictor | b = 0.42, SE = 0.11, Wald = 14.58, p < .001, OR = 1.52, 95% CI [1.23, 1.89] |
| Model fit | Nagelkerke R² = .24 |
| Discrimination | AUC = .78, 95% CI [.71, .85] |
“A binary logistic regression predicting pass/fail from weekly study hours and workshop attendance was significant, χ²(2, N = 210) = 38.42, p < .001, Nagelkerke R² = .24. Each additional study hour was associated with 52% higher odds of passing (OR = 1.52, 95% CI [1.23, 1.89]), and workshop attendance with 2.69 times the odds (95% CI [1.38, 5.24]). Of 210 students, 84 failed, giving 42 events per predictor.”
Send your dataset and research question. A named statistician fits the model, checks separation and collinearity, and returns annotated output with the odds ratios interpreted in plain language.
See statistical consultancyAnswers
Frequently asked questions
What is logistic regression used for?
Predicting a binary outcome — pass or fail, readmitted or not, converted or not — from one or more predictor variables. It models the probability of the outcome rather than the outcome itself, which keeps predictions between 0 and 1 and allows several predictors to be assessed simultaneously.
Why can't I use linear regression for a yes/no outcome?
Because a straight line is unbounded and will predict probabilities above 1 and below 0. The variance of a binary outcome also depends on the probability itself, so the constant-variance assumption fails by construction, and residuals cannot be normally distributed when only two outcomes exist.
What is the difference between an odds ratio and a risk ratio?
The risk ratio compares probabilities; the odds ratio compares odds. They are close when the outcome is rare and diverge sharply when it is common. An odds ratio of 2.0 with a baseline probability of 0.5 corresponds to a risk ratio of only 1.33, so describing an OR as 'times more likely' overstates the effect.
How do I interpret a logistic regression coefficient?
Exponentiate it. The raw coefficient b is a change in log odds, which has no intuitive meaning; exp(b) is an odds ratio. An exp(b) of 1.52 means each one-unit increase in the predictor multiplies the odds of the outcome by 1.52, a 52% increase in the odds.
What sample size do I need for logistic regression?
What matters is the number of cases in the less common outcome category, not the total. The traditional rule is at least 10 such events per predictor, so a model with 5 predictors needs at least 50 events. Treat that as a floor; recent work shows it can be optimistic depending on the event rate.
What is complete separation?
When a predictor perfectly divides the outcome, so that everyone above some value has one result and everyone below the other. The maximum likelihood estimate then does not exist, and software returns implausibly large coefficients with enormous standard errors. Firth's penalised logistic regression is the usual fix.
What is a good Nagelkerke R squared?
There is no accepted threshold, and it should not be read as variance explained in the way a linear-model R squared is. Values in logistic regression are typically much lower than researchers expect. Discrimination measures such as the AUC are usually more informative for judging whether a model is useful.
Can logistic regression handle more than two outcome categories?
Not in its binary form. Use multinomial logistic regression for unordered categories such as choice of course, and ordinal logistic regression for ordered ones such as low, medium and high. Both extend the same underlying logic.
Keep reading
Related guides and services
Odds ratio calculator
The OR with its confidence interval, alongside the risk ratio.
GuideChi-square test
The simpler test for association between two categorical variables.
Case studyGLMM to identify drivers of production defects
A quarter of a million records where univariate analysis could not separate the factors.
Send the data. Get a fixed quote.
Attach your dataset or just describe the project. A named statistician replies with a price and a deadline, usually within one working day.