Chapter 8 · Regression models
How do several factors together predict an outcome?
Coefficients, R², adjusted R², multiple and partial correlation, dummy variables and residual checks.
Read first: Correlation and regression
The problem first
You are an MD Medicine resident. In 120 patients with type 2 diabetes, HbA1c rises with age (r = 0.41, p < 0.001), and your results chapter says that older patients have poorer glycaemic control.
Your guide points out that the older patients have also had diabetes for longer: age and duration of diabetes correlate at r = 0.79. She asks one question.
“What is the effect of age in patients who have had diabetes for the same number of years?”
Start here
What does "holding the other predictors constant" mean?
Multiple linear regression gives each predictor its own coefficient. Each coefficient is the difference in the outcome for a 1-unit difference in that predictor, among patients who have the same values of every other predictor in the model.
The right-hand panel shows how the model works. The coefficient for age is estimated only from the variation in age that the other predictors do not explain. Two patients of different ages who have had diabetes for the same time are what inform the age coefficient.
y = b₀ + b₁x₁ + b₂x₂ + … + bₖxₖ
HbA1c = 7.208 + 0.004 × age + 0.080 × duration
- y
- the outcome (dependent variable), here HbA1c in %
- x₁ … xₖ
- the k predictors (independent variables)
- b₀
- the intercept: predicted outcome when every predictor is 0, often a value outside the data (age 0)
- b₁ … bₖ
- the partial regression coefficients: each one is adjusted for the other predictors in the model
In this model, age has B = 0.004 (95% CI −0.019 to 0.027, p = 0.73) and duration has B = 0.080 (0.035 to 0.125, p < 0.001). The coefficient is adjusted only for the predictors in the model, as they were measured. A confounder that was not measured is not adjusted for.
Interactive
Add or remove predictors and watch the coefficients, R² and adjusted R² change
Try this: start with age alone, then tick Duration of diabetes. Watch the coefficient for age fall from 0.036 to 0.004. Then add BMI and physical activity and compare R² with adjusted R².
Teaching example, made-up data: HbA1c (%) in 120 adults with type 2 diabetes. Outcome: HbA1c. Least squares fitted in your browser.
| Predictor | B | 95% CI | SE | t | p | β |
|---|---|---|---|---|---|---|
| Intercept (constant) | 6.142 | 5.296 to 6.987 | 0.427 | 14.38 | < 0.001 | |
| Age (years) | 0.036 | 0.022 to 0.051 | 0.007 | 4.93 | < 0.001 | 0.41 |
Age: +0.036 percentage points of HbA1c per year of age (p < 0.001).
1 predictor column, n = 120. R² − adjusted R² = 0.007. Each B is in HbA1c percentage points: per year of age. β is the standardised coefficient.
Goodness of fit
How much of the variation does the model explain?
The total variation in the outcome is split into the part the model explains and the part left over. R² is the explained share.
SST = Σ(y − ȳ)² SSR = Σ(ŷ − ȳ)² SSE = Σ(y − ŷ)² SST = SSR + SSE
R² = SSR ÷ SST = 1 − SSE ÷ SST R = √R²
adjusted R² = 1 − (1 − R²) × (n − 1) ÷ (n − k − 1)
- ŷ
- the value the model predicts for each patient
- SSR
- regression (explained) sum of squares
- SSE
- residual (error) sum of squares: what the model leaves unexplained
- R
- multiple correlation coefficient: the correlation between the observed and the predicted outcome. With one predictor it equals the size of Pearson r
- n, k
- number of patients, number of predictor terms (not counting the intercept)
Why R² always rises. Adding a predictor can never make the least squares fit worse, because the new coefficient could be set to 0 and the fit would be the same as before. So R² goes up, or stays level, even for a column of random numbers. Adjusted R² goes up only when the added predictor's t statistic is larger than 1 in absolute value, and it can be negative.
Multiple R for the full teaching model is √0.513 = 0.716: the observed HbA1c values correlate at 0.716 with the values the model predicts.
Interactive
Add useless predictors and watch R² rise while adjusted R² does not
Try this: press "Add a useless predictor" ten times. R² climbs with every predictor. Adjusted R² does not.
Teaching example: HbA1c in the first 30 patients of the chapter's made-up data, predicted from duration of diabetes and being sedentary. Each useless predictor is a column of random numbers with no relation to HbA1c.
30 patients, 2 predictors, 27 residual degrees of freedom
With duration and sedentary only, R² is 0.405 and adjusted R² is 0.361.
Tests
What do the F test and the t tests each test?
The F test asks whether the predictors together explain more than chance would. Each t test asks whether one coefficient differs from 0 when the other predictors are held constant.
| Source | Sum of squares | df | Mean square | F | p |
|---|---|---|---|---|---|
| Regression | 66.81 | 5 | 13.36 | 24.05 | < 0.001 |
| Residual | 63.33 | 114 | 0.556 | ||
| Total | 130.15 | 119 |
F = (SSR ÷ k) ÷ [SSE ÷ (n − k − 1)], with k and n − k − 1 degrees of freedom
t = B ÷ SE(B), with n − k − 1 degrees of freedom 95% CI = B ± t₀.₉₇₅ × SE(B)
- Overall F: tests whether all slope coefficients are 0 at once. Here F(5, 114) = 24.05, p < 0.001. A significant F says the model explains something, not that every predictor matters.
- t for each coefficient: duration t = 5.11, p < 0.001. Age t = 0.01, p = 0.99: once duration, BMI and activity are known, age adds nothing.
- F for a block of terms: compares two nested models, the full model and the model without the block. Physical activity (two 0/1 variables) gave F(2, 114) = 12.99, p < 0.001, and added 0.111 to R².
- The intercept's p value tests whether the predicted outcome is 0 when every predictor is 0. For HbA1c at age 0 this has no clinical meaning.
A significant overall F with no significant t test is a sign that two or more predictors overlap. That is covered in the multicollinearity chapter.
Partial correlation
How strongly is one predictor related to the outcome once the others are allowed for?
Partial correlation removes the effect of the other predictors from both the outcome and the predictor. Semi-partial (part) correlation removes it from the predictor only.
partial r = t ÷ √(t² + df) semi-partial r² = t² × (1 − R²) ÷ df
For duration in the full model, t = 5.11 and df = 114: partial r = 0.43 and semi-partial r = 0.33 (semi-partial r² = 0.111). For BMI, partial r = 0.39 and semi-partial r = 0.29. The partial correlation is always at least as large as the semi-partial one, because it divides by a smaller amount of variation.
Standardised coefficients
Can you compare coefficients measured in different units?
B is in outcome units per unit of the predictor. The standardised coefficient β is in standard deviations of the outcome per standard deviation of the predictor.
β = B × SD(x) ÷ SD(y)
Duration: β = 0.0959 × 6.075 ÷ 1.046 = 0.56. BMI: β = 0.31. Sedentary: β = 0.37. A patient whose duration is 1 SD (6.1 years) longer has HbA1c about 0.56 SD (0.58 percentage points) higher, holding the other predictors constant.
- β depends on the SDs in your sample. The same biology gives a different β in a sample with a narrower range of duration.
- For a 0/1 predictor, a change of 1 SD has no clinical meaning. Report B for categories.
- Report B with its units and 95% CI as the main result. β can be added, but a table of β alone cannot be read in clinical units.
Categorical predictors
How do you put a predictor with several categories into the model?
A predictor with k categories becomes k − 1 indicator (dummy) variables, each coded 0 or 1. The category with no variable of its own is the reference category.
| Physical activity | moderate | sedentary | Patients |
|---|---|---|---|
| Active (reference) | 0 | 0 | 56 |
| Moderately active | 1 | 0 | 38 |
| Sedentary | 0 | 1 | 26 |
- Why k − 1: a variable for every category would add up to 1 for every patient, the same as the intercept column, and the coefficients could not be estimated.
- Choosing the reference: a clinically natural comparison group with enough patients. A reference category with very few patients gives wide intervals for every comparison.
- Testing the predictor: use one F test for the whole set of dummies. A single non-significant dummy does not mean that category can be merged or dropped.
- Never enter codes 1, 2, 3 as one number for unordered categories. That forces the same step between each pair of categories.
Interaction terms
What if the effect of one predictor depends on another?
An interaction term is the product of two predictors. Its coefficient is how much the slope of one predictor changes for a 1-unit change in the other.
HbA1c = b₀ + … + b₁ × (BMI − 27) + b₂ × sedentary + b₃ × (BMI − 27) × sedentary
- Main effects change meaning. With the interaction in the model, the sedentary coefficient (0.85) is the difference at BMI 27, and the BMI coefficient is the slope in patients who are not sedentary.
- Centre the continuous predictor (subtract a sensible value such as 27) so that the main effects describe a realistic patient. Without centring, the sedentary coefficient is the difference at BMI 0: −2.16 in the same data.
- Test the interaction term itself. A significant effect in one group and not in the other does not show that the effects differ.
- Plan interactions before the analysis. Testing every possible product term produces chance findings.
Assumptions
How do you check that the model is suitable for the data?
The assumptions are about the residuals, the differences between the observed and the predicted outcome. Plot them before you read the p values.
- Linearity: the outcome changes in a straight line with each continuous predictor, holding the others constant. Check: residuals against fitted values and against each predictor show no curve.
- Independence: one row per patient, with no repeated measurements or clusters analysed as if independent.
- Constant variance: the spread of the residuals is similar at all fitted values. Check: no funnel shape.
- Normal residuals: needed for accurate p values and confidence intervals, most of all in small samples. Check: a histogram or normal Q-Q plot of the residuals. The raw outcome does not need to be normal.
- No single patient controls the result: check outliers and influential points (for example Cook's distance), and the case records behind them.
- Predictors that do not overlap too much: check variance inflation factors (multicollinearity chapter).
Interactive
Change how the data were generated and watch the residual plot
Try this: choose "Curved relation with age" and look at the red line of average residuals. Then choose "Spread widens with age" and look at the dashed band.
Teaching example, made-up data: systolic BP in 60 adults, fitted on age and BMI with a straight-line model every time. Only the way the data were generated changes.
The residuals form an even band around 0 with no pattern. The straight-line model suits these data.
dots: patients red line: average residual in each sixth of the fitted values dashed: ± 2 SD of the residuals in each sixth
Decide
How should each predictor enter the model?
Answer the questions for each predictor before you run the analysis.
What kind of predictor is it?
How a predictor enters: all possible answers
- Enter it as it is: B is the change in the outcome per 1 unit of the predictor, holding the other predictors constant. Keep it continuous: cutting it into groups throws information away.
- Model the curve: Add a squared term, transform the predictor (for example its logarithm), or use a spline with a statistician. Decide the form from clinical knowledge and the plot, not by trying many forms and keeping the smallest p value.
- One 0/1 variable: Code the reference group 0 and the other group 1. B is the difference in the outcome between the groups, holding the other predictors constant.
- k − 1 indicator (dummy) variables: A predictor with k categories needs k − 1 variables of 0 and 1. The category left out is the reference. Test the whole predictor with one F test for the set of variables.
- Dummies, or one score: state which: k − 1 dummy variables assume nothing about the spacing of the grades. A single score (1, 2, 3, 4) assumes each step changes the outcome by the same amount. Choose before the analysis and say which you used.
- An interaction term: Add the product of the two predictors and test that one term. Do not fit separate models in each group and compare their p values.
Comparison
Three pairs that residents confuse
| Feature | R² | Adjusted R² |
|---|---|---|
| Measures | Share of the outcome variation explained in this sample | The same, with a penalty for each predictor term |
| When a predictor is added | Never falls | Falls if the new term has |t| below 1 |
| Range | 0 to 1 | Can be below 0 |
| Use | Describe how much the model explains | Compare models with different numbers of predictors |
| Teaching data, full model | 0.513 | 0.492 |
| Feature | Partial correlation | Semi-partial (part) correlation |
|---|---|---|
| Other predictors removed from | Both the outcome and the predictor | The predictor only |
| Squared, it is | Unique variation ÷ variation the others leave unexplained | Unique variation ÷ all the outcome variation |
| Link to R² | No direct link | Equals the fall in R² when the predictor is removed |
| Duration in the teaching model | r = 0.43 | r = 0.33 (r² = 0.111) |
| Feature | Unstandardised B | Standardised β |
|---|---|---|
| Units | Outcome units per unit of the predictor | SDs of the outcome per SD of the predictor |
| Clinical reading | Direct: +0.096% HbA1c per year of diabetes | Indirect: needs the SDs to convert back |
| Depends on the sample SD | No | Yes |
| Categorical predictors | Difference from the reference category | Hard to interpret |
| Report | Always, with the 95% CI | Optional, alongside B |
Reading a paper
How do you read a regression table in a paper?
Read the table from the rows to the footer: what each row compares, its size in units, its precision, and the model it came from.
| Predictor | B | SE | 95% CI | t | p | β |
|---|---|---|---|---|---|---|
| Intercept | 4.777 | 0.652 | 3.486 to 6.068 | 7.33 | < 0.001 | |
| Age (years) | 0.000 | 0.009 | −0.019 to 0.019 | 0.01 | 0.99 | 0.00 |
| Duration of diabetes (years) | 0.096 | 0.019 | 0.059 to 0.133 | 5.11 | < 0.001 | 0.56 |
| BMI (kg/m²) | 0.084 | 0.019 | 0.047 to 0.120 | 4.50 | < 0.001 | 0.31 |
| Moderately active (vs active) | 0.240 | 0.157 | −0.072 to 0.552 | 1.52 | 0.13 | 0.11 |
| Sedentary (vs active) | 0.932 | 0.183 | 0.570 to 1.294 | 5.09 | < 0.001 | 0.37 |
n = 120 · R² = 0.513 · adjusted R² = 0.492 · F(5, 114) = 24.05, p < 0.001 · outcome HbA1c (%) · teaching data
- Outcome and units: find them in the title or footer. Here every B is in percentage points of HbA1c.
- Each row: a continuous predictor is per unit (per year, per kg/m²). A category row names its reference (“vs active”). If the reference is not stated, the row cannot be read.
- Size before significance: sedentary patients have HbA1c 0.93 percentage points higher than active patients with the same age, duration and BMI.
- Precision: the 95% CI for sedentary runs from 0.57 to 1.29. The CI for age includes 0 and is narrow, so a clinically important age effect at the same duration is unlikely in these data.
- Adjustment set: every coefficient is adjusted for the other rows, and only those. Check whether an obvious confounder is missing, and whether a variable on the causal path was included.
- The footer: n, R², adjusted R² and the F test. Divide n by the number of predictor terms (here 120 ÷ 5 = 24).
- What is missing: unadjusted estimates, how predictors were chosen, residual checks and variance inflation factors.
The formula
Worked example: the full HbA1c model
Teaching data, made up: 120 adults with type 2 diabetes. HbA1c on age, duration of diabetes, BMI and physical activity (reference: active). Every number was computed with statsmodels OLS in Python.
- Sums of squares from the software: SST = 130.15, SSR = 66.81, SSE = 63.33. n = 120, k = 5, residual df = 120 − 5 − 1 = 114.
- R² = 66.81 ÷ 130.15 = 0.513. Multiple R = √0.513 = 0.716.
- Adjusted R² = 1 − (1 − 0.513) × 119 ÷ 114 = 0.492.
- F = (66.81 ÷ 5) ÷ (63.33 ÷ 114) = 13.36 ÷ 0.556 = 24.05, with 5 and 114 df, p < 0.001.
- Duration: B = 0.0959, SE = 0.0188, t = 5.11 (from the unrounded values), df 114, p < 0.001.
- 95% CI = 0.0959 ± 1.981 × 0.0188 = 0.059 to 0.133 percentage points per year.
- Standardised β = 0.0959 × 6.075 ÷ 1.046 = 0.56 (SD of duration 6.075 years, SD of HbA1c 1.046%).
- Partial r = 5.11 ÷ √(5.11² + 114) = 0.43. Semi-partial r² = 5.11² × (1 − 0.513) ÷ 114 = 0.111, the fall in R² if duration is removed.
- Prediction for a 60-year-old with diabetes for 10 years, BMI 30, sedentary: 4.777 + 0.0001 × 60 + 0.0959 × 10 + 0.0836 × 30 + 0.932 = 9.18%. 95% CI for the mean of such patients 8.89 to 9.48. 95% prediction interval for one such patient 7.68 to 10.69.
import statsmodels.formula.api as smf
# d has one row per patient. moderate and sedentary are 0/1 columns (reference: active)
fit = smf.ols("hba1c ~ age + duration + bmi + moderate + sedentary", data=d).fit()
print(fit.summary()) # B, SE, t, p, 95% CI, R-squared, F
print(fit.rsquared, fit.rsquared_adj) # 0.513, 0.492In a real paper
Multiple linear regression in published studies
Jaspert FM, Harling G, Sie A, Bountogo M, Bärnighausen T, Ditzen B, et al. Association of relationship satisfaction with blood pressure: a cross-sectional study of older adults in rural Burkina Faso. BMJ Open. 2024;14(11):e089374.
doi:10.1136/bmjopen-2024-089374 · PMID 39532359 · Free full text (PMC12185928)
The study: A cross-sectional household survey of 2114 partnered adults aged over 40 in rural Burkina Faso. Systolic BP is a measurement, and the authors wanted its relation to a relationship-satisfaction score (Couples Satisfaction Index-4) with age, gender, socioeconomic and health variables held constant, so they fitted multiple linear regression models: model 1 with demographic and socioeconomic variables, model 2 with health variables added.
“Relationship satisfaction was significantly and positively (B=0.23; 95% CI (0.02 to 0.45); p=0.03) associated with SBP in model 1 which controlled for demographic and socioeconomic variables, indicating that individuals who were more satisfied in their relationship had slightly higher SBP values.”
B = 0.23: each 1-point higher satisfaction score went with systolic BP 0.23 mmHg higher, among people with the same values of the model 1 covariates. The 95% CI 0.02 to 0.45 does not include 0, so p = 0.03. “Controlled for” means these variables were in the model, not that confounding was removed. When health variables were added (model 2), B became 0.21 with a CI crossing 0.
| Reported | Value | What it means |
|---|---|---|
| Model 1, satisfaction score | B=0.23; 95% CI (0.02 to 0.45); p=0.03 | mmHg of SBP per point of the score, adjusted for model 1 variables |
| Model 2, satisfaction score | B=0.21; 95% CI (−0.01 to 0.42); p=0.06 | Almost the same estimate. The CI now includes 0 |
| Adjusted R² | 0.06 for model 1 and 0.08 for model 2 | The predictors together explain about 6% to 8% of the variation in SBP |
| Age, model 1 | 0.42 (0.34; 0.50) | mmHg per year of age, holding the other variables constant |
| Female (vs male), model 1 | −2.83 (−4.41; −1.26) | A 0/1 predictor with men as the reference category |
| Satisfaction × gender interaction, SBP | B=0.03; 95% CI (−0.08 to 0.47); p=0.88 | No evidence that the association differs by gender |
- The methods say the absence of multicollinearity and the normal distribution of the residuals were checked, but the results do not show VIFs or residual plots. Look for them before accepting that claim.
- The interaction estimate B = 0.03 does not sit near the middle of its interval (−0.08 to 0.47). In a linear model the 95% CI is roughly B ± 2 SE, so one of these numbers is probably misprinted.
- With an adjusted R² of 0.06 to 0.08, most of the variation in SBP is explained by factors outside the model. A p value of 0.03 in 2114 people describes a small difference.
- 101 participants who had taken BP medication in the previous 2 weeks were excluded. Consider how this changes the population the results apply to.
Lasserson DS, Scherpbier de Haan N, de Grauw W, van der Wel M, Wetzels JF, O'Callaghan CA. What is the relationship between renal function and visit-to-visit blood pressure variability in primary care? Retrospective cohort study from routinely collected healthcare data. BMJ Open. 2016;6(6):e010702.
doi:10.1136/bmjopen-2015-010702 · PMID 27288374 · Free full text (PMC4908894)
The study: A retrospective cohort of 19 175 primary care patients in Nijmegen, the Netherlands. The outcome was variability of systolic BP across 7 visits, and the question was whether lower eGFR goes with more variability once age, sex, mean BP, diabetes, cardiovascular disease and drugs are allowed for. The authors used stepwise multiple linear regression and reported standardised coefficients.
“Lower eGFR was consistently associated with increasing measures of BP variability (both with and without transformation to be independent of mean BP), as evidenced by the significant negative standardised β coefficients across the regressions in the presence of potential confounders.”
Every model gave a negative standardised β for eGFR: a patient with eGFR 1 SD higher had BP variability a fraction of an SD lower, holding the other variables constant. Standardised β has no units, so the table cannot be read as mmHg per mL/min/1.73 m². “Significant” in a sample of 19 175 says little about size.
| Reported | Value | What it means |
|---|---|---|
| Method | multiple stepwise linear regression | The software chose which covariates stayed in each model |
| eGFR on SD of systolic BP | −0.04*** | Standardised β. Asterisks mark the p value, and no CI is given |
| eGFR on SD independent of mean | −0.05*** | The same for a variability measure corrected for mean BP |
| Patients | 19 175 | A very large sample, so small standardised coefficients reach significance |
- Coefficients are shown only if a variable was included by the stepwise procedure, so a blank cell means the variable was dropped, not that it was unimportant.
- Only standardised coefficients appear in the main table. The non-standardised coefficients for categorical variables are in an online supplement.
- No confidence intervals and no R² are given for the models. SAMPL asks for both.
- Stepwise selection makes the p values of the final model too small. See the multicollinearity chapter.
How to run it
Running multiple linear regression in SPSS, R and jamovi
Each package fits the same model. Enter categorical predictors as indicator variables or as factors, and ask for confidence intervals and residual plots.
IBM SPSS Statistics
- Analyze > Regression > Linear... Select the numeric dependent variable and one or more numeric independent variables. Independent variables can be grouped into blocks, each with its own entry method.
- Leave Method as Enter, which enters all variables in a block in a single step.
- The independent variables must be numeric, so enter physical activity as two 0/1 variables you have created, leaving out the reference category.
- Statistics: Estimates gives B, its standard error, the standardized coefficient beta, t and the two-tailed significance. Also tick Confidence intervals, Model fit (multiple R, R², adjusted R², standard error of the estimate and the ANOVA table), R squared change for blocks, and the part and partial correlations.
- Plots: put *ZRESID on the Y axis and *ZPRED on the X axis to check linearity and equal variance. Tick the histogram and the normal probability plot of the standardized residuals. “Produce all partial plots” shows each predictor after the others are removed.
- Partial correlation on its own: Analyze > Correlate > Partial..., with the other predictors as control variables.
R
d$activity <- relevel(factor(d$activity), ref = "active") # choose the reference category
fit <- lm(hba1c ~ age + duration + bmi + activity, data = d) # treatment contrasts: k - 1 dummies against the reference
summary(fit) # B, SE, t, p, R-squared, adjusted R-squared, F statistic
confint(fit) # 95% confidence intervals
fit_no_act <- lm(hba1c ~ age + duration + bmi, data = d)
anova(fit_no_act, fit) # F test for the activity block (nested models)
d$bmi_c <- d$bmi - 27
fit_int <- lm(hba1c ~ age + duration + moderate + bmi_c * sedentary, data = d) # 0/1 columns, and a*b = a + b + a:b
plot(fit) # residuals vs fitted, Q-Q, scale-location, residuals vs leverage
lm.beta::lm.beta(fit) # standardised coefficients (package lm.beta)
ppcor::pcor(d[, c("hba1c", "age", "duration", "bmi")]) # partial correlations (package ppcor)
ppcor::spcor(d[, c("hba1c", "age", "duration", "bmi")]) # semi-partial correlationsjamovi
- Analyses → Regression → Linear Regression.
- Move HbA1c to Dependent Variable, continuous predictors to Covariates, and categorical predictors to Factors. The reference level of each factor can be set (the refLevels option of linReg in the jmv R package).
- Model Fit: tick R, R² and Adjusted R². Model Coefficients: tick ANOVA test, Confidence interval and Standardized estimate.
- Assumption Checks: tick Q-Q plot of residuals, Residuals plots and Cook's distance.
- To compare nested models, use Model Builder and add a second block with “+ Add New Block”.
- Partial and semi-partial correlations are in the Partial Correlation analysis (corrPart in the jmv R package, with type partial or semipartial).
How to report it
What to write in the methods and results
Report the model so that a reader could fit it again: the outcome, every predictor and how it was coded, how predictors were chosen, the checks, and each coefficient with its units and 95% CI.
- Methods: the outcome, each predictor with its units or categories and reference category, and why each was included. Any interaction or transformation planned. How assumptions and collinearity were checked, how missing data were handled, and the software and version.
- Results: n in the model, and for each predictor B, 95% CI and p, preferably in a table. The unadjusted estimate for the main exposure. R² or adjusted R², and any interaction tested, with its estimate.
Multiple linear regression was used to relate HbA1c to age, duration of diabetes, BMI and physical activity (reference category: active), chosen before analysis. Residuals were checked with a plot against fitted values and a normal Q-Q plot, and no variance inflation factor exceeded 3. Duration was associated with higher HbA1c (B = 0.096 percentage points per year, 95% CI 0.059 to 0.133, p < 0.001), as were BMI (B = 0.084 per kg/m², 0.047 to 0.120, p < 0.001) and being sedentary (B = 0.93, 0.57 to 1.29, p < 0.001). Age was not associated with HbA1c after adjustment (B = 0.000, −0.019 to 0.019, p = 0.99), although the unadjusted coefficient was 0.036 per year (0.022 to 0.051). The model explained 51% of the variation in HbA1c (R² = 0.513, adjusted R² = 0.492, F(5, 114) = 24.05, p < 0.001). A BMI × sedentary interaction was tested (B = 0.111, 0.035 to 0.188, p = 0.005): HbA1c rose 0.048 percentage points per kg/m² in patients who were not sedentary and 0.159 in sedentary patients.
If you enter the residual checks, state what they showed, not only that they were done. The guidance these items come from is in the Guidelines section below.
By specialty
Multiple regression problems by specialty
HbA1c is higher in older patients with type 2 diabetes, but the older patients have also had diabetes for longer.
Put age and duration in one model. The age coefficient then compares patients with the same duration of diabetes.
Length of stay after open hernia repair is predicted from age, ASA grade and operating time. A few patients stay for weeks.
Look at the residual plot before trusting the p values. A long right tail often needs the log of length of stay as the outcome.
Pain score at 24 hours is compared between three nerve block techniques, adjusted for age and duration of surgery.
Block technique has three categories: enter two 0/1 variables with the standard technique as the reference, and test the pair with one F test.
Serum bilirubin on day 3 is predicted from gestational age, birth weight and feeding type in 180 neonates.
Gestational age and birth weight rise together. Each coefficient holds the other constant, so read both with their confidence intervals and check the variance inflation factors.
A resident wants to know whether the rise in systolic BP with BMI during pregnancy is steeper in primigravidae.
That question is an interaction. Add BMI × primigravida and test that term, rather than fitting separate models and comparing their p values.
HAM-D score at 8 weeks is compared between two antidepressants, and the groups differ at baseline.
Include the baseline HAM-D score as a predictor. The drug coefficient is then the difference at 8 weeks between patients with the same baseline score.
Haemoglobin in adolescent girls is related to dietary iron, BMI and socioeconomic class on a five-point scale.
Five classes need four 0/1 variables. Entering the class as one number from 1 to 5 assumes equal steps between classes.
Bone mineral density in 150 postmenopausal women is related to age, BMI and years since menopause.
Age and years since menopause overlap. Report both adjusted coefficients with confidence intervals, and give the unadjusted ones as well.
Common myths
Common mistaken beliefs
Myth: The coefficient for age is the effect of age.
It is the difference in the outcome per year of age among patients with the same values of the other predictors in the model. In the teaching data it was 0.036 alone and 0.000 with duration, BMI and activity in the model.
Myth: A higher R² means a better model.
R² never falls when a predictor is added, even a column of random numbers. Compare models with adjusted R², and judge them by their purpose and their residual plots.
Myth: If one category of a factor is not significant, merge or drop it.
Each dummy coefficient compares one category with the reference. Test the factor as a whole: activity gave F(2, 114) = 12.99, p < 0.001, although moderate activity alone had p = 0.13.
Myth: The predictor with the largest coefficient matters most.
B depends on units. HbA1c changes 0.096 per year of diabetes and 0.084 per kg/m² of BMI, and these cannot be ranked without allowing for how much each predictor varies.
Myth: "Adjusted for" means confounding has been removed.
The model adjusts only for the variables it contains, as they were measured. Confounders that were not measured, or were measured poorly, can still bias the coefficient.
Myth: The outcome must be normally distributed.
The assumption concerns the residuals, the differences between observed and predicted values, not the raw outcome.
Why this matters to you
Five consequences of misreading multiple regression
A conclusion you cannot defend at the viva
Writing that older patients have poorer control when, at the same duration of diabetes, age made no difference.
A protocol sent back
"Multivariate analysis will be done" without naming the outcome, the predictors, their coding and why each was chosen.
Wrong numbers from a coding error
A three-category predictor entered as 1, 2, 3 forces equal steps between categories and gives a coefficient that describes no real comparison.
Misreading papers
Taking a standardised β of −0.04 as if it were in clinical units, or reading a dummy coefficient without knowing its reference category.
Predictions that fail for patients
Using the equation for patients outside the range of the data, or trusting a high R² from a model whose residuals curve.
History
History of multiple regression
- 1886
Francis Galton
Published “Regression towards mediocrity in hereditary stature”: children of unusually tall or short parents were, on average, closer to the population average.
- 1896
Karl Pearson
Published a mathematical treatment of correlation and regression in the Philosophical Transactions of the Royal Society, calculating both from the product-moment.
- 1922
R. A. Fisher
Published “The goodness of fit of regression formulae, and the distribution of regression coefficients” in the Journal of the Royal Statistical Society.
- 1977
R. Dennis Cook
Published “Detection of influential observation in linear regression” in Technometrics.
- 2013
Bertha Hidalgo and Michael Goodman
In one year of the American Journal of Public Health, 25 of 30 articles that described a "multivariate" method had used multivariable analyses with a single outcome.
- 2015
Peter Austin and Ewout Steyerberg
Simulations showed that linear regression needs only about two subjects per variable for accurate coefficients, standard errors and confidence intervals, but many more for an unbiased R². Adjusted R² behaved well.
- 2019
Richard Riley and colleagues
Proposed four criteria for the minimum sample size of a linear regression prediction model, including a global shrinkage factor of 0.9 or more and a difference of 0.05 or less between apparent and adjusted R².
- 2024
Gary Collins and colleagues
Published TRIPOD+AI, a 27-item checklist for reporting prediction models built with regression or machine learning, replacing TRIPOD 2015.
Guidelines
Multiple regression in reporting guidelines
“For either simple or multiple (multivariable) regression analyses, report the regression equation.” “Report the regression coefficients (beta weights) of each explanatory variable and the associated confidence intervals and P values, preferably in a table.” Provide a measure of goodness of fit, “the coefficient of multiple determination, R2, for multiple regression”.
Report “whether the variables were assessed for a) colinearity and b) interaction” and “describe the variable selection process by which the final model was developed”. In linear regression, indicate “whether an analysis of residuals confirmed the assumptions of linearity”.
“Give unadjusted estimates and, if applicable, confounder-adjusted estimates and their precision (e.g., 95% confidence intervals). Make clear which confounders were adjusted for and why they were included.”
For prediction models: “Depending on the type of model, describe how predictors were handled in the analyses (functional form, rescaling, transformation, or any standardisation)”.
Reading a paper
Five checks on any multiple regression in a paper
- Are the outcome, every predictor, its units and the reference category of each categorical predictor stated?
- Are coefficients given in clinical units with 95% confidence intervals, not only standardised β or p values?
- Were the predictors chosen before the analysis for stated reasons, or by a stepwise procedure?
- Are unadjusted estimates shown alongside adjusted ones, and is the number of patients large for the number of predictor terms?
- Did the authors check residuals, interactions and collinearity, and report what they found?
Why is it called that?
Word surgery
“Adjusted”
Changed a little to fit, corrected.
Estimated with the other predictors in the model held constant. It says nothing about variables left out of the model.
“Dummy variable”
A fake or a stand-in with no real function.
A real 0/1 variable that marks one category of a predictor, compared with the reference category.
“Interaction”
People talking to or affecting each other.
The effect of one predictor on the outcome depends on the value of another predictor.
B: change per unit, others held constant. β: change in SDs per SD. R²: share explained. Adjusted R²: R² with a penalty for each term. Partial r: the others removed from both. Part r: the others removed from the predictor only.
Multiple
Late Latin multiplus: "manifold"
Multiple regression has more than one predictor. One outcome with several predictors is also called multivariable.
Partial
Latin pars: "a part, piece, a share"
A partial regression coefficient or partial correlation describes one part of the relation, with the other predictors taken out.
Residual
Latin residuum: "that which is left behind"
What the model leaves unexplained for each patient: observed minus predicted value.
Coefficient
co- + efficient: "that which unites in action with something else to produce a given effect"
The number that multiplies a predictor in the regression equation.
Regression
Latin regressio: "a going back, a return"
Galton (1886) found that children of unusually tall or short parents were, on average, closer to the population average, and called this "regression towards mediocrity". The name stayed with the method.
Exam answers
Short-note outlines
Multiple linear regression
- Definition: a model for a continuous outcome with two or more predictors: y = b₀ + b₁x₁ + … + bₖxₖ, fitted by least squares.
- Coefficients: each bᵢ is the change in y per unit of xᵢ with the other predictors held constant (partial regression coefficient). Example (teaching data): age 0.036 alone, 0.004 with duration in the model.
- Categorical predictors: k − 1 dummy variables with a stated reference category. Interaction: a product term.
- Fit and tests: R², adjusted R², overall F test, t test and 95% CI for each coefficient.
- Assumptions: linearity, independence, constant variance, normal residuals, no influential outliers, no severe multicollinearity. Checked with residual plots and VIFs.
- Uses: adjusting for confounders, prediction, and finding which factors are associated with an outcome independently of others.
- Pitfalls: too many predictors for n, stepwise selection, extrapolation, causal claims from observational data.
- Reporting (SAMPL): the equation, coefficients with CIs and p values in a table, R², and checks of collinearity, interaction and residuals.
Coefficient of determination (R²), adjusted R² and multiple correlation
- SST = SSR + SSE. R² = SSR ÷ SST: the share of outcome variation explained. Teaching data: 66.81 ÷ 130.15 = 0.513.
- Multiple R = √R² = 0.716: the correlation between observed and predicted values. With one predictor, R² = r².
- R² never falls when a predictor is added, so it rewards extra terms.
- Adjusted R² = 1 − (1 − R²)(n − 1) ÷ (n − k − 1) = 0.492. It rises only if the new term has |t| > 1, and can be negative.
- A high R² does not show that the model form is right (check residuals) or that the model will predict new patients (validate it).
Dummy variables, interaction terms, and partial and semi-partial correlation
- Dummy variables: k categories → k − 1 variables of 0 and 1. Each coefficient is the adjusted difference from the reference category. Test the set with one F test. Teaching data: sedentary vs active +0.93 (0.57 to 1.29).
- Interaction: the product x₁ × x₂. Its coefficient is the change in the slope of x₁ per unit of x₂. Centre continuous variables so the main effects describe a realistic patient. Teaching data: BMI slope 0.048 (not sedentary) and 0.159 (sedentary).
- Partial correlation: the other predictors removed from both outcome and predictor. r = t ÷ √(t² + df). Duration 0.43.
- Semi-partial (part) correlation: the other predictors removed from the predictor only. Its square is the fall in R² when the predictor is removed. Duration r² = 0.111.
The one thing to remember
Each coefficient in a multiple regression compares patients who have the same values of every other predictor in the model, and of nothing else.
The HbA1c data, the residual patterns and the worked example are made up for teaching. Every number was computed in Python (statsmodels 0.14, SciPy 1.15, pingouin 0.6) and checked against the calculations the interactive elements run in the browser.
Sources: Jaspert FM et al. BMJ Open 2024;14(11):e089374 (doi:10.1136/bmjopen-2024-089374, PMID 39532359). Lasserson DS et al. BMJ Open 2016;6(6):e010702 (doi:10.1136/bmjopen-2015-010702, PMID 27288374). Galton F. J Anthropol Inst 1886;15:246 (doi:10.2307/2841583). Pearson K. Phil Trans R Soc Lond A 1896;187:253–318 (doi:10.1098/rsta.1896.0007). Stanton JM. J Stat Educ 2001;9(3) (doi:10.1080/10691898.2001.11910537). Fisher RA. J R Stat Soc 1922;85:597 (doi:10.2307/2341124). Cook RD. Technometrics 1977;19:15–18 (doi:10.1080/00401706.1977.10489493). Hidalgo B, Goodman M. Am J Public Health 2013;103:39–40 (PMID 23153131). Austin PC, Steyerberg EW. J Clin Epidemiol 2015;68:627–36 (doi:10.1016/j.jclinepi.2014.12.014, PMID 25704724). Riley RD et al. Stat Med 2019;38:1262–75 (doi:10.1002/sim.7993, PMID 30347470). Collins GS et al. TRIPOD+AI statement. BMJ 2024;385:e078378 (doi:10.1136/bmj-2023-078378, PMID 38626948). Lang TA, Altman DG. SAMPL guidelines. Int J Nurs Stud 2015;52:5–9 (PMID 25441757). von Elm E et al. STROBE statement. Lancet 2007;370:1453–7 (PMID 18064739). Software: IBM SPSS Statistics Base 26 manual and IBM Documentation (Linear Regression Statistics and Plots). R documentation for lm, summary.lm, confint, anova.lm, relevel, formula and plot.lm. CRAN reference manuals for lm.beta 1.7-3, ppcor 1.1 and jmv 2.8.0. jamovi documentation. Accessed 15 September 2026.
Further reading