Logistic Regression in Medical Research: How to Build and Interpret a Reliable Model
Learn how to build and interpret reliable logistic regression models in medical research, from predictor handling and adjusted odds ratios to overfitting, internal validation, discrimination, and calibration.
Logistic regression is one of the standard tools for binary outcome analysis in medical research. It can estimate adjusted associations between predictors and a binary outcome, and it can also form the statistical engine of a clinical prediction model.
But fitting a logistic regression model is not the same as building a reliable one. Reliability depends on how predictors are represented, whether nonlinear relationships and interactions are handled appropriately, how model complexity is controlled, and—when prediction is the goal—whether performance is evaluated beyond the data used to develop the model.
Start with the model's purpose. A multivariable logistic regression used to estimate adjusted associations is not evaluated in exactly the same way as a model intended to predict an individual patient's probability of an outcome. Logistic regression can serve both purposes, but the modeling priorities and interpretation differ (Harrell, 2015; Steyerberg, 2019).
1. What Logistic Regression Actually Estimates
Start with a binary outcome
Binary logistic regression applies when the response has two possible outcomes. If Y = 1 denotes the event of interest and
p = P(Y = 1 | X),
the model does not represent p as a simple linear function of the predictors. Instead, it models the log odds, or logit, of the event:
log(p / (1 − p)) = β0 + β1X1 + ⋯ + βkXk.
The odds corresponding to probability p are p / (1 − p). Logistic regression therefore relates predictors linearly to log odds, while the inverse logistic transformation converts the resulting linear predictor into a probability between 0 and 1 (Agresti, 2013; Steyerberg, 2019).
Interpretation boundary: a logistic regression coefficient is not directly a change in probability.
From a coefficient to an odds ratio
For a predictor Xj, the coefficient βj represents a change on the log-odds scale associated with a specified change in that predictor, conditional on the other variables represented in the model. Exponentiating the coefficient gives an odds ratio:
OR = exp(βj).
The odds ratio expresses the multiplicative change in the modeled odds associated with the predictor contrast. Agresti treats the odds ratio as a central association measure for categorical data and develops logistic regression as a framework in which such conditional associations can be modeled with multiple explanatory variables (Agresti, 2013).
An odds ratio should remain an odds interpretation. It is not automatically a risk ratio, a percentage-point change in probability, or evidence of a causal effect.
2. How to Prepare Predictors Before Fitting the Model
Predictor handling is not a preprocessing detail. It defines the mathematical form of the model and can materially affect estimation, interpretation, and prediction.
Keep continuous predictors continuous when possible
A common mistake in medical research is to convert a naturally continuous predictor—age, blood pressure, biomarker concentration, body mass index—into categories simply because categories appear easier to interpret.
Harrell identifies substantial disadvantages of categorizing continuous predictors. Categorization imposes artificial discontinuities and flat relationships within categories, loses information, can reduce predictive accuracy, and can leave residual confounding when a continuous confounder is adjusted for only through categories. Data-derived cutpoints create additional problems because the selected threshold becomes part of the data-dependent modeling process (Harrell, 2015).
Steyerberg likewise warns against dichotomizing continuous predictors in prediction models. Dichotomization creates an abrupt jump in predicted risk at the threshold and assumes constant risk on either side. Smooth continuous relationships are generally more plausible and can be represented without throwing away the original scale of the predictor (Steyerberg, 2019).
Practical rule: do not convert a continuous predictor into “high/low” categories merely to simplify logistic regression.
Continuous does not mean linear
Keeping a predictor continuous does not require assuming that its relationship with the outcome is a straight line on the logit scale.
A simple term such as β1X specifies a linear relationship between X and the log odds of the outcome. If that functional form is inadequate, the model is misspecified.
Flexible transformations can represent nonlinear relationships. Harrell discusses polynomial terms and places particular emphasis on regression splines, including restricted cubic splines, as flexible approaches to modeling smooth predictor–outcome relationships without imposing arbitrary cutpoints (Harrell, 2015).
Steyerberg similarly describes nonlinear functions for continuous predictors, including polynomials, fractional polynomials, and splines, and emphasizes examination of the functional form rather than automatic categorization (Steyerberg, 2019).
The relevant logistic regression assumption is therefore not that a continuous predictor must be linearly related to probability. Rather, entering the predictor as a single untransformed linear term imposes linearity of that predictor's contribution to the logit.
Code categorical predictors deliberately
A categorical predictor with more than two levels generally requires a coding scheme that defines comparisons among its categories. With reference-category indicator coding, one level acts as the reference and coefficients for the other levels express contrasts with that reference.
The reference category is therefore part of the interpretation. Researchers should report it explicitly rather than presenting an odds ratio without stating what comparison generated it (Agresti, 2013).
3. What an Adjusted Odds Ratio Means
In multivariable logistic regression, interpretation is conditional on the model specification.
Suppose the model contains treatment, age, biomarker level, and disease severity. The exponentiated treatment coefficient represents the treatment odds ratio conditional on the other modeled predictors—not the unadjusted odds ratio obtained by simply comparing treated and untreated groups.
Holding the other variables in the model constant, the modeled odds of the outcome were OR times as high for the specified predictor contrast.
For a binary predictor, the contrast is usually one category versus its reference. For a continuous predictor modeled linearly, the odds ratio corresponds to a specified increase—often one unit unless another contrast has been defined.
Why nonlinear terms change interpretation
If a continuous predictor is represented nonlinearly, there is no reason to expect one constant odds ratio to describe its effect across its entire range.
For example, when spline terms represent a predictor, its association is distributed across several model coefficients. Interpretation is better based on the estimated relationship or on contrasts between meaningful predictor values than on trying to interpret individual spline coefficients (Harrell, 2015; Steyerberg, 2019).
An adjusted odds ratio is not automatically causal
The word adjusted means that the coefficient is conditional on variables represented in the fitted model. It does not, by itself, turn an observational association into a causal effect.
The purpose of the analysis should therefore be stated explicitly. If the model is intended to describe adjusted associations, interpretation should remain associational unless the research design and inferential framework justify a stronger claim.
4. Logistic Regression Model Building: Decisions That Matter
Decide whether the objective is explanation or prediction
A reliable logistic regression model building strategy begins by defining the target.
Association or explanation
The primary concern is estimating and interpreting predictor–outcome relationships under a scientifically defensible model specification.
Success is not established by: a high AUC alone.
Prediction
The primary concern is generating useful predictions for future individuals. Predictors need not be causes of the outcome, and predictive performance becomes central.
Success is not established by: statistically significant coefficients alone.
Steyerberg emphasizes that, in a prediction context, predictors need not be causes of the outcome. The objective is prediction of future outcomes, and predictive performance becomes central. Prediction is primarily an estimation problem, whereas studying predictor effects brings greater emphasis to inference, effect estimation, and model assumptions (Steyerberg, 2019).
That distinction changes what constitutes success. For an association-focused model, a high AUC does not validate the scientific interpretation of a coefficient. For a prediction model, statistically significant coefficients do not establish that the model predicts new patients accurately.
Do not let stepwise selection define the science
Automated stepwise procedures are attractive because they appear to convert a long predictor list into a concise model. But selection based on the same data used for estimation introduces model uncertainty and encourages overinterpretation of the selected model.
Harrell describes stepwise variable selection as a widely used and abused modeling technique and emphasizes that inference after data-driven model searching cannot be treated as though the final specification had been fixed in advance (Harrell, 2015).
Steyerberg similarly describes stepwise selection as suboptimal, particularly in small datasets, and emphasizes using subject-matter knowledge when defining candidate predictors rather than relying exclusively on the development dataset to decide what matters (Steyerberg, 2019).
A more defensible strategy is to define the candidate predictor set and functional forms from the research objective, prior knowledge, and available information, while keeping model complexity compatible with the amount of information in the data.
Treat interactions as model specification, not decoration
An interaction means that the modeled association of one predictor depends on another predictor. If an interaction is present, interpreting only the corresponding main-effect coefficient can be misleading because that coefficient is conditional on the value or reference level of the interacting variable.
Interactions also consume model complexity. Harrell treats nonlinearities and interactions as important aspects of model specification and warns that omitted interactions can contribute to misspecification, while unnecessary complexity contributes to overfitting (Harrell, 2015).
Interactions should therefore have a scientific or predictive rationale rather than being generated indiscriminately from every possible predictor pair.
Model complexity has a cost
Adding parameters makes a model more flexible in the development data. Flexibility can capture genuine structure—but it can also capture random peculiarities of the sample.
Overfitting: an overfitted model describes the development sample better than it is likely to describe new observations. Harrell notes that overfitting can produce predictions that are too extreme and associations that do not reproduce. Steyerberg likewise emphasizes that apparent findings and apparent predictive performance can be optimistic when the model adapts too closely to the development data (Harrell, 2015; Steyerberg, 2019).
5. Diagnostics and Validation: How to Decide Whether the Model Is Reliable
The appropriate evaluation depends on the model's purpose.
For model specification, examine more than coefficients and p-values
Agresti separates logistic regression fitting from model building and diagnostics, emphasizing assessment of model adequacy rather than interpreting estimated coefficients in isolation (Agresti, 2013).
Important questions include whether the specified functional forms are adequate, whether interactions that matter have been omitted, whether observations exert unusual influence, and whether the fitted model adequately represents the observed binary-response structure.
For continuous predictors, graphical and flexible modeling approaches are especially useful because a nonsignificant test of a simple linear coefficient does not establish that the predictor has no nonlinear relationship with the outcome.
Prediction models require internal validation
Performance calculated on the same observations used to build the model is apparent performance. It does not quantify how much performance has been inflated by fitting the model to those particular data.
Internal validation addresses this optimism.
Steyerberg describes bootstrap validation as a particularly useful internal-validation strategy. In bootstrap validation, the model-development process is repeated in bootstrap samples and its performance is compared between bootstrap and original observations, allowing estimation of optimism in apparent performance. Importantly, data-dependent model-building procedures should be reproduced during validation when possible; otherwise the optimism associated with those decisions can be missed (Steyerberg, 2019).
Harrell likewise emphasizes bootstrap methods for estimating optimism in model fit while accounting for variation introduced by the modeling strategy, without unnecessarily removing observations from model development solely to create a validation subset (Harrell, 2015).
Internal validation is part of model development, not an optional final check.
Discrimination asks: can the model separate higher- from lower-risk patients?
For a binary prediction model, discrimination concerns how effectively predictions distinguish individuals who experience the outcome from those who do not.
The c-statistic or area under the ROC curve is a commonly used discrimination measure. But discrimination is only one dimension of predictive performance (Harrell, 2015; Steyerberg, 2019). A model can rank patients reasonably well while giving poor absolute risk estimates.
Calibration asks: are the predicted probabilities accurate?
Calibration evaluates agreement between predicted risks and observed outcome frequencies.
Steyerberg distinguishes several levels of calibration and recommends graphical assessment through calibration plots. For binary outcomes, a calibration plot compares predicted probabilities with estimates of observed event probabilities; perfect predictions lie along the identity line. Calibration-in-the-large and the calibration slope provide complementary summaries, while a plot can reveal patterns that summary statistics alone may miss (Steyerberg, 2019).
| Question | Performance concept |
|---|---|
| Does the model assign higher risks to patients who experience the event? | Discrimination |
| Do predicted probabilities correspond to observed event frequencies? | Calibration |
| Is development-sample performance inflated by model fitting? | Internal validation / optimism |
A high AUC should not be used as evidence that predicted probabilities are well calibrated.
6. Mistakes That Make a Logistic Model Unreliable
Several recurring practices can undermine otherwise technically correct logistic regression.
-
Categorizing continuous predictors automatically. Turning continuous measurements into high/low groups discards information and imposes artificial jumps in the modeled relationship. Where nonlinearity is plausible, flexible continuous modeling is generally preferable to arbitrary cutpoints (Harrell, 2015; Steyerberg, 2019).
-
Assuming a linear predictor term is automatically adequate. Entering age or a biomarker as one linear term assumes a specific functional relationship with log odds. Nonlinear relationships should be considered rather than hidden through categorization or ignored (Harrell, 2015; Steyerberg, 2019).
-
Reading an odds ratio as a probability or risk ratio. An odds ratio describes a ratio of odds. It should not be rewritten automatically as a relative probability or percentage-point change in risk (Agresti, 2013).
-
Calling every adjusted odds ratio an “independent predictor.” A coefficient is conditional on the fitted model. Data-dependent selection, collinearity, model misspecification, and sampling variability can all affect which predictors appear important. Steyerberg specifically cautions that claims of having identified “independent predictors” may be exploratory and may fail to reproduce (Steyerberg, 2019).
-
Using stepwise selection and then treating the final model as prespecified. The search process itself creates uncertainty. Standard interpretation of the selected model as though no search occurred understates the consequences of data-dependent modeling (Harrell, 2015).
-
Adding every plausible nonlinear term and interaction. Flexibility is useful only when the available information can support it. Excessive complexity increases the opportunity to fit noise and therefore increases overfitting.
-
Reporting only apparent predictive performance. Performance measured in the development data is optimistic to some degree whenever the model has adapted to those data. Prediction models require internal validation of the entire development strategy (Harrell, 2015; Steyerberg, 2019).
-
Reporting only discrimination. A prediction model can discriminate well yet produce inaccurate absolute probabilities. Calibration must be assessed separately (Harrell, 2015; Steyerberg, 2019).
-
Confusing prediction with explanation. A useful predictor need not be causal. Conversely, a scientifically important association is not validated simply because it improves prediction. Define whether the objective is association estimation, scientific explanation, or prediction before deciding how the logistic model should be built and judged (Steyerberg, 2019).
A Practical Logistic Regression Reliability Checklist
Before accepting a logistic regression analysis, ask:
- Is the outcome genuinely binary, and is the modeled event clearly identified?
- Is the objective association/explanation, prediction, or another explicitly defined target?
- Are categorical predictors coded with interpretable reference categories?
- Have continuous predictors been retained on their continuous scale where appropriate?
- Has the functional form of important continuous predictors been considered rather than assuming linearity automatically?
- Have clinically or scientifically plausible interactions been considered deliberately?
- Is model complexity reasonable relative to the information available?
- Has indiscriminate data-driven stepwise selection been avoided or its consequences acknowledged?
- Are coefficients interpreted on the log-odds scale or, after exponentiation, as odds ratios?
- Are adjusted odds ratios described as conditional on the other modeled variables?
- Are odds ratios kept distinct from risk ratios, probability differences, and causal effects?
- If prediction is the goal, has the complete model-building process undergone internal validation?
- Are discrimination and calibration both reported for a prediction model?
- Are conclusions limited to what the model purpose, design, and validation actually support?
Bottom Line
Reliable logistic regression in medical research requires more than obtaining coefficients, odds ratios, and p-values.
Begin with the scientific purpose. Define the binary event clearly. Preserve the information in continuous predictors rather than automatically categorizing them. Allow nonlinear relationships when the data and subject matter justify them. Treat interactions as substantive model components. Avoid allowing automated variable selection to substitute for a modeling strategy.
Then interpret the fitted model according to its purpose. In an association-focused multivariable logistic regression, an adjusted odds ratio describes a conditional association on the odds scale; it is not automatically a causal effect. In a prediction model, coefficient significance is not enough: overfitting must be addressed through internal validation, and predictive performance requires assessment of both discrimination and calibration (Agresti, 2013; Harrell, 2015; Steyerberg, 2019).
The central principle: the logistic equation may be easy to fit, but reliability comes from the modeling decisions surrounding it.
FAQs
What does logistic regression estimate?
For a binary outcome, logistic regression models the log odds of the event as a function of the predictors. The fitted linear predictor can then be transformed into an estimated probability (Agresti, 2013; Steyerberg, 2019).
How do I interpret an odds ratio from multivariable logistic regression?
Exponentiating a logistic regression coefficient produces an odds ratio for the specified predictor contrast, conditional on the other variables represented in the model. An odds ratio should not automatically be interpreted as a risk ratio or probability difference (Agresti, 2013).
What are the main logistic regression assumptions for continuous predictors?
When a continuous predictor is entered as a simple linear term, its contribution is assumed to be linear on the logit scale. Researchers should consider whether nonlinear functions are needed rather than automatically categorizing the predictor (Harrell, 2015; Steyerberg, 2019).
Should continuous variables be categorized before logistic regression?
Not routinely. Categorization can discard information, create artificial discontinuities, reduce predictive accuracy, and impose implausible assumptions about the predictor–outcome relationship. Flexible continuous functions such as regression splines can represent nonlinear effects without arbitrary cutpoints (Harrell, 2015; Steyerberg, 2019).
Should I use stepwise selection for logistic regression model building?
Stepwise selection should not be treated as a default modeling strategy. Data-driven selection introduces model uncertainty, can encourage overinterpretation, and is particularly problematic when information is limited. Candidate predictors and model structure should be guided by the research objective and subject-matter knowledge, with data-dependent modeling incorporated into validation when prediction is the goal (Harrell, 2015; Steyerberg, 2019).
How should a logistic regression prediction model be validated?
Apparent performance in the development sample is insufficient. Internal validation should estimate optimism arising from model development. Bootstrap validation is a useful approach because it can repeat the development process and estimate optimism without permanently withholding a portion of the available sample (Harrell, 2015; Steyerberg, 2019).
Is AUC enough to evaluate a logistic regression prediction model?
No. AUC or the c-statistic assesses discrimination, whereas calibration assesses whether predicted probabilities correspond to observed outcome frequencies. Prediction models should therefore be evaluated on both dimensions rather than judged from discrimination alone (Harrell, 2015; Steyerberg, 2019).
Does an adjusted odds ratio prove that a predictor causes the outcome?
No. Adjustment means that the estimated association is conditional on variables included in the model. A logistic regression coefficient does not by itself establish a causal effect.
References
Agresti, A. (2013). Categorical data analysis (3rd ed.). Wiley.
Harrell, F. E., Jr. (2015). Regression modeling strategies: With applications to linear models, logistic and ordinal regression, and survival analysis (2nd ed.). Springer. https://doi.org/10.1007/978-3-319-19425-7
Steyerberg, E. W. (2019). Clinical prediction models: A practical approach to development, validation, and updating (2nd ed.). Springer. https://doi.org/10.1007/978-3-030-16399-0
Need help with a similar research question?
Share a short, non-confidential summary of your study and the decision you need to make.