Prove that the leave-one-out residual of ordinary least squares is , where is the ordinary residual and the leverage, so LOOCV needs only one fit. How do you check it on the points by computing the LOOCV mean squared error both ways?
Supervised learning, Least squares and the hat matrix
Level L4 Advanced. Length Long. Nature Mat Mathematical.
What's being asked
Whether you can use a rank-one update (Sherman–Morrison) to avoid refitting models.
Key idea
Removing row changes by a rank-one term. The Sherman–Morrison identity gives exactly.
Steps
- Let be row of . Without it, and .
- Sherman–Morrison: with . Note .
- Leave-one-out coefficients: , using . (Expand and combine the two terms.)
- Predict the held-out point: . So the held-out error is .
- Check: the line fit has residuals and leverages . LOO errors are , and LOOCV MSE .
- Direct check: drop point 1, line through predicts 3 at , error . Drop point 2, line through predicts 2 at , error . Drop point 3, line through predicts 5 at , error . These match.
Common mistakes
- Using for models other than linear smoothers. It holds for OLS and ridge (with its own ), not for lasso or trees.
- Forgetting that high-leverage points have an LOO error much larger than their ordinary residual.
- Dividing the residual by . The square belongs only to the squared LOO error, not to the residual.
How long your answer should be
One page; 8 minutes.
Last checked on 4 December 2026.
Read this
Previous in Supervised learning: Derive why the directions that maximise the multi-class Fisher criterion are the leading eigenvectors of . Start with a single direction and maximise . How do you show that for two classes the result reduces to ?
Next in Supervised learning: Prove the perceptron convergence theorem: if there is a unit vector and a margin such that for all , and , then the perceptron (starting from ) makes at most mistakes. Why does the bound not depend on the number of points or the dimension?