REGRESSION MODELLING FOR HEALTH PRACTITIONERS · CHAPTER 3
Multiple Linear Regression
When more than one predictor influences a continuous
outcome,multiple linear regression is used. This chapter
extends the simple linear regression model to accommodate several
predictors, discusses model interpretation and variable selection, and
demonstrates how to fit multivariable models using R,
Python and Julia.
Model Specification
In multiple linear regression, the outcome is expressed as a linear combination of predictors plus an error term:
The coefficients represent the expected change in for a one–unit increase in while holding all other predictors constant. This allows researchers to distinguish the effects of different variables on the outcome. Fitting the model by least squares produces estimates and an estimated variance .
Interactions and Nonlinear Terms
Sometimes the effect of one predictor depends on the value of another. An interaction term between and adds a product to the model. Nonlinear relationships can be modelled by including polynomial terms (e.g., ) or spline functions—see Chapter [chap:smoothing_and_gam] for details.
Worked Example: Blood Pressure with Multiple Predictors
Consider an extension of the weight–blood pressure example from Chapter [chap:02_simple_linear_regression]. Suppose we collect additional predictors: age (years) and sex (0 = female, 1 = male). Our model becomes
R
# Example dataset (expand as needed)
df <- data.frame(
weight = c(60,65,68,70,72,75,78,80,82,85),
age = c(45,48,50,52,54,57,60,62,64,66),
sex = c(0,1,0,1,0,1,0,1,0,1),
sbp = c(120,122,124,125,127,130,132,135,137,140)
)
# Fit multiple regression
model <- lm(sbp ~ weight + age + sex, data = df)
summary(model)
# Interpret coefficients: exponentiate if needed
Python
import pandas as pd
import statsmodels.formula.api as smf
df = pd.DataFrame({
'weight': [60,65,68,70,72,75,78,80,82,85],
'age': [45,48,50,52,54,57,60,62,64,66],
'sex': [0,1,0,1,0,1,0,1,0,1],
'sbp': [120,122,124,125,127,130,132,135,137,140]
})
model = smf.ols('sbp ~ weight + age + sex', data=df).fit()
print(model.summary())
Julia
using DataFrames, GLM
df = DataFrame(weight=[60,65,68,70,72,75,78,80,82,85],
age=[45,48,50,52,54,57,60,62,64,66],
sex=[0,1,0,1,0,1,0,1,0,1],
sbp=[120,122,124,125,127,130,132,135,137,140])
model = lm(@formula(sbp ~ weight + age + sex), df)
coeftable(model)
The regression output includes estimates and standard errors for each
coefficient. For example, a positive coefficient for sex
suggests that males have higher blood pressure on average than females
when weight and age are held constant.
Model Building and Variable Selection
Choosing which variables to include in a regression model is a common challenge. The goal may be to understand causal relationships, in which case variables are selected based on prior knowledge and directed acyclic graphs (see Chapter [chap:reporting_and_interpretation]). Alternatively, when prediction is the goal, automated selection methods such as forward, backward or stepwise selection can be used, but they should be combined with cross–validation to avoid overfitting. Penalised regression techniques, such as the lasso and ridge (Chapter [chap:regularisation_and_selection]), provide principled ways to shrink coefficients and perform variable selection simultaneously.
Interpretation
In a multiple regression model, each coefficient represents the expected change in the outcome per unit change in its predictor while keeping all other predictors fixed. This ability to adjust for other variables allows us to distinguish the independent effect of each predictor. Confidence intervals and p‑values for each coefficient help assess whether the association is statistically significant. However, statistical significance does not imply clinical importance—examine the magnitude and direction of effects and consider the clinical context.
Exercises
Exercises
Using a publicly available dataset of your choice (e.g., the built‐in
mtcarsdataset in R or Python), fit a multiple regression model predicting a continuous outcome (e.g., fuel consumption) from at least three predictors. Interpret each coefficient.Consider the blood pressure example above and add an interaction between weight and sex. Fit the model and interpret the interaction term. When might interactions be important in clinical research?
Explore multicollinearity by computing variance inflation factors (VIFs) for the predictors. How does high multicollinearity affect the estimates and their standard errors?
Simulate a dataset where two predictors are highly correlated (e.g., height and weight) and fit a multiple regression. Compare the individual p‑values to those from a regression with only one predictor.
Code examples use illustrative datasets. Supply data with the named columns to run them.