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.

Age aloneAge after allowing for duration405060706810-15015-202x: age (years), y: HbA1c (%)age not explained by duration (years)y axis: HbA1c not explained by duration (%)slope 0.036 per yearslope 0.004 per year
Teaching data, made up: 120 adults with type 2 diabetes. Left: age alone gives a slope of 0.036 percentage points of HbA1c per year. Right: the same patients after removing the part of HbA1c and the part of age that duration of diabetes explains (the residuals of two simple regressions on duration). The slope is now 0.004 per year, which is exactly the age coefficient in the model that contains both age and duration. Most of the crude age effect was duration.

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.

Predictors in the model
Reference category for activity

Tick physical activity to choose its reference category.

Regression coefficients for HbA1c
PredictorB95% CISEtpβ
Intercept (constant)6.1425.296 to 6.9870.42714.38< 0.001
Age (years)0.0360.022 to 0.0510.0074.93< 0.0010.41
0.171R²
0.164adjusted R²
< 0.001F(1, 118) = 24.34

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 = 130.15: all the variation in HbA1c around its meanAgeR² 0.171adjusted R² 0.164+ durationR² 0.250adjusted R² 0.237+ BMIR² 0.402adjusted R² 0.387+ activityR² 0.513adjusted R² 0.492SSR: explained by the modelSSE: left unexplained
Teaching data. Each bar is the total sum of squares of HbA1c, 130.15. The dark part is explained by the model. As predictors are added, the explained part grows and R² rises from 0.171 to 0.513. Adjusted R² rises less, because it allows for the number of predictors.

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.

0

30 patients, 2 predictors, 27 residual degrees of freedom

0.405R²
0.361adjusted R²
0useless predictors with p < 0.05

With duration and sedentary only, R² is 0.405 and adjusted R² is 0.361.

-0.6-0.20.00.20.61.005101520useless predictors addedR²adjusted R²

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.

Analysis of variance table for the full teaching model
SourceSum of squaresdfMean squareFp
Regression66.81513.3624.05< 0.001
Residual63.331140.556
Total130.15119

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.

DurationAge, BMI, activityHbA1cabcea: variation in HbA1c explained by duration and by no other predictor. Semi-partial r² = a = 0.111b: shared by duration and the other predictors, and credited to neither coefficiente: explained by no predictor = 1 − R² = 0.487. Partial r² = a ÷ (a + e) = 0.186
Teaching data. The areas are not drawn to scale. Semi-partial r² is the share of all the HbA1c variation that duration explains on its own: it equals the fall in R² if duration is removed from the model (0.513 − 0.402 = 0.111). Partial r² is the same area as a share of the variation the other predictors leave unexplained.

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.

Indicator coding of physical activity with active as the reference
Physical activitymoderatesedentaryPatients
Active (reference)0056
Moderately active1038
Sedentary0126
Reference: active-10+1activereferencemoderate+0.24sedentary+0.93Reference: sedentary-10+1active−0.93moderate−0.69sedentaryreference
Teaching data, full model, with 95% CIs. Each dummy coefficient is the adjusted difference from the reference category. Changing the reference from active to sedentary changes which differences are printed, but not the model: R² (0.513), the predictions and the other coefficients stay the same. Moderate vs active: p = 0.13. Moderate vs sedentary: p < 0.001.
  • 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

182226303478910BMI (kg/m²)predicted HbA1c (%)0.85 at BMI 27sedentary: +0.159 per kg/m²active: +0.048 per kg/m²
Teaching data, interaction model with BMI centred at 27 kg/m², drawn at the mean age and duration. In patients who are not sedentary, HbA1c rises 0.048 percentage points per kg/m² (95% CI 0.004 to 0.091). The interaction coefficient is 0.111 (0.035 to 0.188, p = 0.005), so in sedentary patients the slope is 0.048 + 0.111 = 0.159 per kg/m².
  • 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.

  1. 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.
  2. Independence: one row per patient, with no repeated measurements or clusters analysed as if independent.
  3. Constant variance: the spread of the residuals is similar at all fitted values. Check: no funnel shape.
  4. 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.
  5. No single patient controls the result: check outliers and influential points (for example Cook's distance), and the case records behind them.
  6. Predictors that do not overlap too much: check variance inflation factors (multicollinearity chapter).
Even bandCurveFunnelOutliereach panel: residual (up) against fitted value (across)
Made-up residual plots. An even band is what a suitable model gives. A curve means a curved relation was fitted as a straight line. A funnel means the spread changes with the fitted value. A single distant point needs checking against its case record.

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.

How the data were generated
0.45R²
0.46mmHg per year of age (95% CI 0.31 to 0.62)

The residuals form an even band around 0 with no pattern. The straight-line model suits these data.

0+21−21residual (mmHg)116148fitted systolic BP (mmHg)

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

FeatureR²Adjusted R²
MeasuresShare of the outcome variation explained in this sampleThe same, with a penalty for each predictor term
When a predictor is addedNever fallsFalls if the new term has |t| below 1
Range0 to 1Can be below 0
UseDescribe how much the model explainsCompare models with different numbers of predictors
Teaching data, full model0.5130.492
FeaturePartial correlationSemi-partial (part) correlation
Other predictors removed fromBoth the outcome and the predictorThe predictor only
Squared, it isUnique variation ÷ variation the others leave unexplainedUnique variation ÷ all the outcome variation
Link to R²No direct linkEquals the fall in R² when the predictor is removed
Duration in the teaching modelr = 0.43r = 0.33 (r² = 0.111)
FeatureUnstandardised BStandardised β
UnitsOutcome units per unit of the predictorSDs of the outcome per SD of the predictor
Clinical readingDirect: +0.096% HbA1c per year of diabetesIndirect: needs the SDs to convert back
Depends on the sample SDNoYes
Categorical predictorsDifference from the reference categoryHard to interpret
ReportAlways, with the 95% CIOptional, 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.

Full teaching model for HbA1c, as a paper would print it
PredictorBSE95% CItpβ
Intercept4.7770.6523.486 to 6.0687.33< 0.001
Age (years)0.0000.009−0.019 to 0.0190.010.990.00
Duration of diabetes (years)0.0960.0190.059 to 0.1335.11< 0.0010.56
BMI (kg/m²)0.0840.0190.047 to 0.1204.50< 0.0010.31
Moderately active (vs active)0.2400.157−0.072 to 0.5521.520.130.11
Sedentary (vs active)0.9320.1830.570 to 1.2945.09< 0.0010.37

n = 120 · R² = 0.513 · adjusted R² = 0.492 · F(5, 114) = 24.05, p < 0.001 · outcome HbA1c (%) · teaching data

  1. Outcome and units: find them in the title or footer. Here every B is in percentage points of HbA1c.
  2. 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.
  3. Size before significance: sedentary patients have HbA1c 0.93 percentage points higher than active patients with the same age, duration and BMI.
  4. 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.
  5. 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.
  6. The footer: n, R², adjusted R² and the F test. Divide n by the number of predictor terms (here 120 ÷ 5 = 24).
  7. 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.

  1. 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.
  2. R² = 66.81 ÷ 130.15 = 0.513. Multiple R = √0.513 = 0.716.
  3. Adjusted R² = 1 − (1 − 0.513) × 119 ÷ 114 = 0.492.
  4. F = (66.81 ÷ 5) ÷ (63.33 ÷ 114) = 13.36 ÷ 0.556 = 24.05, with 5 and 114 df, p < 0.001.
  5. Duration: B = 0.0959, SE = 0.0188, t = 5.11 (from the unrounded values), df 114, p < 0.001.
  6. 95% CI = 0.0959 ± 1.981 × 0.0188 = 0.059 to 0.133 percentage points per year.
  7. Standardised β = 0.0959 × 6.075 ÷ 1.046 = 0.56 (SD of duration 6.075 years, SD of HbA1c 1.046%).
  8. 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.
  9. 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.492

In a real paper

Multiple linear regression in published studies

Open-access paper · CC BY 4.0

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.

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.

What the authors wrote
“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.”
In plain words

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.

ReportedValueWhat it means
Model 1, satisfaction scoreB=0.23; 95% CI (0.02 to 0.45); p=0.03mmHg of SBP per point of the score, adjusted for model 1 variables
Model 2, satisfaction scoreB=0.21; 95% CI (−0.01 to 0.42); p=0.06Almost the same estimate. The CI now includes 0
Adjusted R²0.06 for model 1 and 0.08 for model 2The predictors together explain about 6% to 8% of the variation in SBP
Age, model 10.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, SBPB=0.03; 95% CI (−0.08 to 0.47); p=0.88No evidence that the association differs by gender
Check these when you read it
  • 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.
Open-access paper · CC BY

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.

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.

What the authors wrote
“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.”
In plain words

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.

ReportedValueWhat it means
Methodmultiple stepwise linear regressionThe 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
Patients19 175A very large sample, so small standardised coefficients reach significance
Check these when you read it
  • 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

  1. 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.
  2. Leave Method as Enter, which enters all variables in a block in a single step.
  3. The independent variables must be numeric, so enter physical activity as two 0/1 variables you have created, leaving out the reference category.
  4. 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.
  5. 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.
  6. 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 correlations

jamovi

  1. Analyses → Regression → Linear Regression.
  2. 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).
  3. Model Fit: tick R, R² and Adjusted R². Model Coefficients: tick ANOVA test, Confidence interval and Standardized estimate.
  4. Assumption Checks: tick Q-Q plot of residuals, Residuals plots and Cook's distance.
  5. To compare nested models, use Model Builder and add a second block with “+ Add New Block”.
  6. 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.
Worked sentence, teaching data
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.

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

  1. 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.

  2. A protocol sent back

    "Multivariate analysis will be done" without naming the outcome, the predictors, their coding and why each was chosen.

  3. 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.

  4. 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.

  5. 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

  1. 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.

  2. 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.

  3. 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.

  4. 1977

    R. Dennis Cook

    Published “Detection of influential observation in linear regression” in Technometrics.

  5. 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.

  6. 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.

  7. 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².

  8. 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

SAMPL guidelines (Lang and Altman), regression

“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”.

SAMPL guidelines, 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”.

STROBE (2007), item 16(a)

“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.”

TRIPOD+AI (2024), item 12b

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”

In everyday speech

Changed a little to fit, corrected.

In research

Estimated with the other predictors in the model held constant. It says nothing about variables left out of the model.

“Dummy variable”

In everyday speech

A fake or a stand-in with no real function.

In research

A real 0/1 variable that marks one category of a predictor, compared with the reference category.

“Interaction”

In everyday speech

People talking to or affecting each other.

In research

The effect of one predictor on the outcome depends on the value of another predictor.

Memory trick

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

  1. Definition: a model for a continuous outcome with two or more predictors: y = b₀ + b₁x₁ + … + bₖxₖ, fitted by least squares.
  2. 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.
  3. Categorical predictors: k − 1 dummy variables with a stated reference category. Interaction: a product term.
  4. Fit and tests: R², adjusted R², overall F test, t test and 95% CI for each coefficient.
  5. Assumptions: linearity, independence, constant variance, normal residuals, no influential outliers, no severe multicollinearity. Checked with residual plots and VIFs.
  6. Uses: adjusting for confounders, prediction, and finding which factors are associated with an outcome independently of others.
  7. Pitfalls: too many predictors for n, stepwise selection, extrapolation, causal claims from observational data.
  8. 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

Related Stateazy articles