Linear regression
Estimates how a continuous outcome changes with one or more factors, holding the others fixed.
Statistically reviewed by Daniel Wolff on 4 November 2026.
Clinical example
Does systolic blood pressure differ between smokers and non-smokers once age and BMI are taken into account, and how much does it change per year of age?
When to use it
- The outcome is a continuous measurement, one per patient.
- You need to adjust for other variables, or relate the outcome to a continuous factor such as age or dose.
- Your main factor has two or more groups (for example never, former and current smoker) and you need to adjust.
- For a yes/no outcome see logistic regression, for time to an event see Cox regression.
Assumptions to check
Linearity
The outcome changes in a straight line with each continuous factor. Plot the residuals against the fitted values and against each continuous factor. If the relation is curved, consider splines or a transformation.
Independent observations
Residual plots cannot check this. It follows from the design: one measurement per patient and no clustering. Repeated measurements or patients in clusters give confidence intervals that are too narrow, and a larger sample does not fix that.
Constant spread of the residuals
Check that the residuals do not fan out in the plot against the fitted values. Unequal spread gives wrong standard errors at any sample size. Consider a transformation of the outcome or robust (sandwich) standard errors.
No undue influence from outliers
Look at extreme or influential observations (for example with Cook's distance) and check whether the conclusion changes without them.
Enough patients for the model
Too many factors for the sample size gives unstable estimates. A common rule of thumb is about 10 to 20 patients per estimated coefficient (see Harrell, Regression Modeling Strategies).
Check first
- Residuals: normal, constant variance
- No strong collinearity between predictors
What to report
- The difference (or coefficient) for your main factor with 95% CI
- The variables you adjusted for, and why
- The exact p-value, alongside the estimate and its CI
- The unit of each coefficient (for example per year of age)
- The number of patients in the model, and how many were left out because of missing data
- How you checked the assumptions
Common mistakes
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.
Report the effect, not just the p-value
Give the estimate (difference, ratio) with its 95% confidence interval and the exact p-value.
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).
Don't test baseline differences in an RCT
With randomization, any baseline difference is chance by definition. Choose adjustment variables in advance, based on how strongly they predict the outcome.
Reading coefficients as causal effects without a causal argument, or adjusting for mediators or colliders.
Entering a categorical variable coded 0, 1, 2 as a number, which fits a linear trend instead of separate groups.
Predicting outside the range of the data, or judging the model by R-squared alone.
Not noticing that incomplete cases are dropped silently, so the model holds fewer patients than the cohort.
Alternatives
| If your situation is… | Use |
|---|---|
| Baseline value of the outcome measured too | ANCOVA (adjusting for baseline) |
| Repeated measurements or clustered patients | Linear mixed model |
| Yes/no outcome | Logistic regression |
| Time to an event | Cox proportional hazards regression |
| Only two or more groups, no adjustment needed | Welch's t-test |
In your software
# R
# If smoker is coded 0/1/2, use factor(smoker) so it is not treated as a number.
fit <- lm(sbp ~ smoker + age + bmi, data = cohort)
summary(fit) # the smoker row is the adjusted difference in mean sbp; age is the change per year
confint(fit)
plot(fit) # residual plots for the assumptions
REGRESSION
/STATISTICS COEFF OUTS CI(95) R ANOVA
/SCATTERPLOT=(*ZRESID ,*ZPRED)
/RESIDUALS HISTOGRAM(ZRESID)
/DEPENDENT sbp
/METHOD=ENTER smoker age bmi.