What Is Logistic Regression?
Logistic regression is a statistical model that estimates the probability of a binary outcome from one or more predictor variables. The term "logistic" refers to the logistic (sigmoid) function a mathematical S-curve that maps any real-valued input to a probability between 0 and 1, which is essential when modeling yes/no outcomes that must remain within those bounds.
Unlike linear regression, which predicts a continuous outcome directly (Y = 2 + 2X), logistic regression models the log-odds (logit) of the outcome as a linear function of the predictors. The model is then transformed back into a probability using the logistic function.
Log-odds (logit): ln(p / (1p)) = 2 + 2X + 2X + ... + 2X
Odds Ratio for predictor X: OR = e2
The Logistic (Sigmoid) Function Constraining Predictions Between 0 and 1
The S-shaped curve illustrates the key advantage of logistic regression: no matter how extreme the predictor values become, the predicted probability is always constrained between 0 and 1 a mathematical property that linear regression cannot guarantee. The model automatically handles the non-linearity of probability at the extremes while maintaining a linear relationship in the middle range.
When to Use Logistic Regression The Decision Criteria
The single most important criterion for choosing logistic regression is the nature of your outcome variable. If the outcome is binary, logistic regression is almost always the correct choice. Everything else number of predictors, sample size, choice of software is secondary.
... Use logistic regression when...
- Outcome is binary (yes/no, 0/1, event/no event)
- You have 2 predictor variables to examine simultaneously
- You need to adjust for confounders
- You want adjusted odds ratios as output
- You need to estimate probability of the outcome for individual patients
- You are building a clinical prediction model or risk score
- Outcome prevalence is 10% (OR RR) or you accept OR interpretation
Do NOT use logistic regression when...
- Outcome is continuous (use linear regression)
- Outcome is time-to-event with censoring (use Cox regression)
- Outcome has 3+ ordered categories (use ordinal logistic)
- Outcome has 3+ unordered categories (use multinomial logistic)
- Observations are not independent (repeated measures, matched data use conditional/mixed-effects logistic regression)
- You have fewer than 10 outcome events per predictor (overfitting risk)
Binary Outcomes in Clinical Research Examples
| Clinical Domain | Binary Outcome | Typical Predictors |
|---|---|---|
| Intensive care | ICU mortality (died vs survived) | APACHE II, age, mechanical ventilation, vasopressors, sepsis |
| Surgery | Surgical site infection (SSI yes vs no) | Diabetes, BMI, operation duration, antibiotic timing |
| Cardiology | 30-day readmission after MI (yes vs no) | Ejection fraction, age, HbA1c, creatinine, smoking |
| Oncology | Pathological complete response to neoadjuvant chemo (yes vs no) | Tumour grade, HER2 status, tumour size, lymph node status |
| Endocrinology | Type 2 diabetes development (yes vs no) | BMI, family history, fasting glucose, hypertension, age |
| Obstetrics | Caesarean delivery (yes vs no) | Bishop score, maternal age, BMI, parity, previous CS |
| Nephrology | Acute kidney injury in ICU (yes vs no) | Pre-existing CKD, contrast exposure, sepsis, age, creatinine |
Three Types of Logistic Regression Which One for Your Outcome?
| Type | Outcome Categories | Clinical Example | Output |
|---|---|---|---|
| Binary | Exactly 2 (yes/no) | Diabetes: present vs absent | Adjusted Odds Ratio (aOR) |
| Multinomial | 3+ unordered categories | Treatment response: complete / partial / none | Relative Risk Ratio vs reference category |
| Ordinal | 3+ ordered categories | Pain: mild / moderate / severe; ECOG PS 04 | Proportional Odds Ratio (assumes constant OR across cut-points) |
Binary logistic regression is by far the most common type in clinical research and the focus of this guide. If your outcome is ordinal with clear ordering and the proportional odds assumption holds (test using the Brant test or score test in your software), ordinal logistic regression is more efficient than collapsing categories or running multiple binary models.
Understanding the Odds Ratio The Core Output
The primary output of logistic regression is the odds ratio (OR) for each predictor. Understanding what an OR means and what it does not mean is essential for correct interpretation and reporting.
The Odds Ratio Scale How to Read the Direction and Magnitude
Strong protective
Moderate protective
No effect
Moderate risk
Strong risk
(reduces odds) OR = 1
No association Strongly increases
odds of outcome
Interpreting Odds Ratios in Practice
For a binary predictor (e.g., smoker vs non-smoker): OR = 2.14 means that smokers have 2.14 times the odds of the outcome compared to non-smokers, after adjusting for all other variables in the model. OR = 0.45 means exposed patients have 55% lower odds (1 0.45 = 0.55 = 55% reduction).
For a continuous predictor (e.g., age in years): OR = 1.08 means that for each one-year increase in age, the odds of the outcome increase by 8%, holding all other variables constant. If age were entered in 10-year increments, OR = 1.08 per year would be expressed as OR = 1.0810 = 2.16 per decade.
For a categorical predictor with multiple levels (e.g., ECOG PS 0/1/2/3): each level is compared to the reference category (usually the lowest or most common). OR for ECOG PS 2 vs 0 = 3.41 means patients with PS 2 have 3.41 times the odds compared to PS 0 patients.
The 95% Confidence Interval What It Tells You
Every OR must be reported with its 95% confidence interval. An OR of 2.14 (95% CI 0.875.26) is not statistically significant the CI includes 1.0, meaning zero association is consistent with the data. An OR of 2.14 (95% CI 1.483.09) is significant the CI excludes 1.0. A wide CI indicates an imprecise estimate (small sample or rare events). A narrow CI indicates a precise estimate (large sample or common events).
Five Key Assumptions to Check Before Running Logistic Regression
Binary dependent variable
The outcome must have exactly two categories, typically coded 0 (absence of outcome) and 1 (presence of outcome). Logistic regression cannot be applied to continuous, count, or multi-category outcomes without modification.
Independence of observations
Each patient in the dataset must contribute only one outcome independently. Paired or matched data, repeated-measures designs, or clustered data (multiple patients from the same hospital) violate this assumption and require conditional logistic regression or mixed-effects logistic regression instead.
Adequate events per variable (EPV 10)
Logistic regression requires a minimum of 10 outcome events per predictor variable. With fewer events per variable, the model overfits regression coefficients become inflated, confidence intervals are too narrow, and results are unreliable and non-reproducible. This is arguably the most commonly violated assumption in published medical literature.
No severe multicollinearity among predictors
When two or more predictors are highly correlated (e.g., serum creatinine and eGFR, or BMI and body weight), the model cannot reliably separate their independent effects. Standard errors inflate, confidence intervals widen abnormally, and regression coefficients become numerically unstable sometimes reversing sign between nearly identical models.
Linearity of continuous predictors with the log-odds
Logistic regression assumes that continuous predictor variables have a linear relationship with the log-odds (logit) of the outcome. If a continuous predictor has a U-shaped or threshold relationship with the outcome, treating it as linearly contributing to the model will produce misleading results.
How to Build a Logistic Regression Model Step by Step
Define the research question and binary outcome precisely
State exactly what you are modelling: "What are the independent predictors of 30-day all-cause mortality in patients with sepsis admitted to the ICU?" Specify the outcome event (mortality) and the time window (30 days). Ambiguous outcome definitions produce ambiguous results.
Select predictor variables a priori from clinical knowledge and literature
List all candidate predictors before analyzing data, based on biological plausibility and evidence from prior studies. Include known confounders regardless of whether they reach statistical significance in your dataset. Document your variable selection rationale in the methods section this is what reviewers audit most carefully.
Check EPV constraint how many predictors can your data support?
Count the number of patients in the less frequent outcome category (e.g., patients who died). Divide by 10 to get the maximum number of predictors. If you have 60 deaths in your dataset, you can include at most 6 predictor variables. Prioritize the most clinically important if you must reduce the list.
Run univariate logistic regression for each predictor (optional screening)
Run simple (one-predictor) logistic regression for each candidate variable to produce crude ORs. These will be reported alongside adjusted ORs in your results table, allowing readers to see which associations changed after adjustment direct evidence of confounding. Some researchers use p < 0.20 as a screening threshold, but always override screening for known confounders.
Enter all selected predictors simultaneously into the multivariable model
Use the "Enter" method (forced entry of all pre-specified variables simultaneously). Do not use stepwise methods as the primary strategy they produce overfit, unreplicable models. All variables you selected in step 2 should be in the model regardless of their univariate significance.
Check model fit and assess assumptions
Run the Hosmer-Lemeshow goodness-of-fit test (p > 0.05 = good fit the model adequately fits the data). Check VIF for multicollinearity. Examine the classification table and ROC/AUC. Check for influential observations using Cook's distance or hat values. Run Box-Tidwell test for continuous predictors if concerned about non-linearity.
Report crude ORs, adjusted ORs, 95% CIs, and model fit statistics
Present a standard results table showing both crude (univariate) and adjusted (multivariate) ORs with 95% CIs and p-values for every predictor. Report the Hosmer-Lemeshow test result, Nagelkerke R2, AUC, and total sample size with number of events. This is the minimum required by most journals.
Example: 85 deaths in 420 patients max 8 predictor variables
Conservative rule: Events - 20 (preferred for publication in high-impact journals)
Interpreting the Logistic Regression Output Table
Statistical software (SPSS, R, Stata, SAS) produces a standardized logistic regression output. Understanding each component prevents the most common reporting errors.
| Output Component | What It Tells You | What to Report |
|---|---|---|
| 2 (B coefficient) | The change in log-odds per unit change in the predictor | Usually not reported in clinical papers convert to OR = e^2 |
| S.E. (Standard error) | Precision of the 2 estimate | Not reported directly used to compute CI |
| Wald statistic | Test statistic for whether 2 0 | Not typically reported report p-value |
| p-value | Test of whether the OR is significantly different from 1.0 | Always report; use exact values (p = 0.003), not p < 0.05 |
| Exp(B) = OR | The adjusted odds ratio for that predictor | Always report with 95% CI |
| 95% CI for Exp(B) | Confidence interval around the OR; CI crossing 1.0 = non-significant | Always report both bounds |
| 2 Log Likelihood | Model fit; lower is better; used for likelihood ratio tests | Report change from null model if doing model comparison |
| Nagelkerke R2 | Pseudo-R2 approximate proportion of variance explained | Always report alongside HL test |
| Hosmer-Lemeshow 2 | Goodness-of-fit test; p > 0.05 = adequate fit | Always report the chi-square value, df, and p-value |
| Classification table | Overall % correctly classified at 0.5 probability threshold | Report as supplementary context; not the primary metric |
| AUC (ROC) | Discrimination how well the model separates events from non-events | Report AUC with 95% CI |
Three Worked Clinical Examples
Predictors of 30-Day Mortality in ICU Patients with Sepsis
Retrospective cohort - N = 487 patients - Events (deaths): 124 (25.5%) - EPV = 124/6 = 20.7 (6 predictors entered)
| Predictor | Crude OR (95% CI) | p | Adjusted OR (95% CI) | p |
|---|---|---|---|---|
| Patient Characteristics | ||||
| Age (per 10 years) | 1.41 (1.221.63) | <0.001 | 1.28 (1.091.49) | 0.002 |
| APACHE II (per 5 points) | 1.87 (1.612.17) | <0.001 | 1.74 (1.482.04) | <0.001 |
| Organ Support & Diagnosis | ||||
| Mechanical ventilation (yes vs no) | 3.42 (2.115.54) | <0.001 | 2.81 (1.704.65) | <0.001 |
| Vasopressor use (yes vs no) | 2.94 (1.874.62) | <0.001 | 2.24 (1.383.64) | 0.001 |
| Septic shock (yes vs no) | 2.11 (1.433.12) | <0.001 | 1.67 (1.092.56) | 0.018 |
| Creatinine > 2.0 mg/dL (yes vs no) | 1.82 (1.192.79) | 0.006 | 1.41 (0.892.23) | 0.143 |
Risk Factors for Type 2 Diabetes in a Community Health Survey
Cross-sectional study - N = 1,240 adults - Events (T2DM): 186 (15.0%) - EPV = 186/5 = 37.2 (5 predictors)
| Predictor | Crude OR (95% CI) | p | Adjusted OR (95% CI) | p |
|---|---|---|---|---|
| BMI 30 kg/m2 (obese vs normal) | 3.81 (2.725.33) | <0.001 | 3.12 (2.184.47) | <0.001 |
| Family history of T2DM (yes vs no) | 2.94 (2.104.11) | <0.001 | 2.71 (1.923.83) | <0.001 |
| Hypertension (yes vs no) | 2.42 (1.743.36) | <0.001 | 1.88 (1.322.68) | <0.001 |
| Physical inactivity (yes vs no) | 1.96 (1.412.72) | <0.001 | 1.62 (1.142.31) | 0.007 |
| Age (per 10 years) | 1.58 (1.381.81) | <0.001 | 1.44 (1.241.67) | <0.001 |
Predictors of Surgical Site Infection (SSI) After Elective Colorectal Surgery
Prospective cohort - N = 614 patients - Events (SSI): 88 (14.3%) - EPV = 88/5 = 17.6 (5 predictors)
| Predictor | Crude OR (95% CI) | p | Adjusted OR (95% CI) | p |
|---|---|---|---|---|
| Type 2 diabetes (yes vs no) | 2.74 (1.724.36) | <0.001 | 2.41 (1.483.93) | <0.001 |
| Operation duration > 180 min (yes vs no) | 2.18 (1.383.44) | 0.001 | 2.03 (1.273.25) | 0.003 |
| Antibiotic given > 60 min pre-incision (yes vs no) | 1.88 (1.182.99) | 0.008 | 1.71 (1.062.76) | 0.028 |
| BMI 35 kg/m2 (yes vs no) | 1.62 (1.012.60) | 0.047 | 1.47 (0.902.41) | 0.124 |
| Open vs laparoscopic approach | 1.54 (0.982.44) | 0.062 | 1.42 (0.882.28) | 0.148 |
Reporting Logistic Regression in a Medical Journal Checklist
Most major medical journals follow STROBE (observational studies) or CONSORT (trials) guidelines, both of which specify what must be reported for regression analyses. Use this checklist before submission:
Common Mistakes in Logistic Regression And How to Fix Them
Mistake 1: Using linear regression for a binary outcome
Applying ordinary least squares linear regression to a 0/1 outcome produces predicted values outside the 01 range, non-normal and heteroscedastic residuals, and invalid standard errors. This was common in older medical literature but is now considered a serious methodological error by reviewers.
Mistake 2: Violating the EPV rule too many predictors for too few events
Including 12 predictor variables in a logistic regression with only 35 outcome events (EPV = 2.9) is the single most common statistical error in submitted medical manuscripts. The model will appear to run without error, the software will produce output, but all the estimates are unreliable inflated ORs, spuriously significant p-values, and results that will not replicate.
Mistake 3: Using stepwise selection and calling it "multivariate logistic regression"
Backward elimination or forward selection methods find the model that fits the sample best not the model that is clinically correct. Variables dropped by stepwise selection may be important confounders. The resulting model overfits to the sample, and the p-values are optimistic because the same data were used to both select and evaluate variables. Despite being flagged repeatedly in the methodological literature, this remains widespread in medical journals.
Mistake 4: Reporting only adjusted ORs, omitting the crude ORs
Showing only the multivariate-adjusted ORs without the crude (univariate) ORs makes it impossible for readers to identify confounding the primary scientific justification for running multivariate analysis. Journals increasingly require both; reviewers will ask for them if missing.
Mistake 5: Treating a continuous predictor as categorical without clinical justification
Arbitrarily categorizing a continuous predictor (e.g., age into tertiles, BMI into quartiles, WBC into "high vs normal") to enter it into logistic regression wastes statistical power, introduces arbitrary cut-points, and can mask non-linear relationships. The practice of categorizing at the median is particularly problematic the median cut-point from the sample is not clinically meaningful and will not replicate in other samples.
Frequently Asked Questions
A chi-square test tests the association between a single categorical predictor and a binary outcome one predictor at a time, no adjustment for other variables. It produces a crude odds ratio (from the 2-2 table) but cannot give you an adjusted OR.
A t-test compares the mean of a continuous predictor between outcome groups again, one variable at a time with no confounding adjustment.
Logistic regression replaces these single-variable tests when you have: multiple predictors you want to include simultaneously; confounders you need to adjust for; or a need to quantify the independent effect of each predictor. The chi-square test and t-test remain appropriate for describing univariate associations in Table 1 of your paper (patient characteristics by outcome group) but the adjusted OR from logistic regression is what determines independent risk factors.
Logistic regression models the probability of a binary (0/1) outcome using the logistic function, which constrains predictions to 01. The output is an odds ratio (OR = e^2). It does not require normally distributed predictors or residuals.
The critical practical difference: using linear regression for a binary outcome is methodologically wrong it can produce predicted probabilities below 0 or above 1, and produces biased standard errors. If your outcome is "yes/no," use logistic regression. If your outcome is a continuous measurement, use linear regression.
The percentage reduction in odds = (1 OR) - 100%:
OR = 0.80 20% lower odds
OR = 0.50 50% lower odds
OR = 0.25 75% lower odds
Example: aOR = 0.42 (95% CI 0.280.63) for antibiotic prophylaxis means that patients who received timely antibiotics had 58% lower odds of SSI compared to patients who did not (1 0.42 = 0.58), after adjusting for all other variables.
If the 95% CI includes 1.0 (e.g., aOR 0.78, 95% CI 0.511.20), the result is not statistically significant you cannot rule out a null effect. Report it as "not significantly associated" rather than "protective."
For studies with very small samples or rare events, standard maximum likelihood logistic regression produces inflated ORs, overfit models, and confidence intervals that are too narrow. Alternatives:
Firth's penalized logistic regression specifically designed for small samples and rare events. Adds a small bias correction to the likelihood to prevent coefficient inflation. Available in R (
logistf package), Stata (firthlogit).LASSO logistic regression penalizes large coefficients, automatically reducing overfitting. Requires cross-validation to select the penalty parameter.
Always state EPV explicitly in your methods section, whether it meets the guideline or not.
It ranges from 0 (model explains nothing beyond the null) to 1 (perfect prediction). In clinical logistic regression, values in the range 0.200.40 typically indicate a reasonable to good model. You should not expect values of 0.700.80 as you might in linear regression binary outcomes have inherent unexplained variability that keeps pseudo-R2 values lower.
Nagelkerke R2 is not the primary model quality indicator. Always pair it with the Hosmer-Lemeshow goodness-of-fit test (is the model calibrated?) and AUC (does the model discriminate?). A model can have a modest Nagelkerke R2 but still have excellent clinical discrimination if AUC is high.
Logistic regression has no normality assumption not for predictors and not for residuals. The five assumptions you should check are: binary outcome, independence of observations, EPV adequacy, absence of multicollinearity, and linearity of continuous predictors with the log-odds (Box-Tidwell test).
Checking normality before logistic regression is wasted effort and sometimes leads to incorrect decisions (e.g., unnecessarily categorizing a skewed continuous predictor before entering it into the model, which loses statistical power).
Multinomial logistic regression: Outcome has 3 or more unordered categories. Each category is compared to a chosen reference category. Output: relative risk ratio for each category vs reference. Example: treatment response classified as complete response, partial response, or no response.
Ordinal logistic regression: Outcome has 3 or more ordered categories with a meaningful rank but unequal intervals. Uses the proportional odds model, which assumes the OR is constant across all possible cut-points of the outcome (this "proportional odds assumption" must be tested using the Brant test or score test). Output: proportional OR. Example: ECOG PS 04, pain severity (mild/moderate/severe), Gleason grade group 15.
Do not collapse an ordinal outcome into binary (e.g., "mild vs moderate-severe") unless you have a strong clinical reason you lose statistical power and clinically meaningful information.
Maximum predictors = Number of outcome events - 10Count only the outcome events not total sample size. If 80 patients experienced the outcome, include at most 8 predictor variables (traditional rule) or 4 variables (conservative rule preferred for high-impact publication).
Note: each level of a categorical variable with k categories counts as k1 predictors. A variable with 4 categories counts as 3 predictors in your EPV calculation.
Exceeding the EPV constraint causes overfitting: the model memorizes the current sample instead of detecting real patterns it will produce spuriously precise ORs that will not replicate in a validation cohort. If you need more predictors than EPV allows: expand sample size, narrow the predictor list based on clinical priority, or use penalized regression (Firth's method or LASSO).
Run Logistic Regression Free Online
StatClinic's logistic regression tool produces crude ORs, adjusted ORs, 95% CIs, Hosmer-Lemeshow test, Nagelkerke R2, AUC, and a publication-ready results table no download, no login, no cost.
Open Logistic Regression Tool