Find a course

Module 4: Multiple RegressionLesson 10 of 1214 min

Multicollinearity, Overfitting and Model Selection

Diagnose correlated predictors with VIF, recognize overfitting with train and test data, and choose models with theory, parsimony and honest validation.

Step 1 of 14Learn

Height in centimeters and height in inches

A student builds a model predicting basketball players' rebounds and includes two predictors: height in centimeters and height in inches. The software runs, but the output is bizarre: one height coefficient is hugely positive, the other hugely negative, and both have enormous standard errors and p-values near 1. Yet the model as a whole fits well.

The two predictors carry exactly the same information. The model can't tell how much credit to give each one, so any combination that adds up to the right overall effect fits equally well. This is multicollinearity in its most extreme form.

Real cases are subtler: square footage and number of rooms, advertising on TV and online when both rise every holiday season, age and years of experience. These predictors are strongly but not perfectly correlated. The model can still be fit, but the coefficients become unstable and hard to interpret.

Multicollinearity is one of two big ways a multiple regression can go wrong while looking fine on the surface. The other is overfitting: building a model so flexible that it fits the noise in your sample and predicts new data badly. This lesson covers how to detect both, and the principles for choosing which variables belong in a model.

Step 2 of 14Learn

Multicollinearity and the VIF

When predictors are highly correlated, multiple regression struggles to separate their individual contributions. Symptoms:

  • Coefficients have large standard errors, so individually they look insignificant even when the predictors jointly matter (a significant overall F-test).
  • Coefficients change a lot, even flip sign, when you add or remove a variable or a few observations.
  • Coefficients have implausible signs or sizes.

Importantly, multicollinearity doesn't hurt predictions within the range of the data, and it doesn't bias the coefficients. It inflates their uncertainty. If you only care about prediction, it may not matter; if you want to interpret individual coefficients, it does.

The standard diagnostic is the variance inflation factor. For predictor j, regress it on all the other predictors and record that R², called R²_j. Then

VIF_j = 1 / (1 − R²_j)

A VIF of 1 means the predictor is uncorrelated with the others. A VIF of 5 means the variance of its coefficient is five times larger than it would be without the overlap, so the standard error is √5 ≈ 2.2 times larger. Common rules of thumb flag VIF above 5 or above 10.

Remedies: drop one of the redundant predictors, combine them into one (such as an index or a total), collect more data with more independent variation, or accept wide intervals if prediction is the goal.

Step 3 of 14Practice · Diagram

VIF = 1 / (1 − R²ⱼ)

Which predictor's coefficient will be estimated least precisely?

Tap the shape that answers the question, then press Check.

VIF = 1 / (1 − R²ⱼ)Scale: R²ⱼ = 0, R²ⱼ = 0.5, R²ⱼ = 0.8, R²ⱼ = 0.95.Usually fineWorth a lookSerious2.557.51012.51517.5201R²ⱼ = 02R²ⱼ = 0.55R²ⱼ = 0.820R²ⱼ = 0.95
The 5 and 10 cut-offs are common rules of thumb, not hard limits.
R²ⱼ = 0

Unrelated to the other predictors.

R²ⱼ = 0.5

2

R²ⱼ = 0.8

5

R²ⱼ = 0.95

Standard error inflated by √20 ≈ 4.5 times.

Step 4 of 14Practice · Work it out

A predictor's R² from regressing it on all other predictors is 0.90. What is its variance inflation factor?

Step 5 of 14Learn

Overfitting and the train/test split

Give a model enough freedom and it can fit almost any sample perfectly. Fit a polynomial of degree 9 through 10 points and it passes through every one of them, R² = 1, while wiggling wildly between them. It has memorized the noise. Shown new data, it predicts terribly. That is overfitting.

The fundamental problem is that fit on the same data used to build the model is an over-optimistic measure of how well the model will work. Every extra predictor, curve or interaction gives the model more ways to chase noise.

The remedy is to judge models on data they haven't seen:

  • Train/test split: fit the model on, say, 70–80% of the data and measure its error on the remaining 20–30%. A model that fits training data far better than test data is overfitting.
  • Cross-validation: split the data into, say, 5 folds; fit on 4, test on the fifth, rotate through all folds and average the test errors. This uses all data for both purposes and gives a more stable estimate.

A useful error measure on test data is the root mean squared error (RMSE), the square root of the average squared prediction error, in the units of y. Compare models by test RMSE, not by training R².

Underfitting is the opposite error: a model too simple to capture real structure, such as a straight line through a curve. Good models sit between the two.

Step 6 of 14Practice · Chart

Training error vs. test error as the model grows

Tap the degree you would choose.

Tap the point that answers the question, then press Check.

Training error vs. test error as the model growsLine chart with 9 categories: 1: Training error 9, Test error 9.4; 2: Training error 5.2, Test error 5.9; 3: Training error 3.6, Test error 4.3; 4: Training error 3.1, Test error 4.6; 5: Training error 2.6, Test error 5.4; 6: Training error 2, Test error 6.8; 7: Training error 1.4, Test error 8.9; 8: Training error 0.7, Test error 12; 9: Training error 0, Test error 17.5.05101520Error (RMSE)123456789Polynomial degree
Illustrative curves for fitting 10 points. Training error always falls; test error falls, then rises.
Training error vs. test error as the model grows
Polynomial degreeTraining errorTest error
199.4
25.25.9
33.64.3
43.14.6
52.65.4
626.8
71.48.9
80.712
9017.5

Step 7 of 14Practice · Work it out

A model's prediction errors on five test observations are 2, −1, 3, −2 and 0. What is the root mean squared error (RMSE)? Round to two decimal places.

Step 8 of 14Compare

Underfit, good fit, overfit

AspectUnderfitGood fitOverfit
ExampleStraight line through clearly curved dataQuadratic through gently curved dataDegree-9 polynomial through 10 points
Training errorHighLowVery low, often near zero
Test errorHighLow, close to training errorHigh, much worse than training error
Typical causeMissing variables or wrong shapeModel matches the real structureToo many terms for the amount of data
FixAdd relevant terms or transformValidate and keep itSimplify, get more data or use cross-validation

Step 9 of 14Practice · True or false

Strong multicollinearity among predictors makes a regression's predictions unreliable, even for new observations that resemble the data used to fit it.

Step 10 of 14Learn

Choosing a model

There is no single correct way to choose predictors, but there are sound principles.

Start from the question and from subject knowledge. If the goal is to estimate the association of a price change with sales, include the variables that plausibly confound it, such as season and promotions, decided before looking at p-values. If the goal is pure prediction, any variable that improves test error is fair game, as long as it will be available when predictions are made.

Prefer simpler models when they perform about as well. This principle, parsimony, makes models easier to explain, more stable and less likely to overfit.

Use criteria that penalize complexity. Adjusted R², the Akaike information criterion (AIC) and the Bayesian information criterion (BIC) balance fit against the number of parameters; lower AIC or BIC is better. Cross-validated error is the most direct check of predictive performance.

Be wary of automated stepwise selection. Adding and dropping variables one at a time based on p-values tends to overfit, produces p-values that are too optimistic and can give different answers for small changes in the data.

Validate on new data. The ultimate test is how the model performs on data collected after it was built.

Finally, report what you tried. A model chosen after testing 40 variations should not be presented as if it were the only one considered.

Step 11 of 14Note

Step 12 of 14Practice · Choose one

A model predicts whether a hospital patient will be readmitted within 30 days. Which predictor is most likely to cause data leakage?

Step 13 of 14Practice · Choose one

A regression with 25 predictors has a training R² of 0.97 but an R² of 0.41 on a held-out test set. What is the most likely problem?

Step 14 of 14Practice · Select all that apply

A model includes advertising spend on TV and on social media, which are correlated at r = 0.93. Both coefficients have large standard errors and are individually insignificant, but the overall F-test is highly significant. Which responses are reasonable? Select all that apply.

Select all that apply.