Prove that the leave-one-out residual of ordinary least squares is ei/(1−hii), where ei is the ordinary residual and hii the leverage, so LOOCV needs only one fit. How do you check it on the points (0,1),(1,3),(2,3) 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 n models.

Key idea

Removing row i changes X⊤X by a rank-one term. The Sherman–Morrison identity gives yi−y^i(−i)=ei/(1−hii) exactly.

Steps

  1. Let xi be row i of X. Without it, X(−i)⊤X(−i)=X⊤X−xixi⊤ and X(−i)⊤y(−i)=X⊤y−xiyi.
  2. Sherman–Morrison: (A−xx⊤)−1=A−1+A−1xx⊤A−11−x⊤A−1x with A=X⊤X. Note xi⊤A−1xi=hii.
  3. Leave-one-out coefficients: β^(−i)=β^−A−1xi ei1−hii, using ei=yi−xi⊤β^. (Expand and combine the two terms.)
  4. Predict the held-out point: xi⊤β^(−i)=y^i−hiiei1−hii. So the held-out error is yi−xi⊤β^(−i)=ei+hiiei1−hii=ei1−hii.
  5. Check: the line fit has residuals (−1/3,2/3,−1/3) and leverages (5/6,1/3,5/6). LOO errors are −2,1,−2, and LOOCV MSE =(4+1+4)/3=3.
  6. Direct check: drop point 1, line through (1,3),(2,3) predicts 3 at x=0, error −2. Drop point 2, line through (0,1),(2,3) predicts 2 at x=1, error 1. Drop point 3, line through (0,1),(1,3) predicts 5 at x=2, error −2. These match.

Common mistakes

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 SW−1SB. Start with a single direction w and maximise w⊤SBww⊤SWw. How do you show that for two classes the result reduces to w∝SW−1(m1−m0)?
Next in Supervised learning: Prove the perceptron convergence theorem: if there is a unit vector w∗ and a margin γ>0 such that yi(w∗⊤xi)≥γ for all i, and ∥xi∥≤R, then the perceptron (starting from w=0) makes at most (R/γ)2 mistakes. Why does the bound not depend on the number of points or the dimension?