Multiple linear regression
Multiple linear regression extends simple linear regression to several predictors. Its real power is adjustment. It can tell you whether a predictor is still associated with the outcome once other variables are accounted for, which is the question most observational research actually asks.
The model
y = b₀ + b₁x₁ + b₂x₂ + … + bₖxₖ + e
Each coefficient bⱼ is the expected change in y for a one-unit increase in xⱼ, with all the other predictors held constant. That phrase is the key to interpreting multiple regression, and the reason a predictor’s coefficient can shrink, grow or even flip sign when other predictors are added.
Two kinds of hypothesis test
- Overall F test. H₀: all slopes are zero, so the model explains nothing.
- t test for each coefficient. H₀: this predictor has no association with the outcome once the others are accounted for (βⱼ = 0).
Categorical predictors and dummy variables
A categorical predictor with k categories enters the model as k − 1 dummy (0/1) variables. One category is the reference, and each dummy’s coefficient is the difference between its category and the reference, holding the other predictors constant. Choose a reference that makes comparisons meaningful, such as the control group or the most common category.
Assumptions
The same as simple regression (linearity, independent errors, homoscedasticity, normal residuals, no dominating influential points), plus:
- No severe multicollinearity. When predictors are highly correlated with each other, the model can’t separate their effects. Coefficients become unstable, with large standard errors. The variance inflation factor (VIF) measures this. Values above 5 deserve attention, and above 10 are usually a problem.
- Enough data. A common rule of thumb is at least 10 to 20 cases per predictor. Too many predictors for the sample size gives an overfitted model that won’t replicate.
Worked example: what predicts fuel economy?
Using the 32 cars in R’s mtcars dataset, we model miles per gallon from weight (1,000 lb), horsepower and number of cylinders. Cylinders is treated as categorical (4, 6 or 8), with 4 cylinders as the reference.
Step 1: run the model
Reference category cyl: 4
Model: Linear regression (OLS)
Outcome: mpg
N: 32
R-squared: 0.8572
Adjusted R-squared: 0.8361
F-statistic: 40.5253
F df: 4, 27
P-value: 4.869e-11
=== COEFFICIENTS ===
const: coef=35.8460, se=2.0410, t=17.5628, p=0.0000, ci=[31.6582, 40.0338]
wt: coef=-3.1814, se=0.7196, t=-4.4211, p=0.0001, ci=[-4.6579, -1.7049]
hp: coef=-0.0231, se=0.0120, t=-1.9344, p=0.0636, ci=[-0.0476, 0.0014]
cyl_6: coef=-3.3590, se=1.4017, t=-2.3964, p=0.0237, ci=[-6.2350, -0.4830]
cyl_8: coef=-3.1859, se=2.1705, t=-1.4678, p=0.1537, ci=[-7.6393, 1.2676]
STD_BETA: {"name": "wt", "beta": -0.516492}
STD_BETA: {"name": "hp", "beta": -0.263012}
=== DIAGNOSTICS ===
VIF wt: 2.581
VIF hp: 3.496
VIF cyl_6: 1.804
VIF cyl_8: 6.230
Breusch-Pagan p (homoscedasticity): 0.1868
Residual normality p: 0.2263
Influential observations (Cook's D > 4/n): 2
Linearity RESET p: 0.0302> summary(lm(mpg ~ wt + hp + factor(cyl), data = mtcars))
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 35.84600 2.04102 17.563 2.67e-16 ***
wt -3.18140 0.71960 -4.421 0.000144 ***
hp -0.02312 0.01195 -1.934 0.063613 .
factor(cyl)6 -3.35902 1.40167 -2.396 0.023747 *
factor(cyl)8 -3.18588 2.17048 -1.468 0.153705
Residual standard error: 2.44 on 27 degrees of freedom
Multiple R-squared: 0.8572, Adjusted R-squared: 0.8361
F-statistic: 40.53 on 4 and 27 DF, p-value: 4.869e-11Every coefficient, standard error, R² and F matches. This exact model is one of the cases Analytika’s test suite checks against R on every change.
Step 2: overall fit
F(4, 27) = 40.53, p < .001, R² = .86, adjusted R² = .84. Together, the predictors explain about 86% of the variation in fuel economy, up from 75% with weight alone.
Step 3: interpret each coefficient
- Weight: b = −3.18, 95% CI [−4.66, −1.70], p < .001. Among cars with the same horsepower and number of cylinders, each extra 1,000 lb is associated with 3.18 fewer mpg.
- Horsepower: b = −0.023, 95% CI [−0.048, 0.001], p = .064. There’s no evidence of an association with fuel economy once weight and cylinders are accounted for. Per 100 hp, that’s about 2.3 fewer mpg, but the interval reaches zero.
- 6 cylinders vs 4: b = −3.36, 95% CI [−6.24, −0.48], p = .024. Six-cylinder cars average 3.36 fewer mpg than four-cylinder cars of the same weight and power.
- 8 cylinders vs 4: b = −3.19, 95% CI [−7.64, 1.27], p = .154. A similar estimate, but much less precise.
Why the coefficients changed
On its own, weight’s slope was −5.34. Here it’s −3.18. Heavy cars also tend to have big, powerful engines, so in the simple model weight was partly standing in for engine size. Holding horsepower and cylinders constant leaves the part of the weight relationship that isn’t shared with them.
Horsepower shows the same thing more dramatically. On its own it correlates strongly with fuel economy (r = −.78), yet here it isn’t significant. That doesn’t mean horsepower is unrelated to fuel economy. It means that, given weight and cylinders, horsepower adds little extra information.
Step 4: check the diagnostics
- Multicollinearity: the VIFs for weight (2.58) and horsepower (3.50) are fine. The 8-cylinder dummy’s VIF is 6.23: eight-cylinder cars are almost all heavy and powerful, so its effect is hard to separate from weight and horsepower. That’s why its CI is so wide.
- Homoscedasticity (Breusch-Pagan p = .19) and residual normality (p = .23): no problems.
- Linearity: RESET p = .030 suggests some remaining curvature. It’s worth trying a squared or log term for weight, as in the simple model.
- Influential points: two cars exceed Cook’s 4/n cut-off. Check them.
- Sample size: 32 cars and 4 coefficients is about 8 cases per coefficient, on the thin side, so treat the estimates as fairly imprecise.
Step 5: report it (APA 7)
A multiple linear regression predicted fuel economy from weight, horsepower and number of cylinders, F(4, 27) = 40.53, p < .001, R² = .86, adjusted R² = .84. Holding the other predictors constant, heavier cars had lower fuel economy, b = −3.18, 95% CI [−4.66, −1.70], p < .001, and six-cylinder cars had lower fuel economy than four-cylinder cars, b = −3.36, 95% CI [−6.24, −0.48], p = .024. There was no evidence of an association for horsepower, b = −0.02, 95% CI [−0.05, 0.00], p = .064, or for eight vs four cylinders, b = −3.19, 95% CI [−7.64, 1.27], p = .154.
With several predictors, a table of coefficients (b, SE, 95% CI, β, p) is usually clearer than text. Our free APA table formatter can lay it out.
Common mistakes
- Comparing raw coefficients across predictors measured in different units. Use standardised coefficients (β) for that: here weight’s β is −.52 and horsepower’s is −.26.
- Dropping predictors because they’re “not significant” and refitting until everything is. That’s data dredging. Choose predictors from theory before you look.
- Treating a numeric category code as continuous, such as cylinders as 4/6/8 in one column, which forces equal steps between categories.
- Ignoring multicollinearity, then over-reading unstable coefficients.
- Saying “controlling for X” as if it settles causation. Only measured confounders are adjusted for.
Going further
- Hierarchical regression: add predictors in blocks and test whether each block improves R².
- Interactions: test whether one predictor’s effect depends on another (moderation).
- Other outcome types: logistic, ordinal and count models follow the same logic. See regression analysis for choosing a model.
How to run it
- SPSS: Analyze → Regression → Linear. Add all predictors under Independent(s), create dummies for categorical predictors first, and tick Collinearity diagnostics and Confidence intervals under Statistics.
- R:
summary(lm(y ~ x1 + x2 + factor(group), data = df)), pluscar::vif(). - Python:
statsmodels.formula.api.ols("y ~ x1 + x2 + C(group)", data=df).fit() - Analytika: ask, for example, “what predicts mpg from weight, horsepower and cylinders?”. It builds the dummies, fits the model, and reports coefficients, VIFs, diagnostics and an APA-style summary.
More in Regression
Try it with the free tools
Run this on your own data
Upload a dataset and ask your question in plain English. Analytika checks the assumptions, picks the test, runs it, and writes the results up in APA format.