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.
Error metrics
Let on evaluation observations, ideally held-out data.
| Measure | Formula | Notes |
|---|---|---|
| MAE | Average miss in units of . Robust to outliers. | |
| Average error | Signed bias: positives and negatives cancel. | |
| MSE | Squared units. | |
| RMSE | Units of . Penalises large errors more than MAE. | |
| RSS / SSE | Total squared error; grows with . | |
| MAPE | Percentage 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 metric | Use |
|---|---|
| Typical error in plain units, robust to outliers | MAE |
| Large errors are especially bad | RMSE |
| Relative error, never near 0 | MAPE |
| Improvement over the mean baseline | (out-of-sample) |
| Comparing in-sample fits with different numbers of predictors | Adjusted (or better, CV) |
Cheatsheet
MAE / RMSE
R²
Adjusted R²
Out-of-sample R²
R² misreadings
Check your understanding
Score 75% or more to master this lesson and earn XP. Answer first, then check.