Lesson 3.7 · 10 min read · about 55 min to master at a very slow pace

R², Adjusted R², RMSE and Other Metrics

MAE, MSE, RMSE, MAPE and average error; R² as improvement over predicting the mean; out-of-sample R² that can go negative; and adjusted R², which penalises useless predictors. With worked calculations.

Not startedJump to quiz

Error metrics

Let on evaluation observations, ideally held-out data.

MeasureFormulaNotes
MAEAverage miss in units of . Robust to outliers.
Average errorSigned bias: positives and negatives cancel.
MSESquared units.
RMSEUnits of . Penalises large errors more than MAE.
RSS / SSETotal squared error; grows with .
MAPEPercentage error; breaks if .

Worked example

Test residuals . MAE . MSE . RMSE . Average error (the model tends to under-predict).

Always compare against a baseline: the "average predictor" that predicts for everyone. A model is only useful if it beats that.

R²

Coefficient of determination

TSS is the squared error of the baseline "always predict the mean". So is the fraction of the baseline's squared error the model removes. In-sample with an intercept, .

Dataset B

RSS (lesson 3.4). TSS . : the line removes 60% of the mean-only model's squared error.

R² cautions

  • does not mean 75% of predictions are correct.
  • A high in-sample doesn't guarantee good out-of-sample prediction.
  • A low doesn't mean the predictors are useless: the signal may be nonlinear, or very noisy.
  • says nothing about correct specification: check residuals.

Out-of-sample R²

It uses held-out data and the training mean as the baseline, so it can be negative: the model does worse than just predicting the training average. You want it high and close to the in-sample value.

Adjusted R²

Ordinary never decreases when you add a predictor, even pure noise, because OLS can always set its coefficient to zero and usually finds a tiny bit of in-sample improvement. Adjusted penalises model size:

It goes down when an unhelpful predictor is added and up when a predictor improves fit enough to justify itself.

Worked example

RSS , TSS , , . . .

Dataset B (, ): . The penalty is large when is tiny.

Choosing a metricUse
Typical error in plain units, robust to outliersMAE
Large errors are especially badRMSE
Relative error, never near 0MAPE
Improvement over the mean baseline (out-of-sample)
Comparing in-sample fits with different numbers of predictorsAdjusted (or better, CV)

Cheatsheet

MAE / RMSE

MAE (robust). RMSE (punishes big errors). Both in units of .

R²

, . Share of the mean-baseline's error removed.

Adjusted R²

. Falls when a useless predictor is added.

Out-of-sample R²

Baseline is on test data. Can be negative.

R² misreadings

Not "% correct". High in-sample ≠ good prediction. Low ≠ useless predictors.

See every cheatsheet by category →

Check your understanding

Score 75% or more to master this lesson and earn XP. Answer first, then check.

Q1calculateA model has RSS = 30 and TSS = 120. What is ?
Q2calculateRSS = 30, TSS = 120, and . What is the adjusted ?
Q3calculateOn three test cases the residuals are . What are the MAE and the RMSE?
Q4interpretA model's out-of-sample is −0.2. What does that mean?
Q5interpretA column of pure random noise is added to an OLS model. What typically happens to and adjusted ?