Does my model fit only these data or new ones as well? (overfitting, adjusted R², cross-validation, stepwise selection)
In brief
R² rises with every additional predictor, even with a column of random numbers. Whoever lets many variables loose on few cases adapts the model to the chance of this sample (overfitting). The adjusted R² subtracts this chance gain; the real quality shows only with new data (cross-validation).
An example by hand
25 students. Model A: 2 variables, R² = 0.40. Model B: 10 variables, R² = 0.52. Adjusted R² = 1 − (1 − R²) · (n − 1) : (n − k − 1).
A: 1 − 0.60 · 24 : 22 = 0.345. B: 1 − 0.48 · 24 : 14 = 0.177. B looks better by R², but clearly worse after the deduction. For B there are only 2.5 cases per variable (rule of thumb: about 10 to 15).
Why a stepwise selection misleads
In a stepwise selection a program tries many variables and keeps those that fit best in these data. This uses the chance of the sample: R² and p values of the chosen model are too favourable, and with new data the explanatory power falls (shrinkage). It is better to choose variables for substantive reasons and keep their number small.
Cross-validation
The cases are split into parts, the model is fitted on one part and checked on another. If the parts are swapped in turn, every case is used once for checking; the mean error there estimates the quality for new data. Important: selection of the variables and checking must not happen on the same cases.
How it works in Statable
- Open the example "Cars". "Model 1: weight only" shows R² 0.753, adjusted R² 0.745. In "Model 3: weight and transmission" R² does not rise (0.753), the adjusted R² falls to 0.736: the transmission adds nothing.
- Statable has no button for cross-validation of an ordinary regression. The penalised regression (lasso and ridge) does it itself with 10 parts. Whoever wants to check a regression with new data selects a part of the cases with "Select cases", calculates on it and checks the prediction on the rest.
What is often misunderstood
- A higher R² does not mean the model predicts new cases better.
- The adjusted R² can be smaller than R² and even fall below zero; then the model explains nothing beyond chance.
- The adjusted R² does not replace checking with new data either: it corrects only for the number of variables, not for the choice among many.
For specialists
R²adj = 1 − (1 − R²)(n − 1) : (n − k − 1), an unbiased estimator of the population R² only approximately (Wherry formula). Rules of thumb for sample size: about 10 to 15 cases per parameter. Stepwise selection: biased B, intervals too narrow, p values too small (Harrell 2015). k-fold cross-validation: mean of the prediction errors over k test parts.
Sources
Harrell, F. E. (2015). Regression Modeling Strategies, 2nd edition. Springer. Hastie, T., Tibshirani, R. & Friedman, J. (2009). The Elements of Statistical Learning, chapter 7. Springer. Cohen, J., Cohen, P., West, S. G. & Aiken, L. S. (2003). Applied Multiple Regression/Correlation Analysis. Erlbaum.