In least-squares linear regression, why is the fitted vector the orthogonal projection of onto the column space of , and what does this say about the residuals?
Supervised learning, Linear regression
Level L3 Intermediate. Length Short. Nature Th Theoretical.
What's being asked
Whether you can see least squares as geometry: the closest point in a subspace is found by dropping a perpendicular.
Key idea
Minimising over means finding the point in the column space of nearest to . The nearest point is the foot of the perpendicular, so the residual is orthogonal to every column of , that is .
Steps
- Say that every vector is a combination of the columns of . So the set of all possible fitted vectors is the column space of (a flat subspace of , where is the number of samples).
- Fitting means choosing the point of this subspace closest to . In ordinary geometry, the closest point on a plane to a given point is found by dropping a perpendicular.
- So the residual is perpendicular to the subspace: for every column . Written together, , which are exactly the normal equations.
- Read off the consequences. If the model has an intercept, one column is all ones, so . Each feature is uncorrelated in-sample with the residual.
- Add Pythagoras: , because . This is the basis of the decomposition.
Common mistakes
- Saying the residuals are orthogonal to or to the fitted line. They are orthogonal to the columns of and to , not to .
- Forgetting that the space here is (one axis per sample), not the feature space. The fitted vector lives in .
- Claiming residuals sum to zero always. This needs an intercept column in .
How long your answer should be
4–6 sentences, with a small sketch of a vector, a plane and a perpendicular if you can.
Read this
- Mathematics for Machine Learning (Deisenroth, Faisal, Ong): Section 3.8 (orthogonal projections, p. 81) and section 9.4 (maximum likelihood as orthogonal projection, p. 313), which show the fitted vector as a projection onto the column space.
- NPTEL: Linear Algebra (IIT Madras, Dr. K.C. Sivakumar): Module 12, Best Approximation: Least Squares Solutions and Orthogonal Complementary Subspaces, Orthogonal Projections, which show that the least-squares fit is an orthogonal projection.
- MIT OCW: 18.06 Linear Algebra (Spring 2010): Lecture 16, Projection matrices and least squares, which shows the projection picture of least squares.
Previous in Supervised learning: Show that a naive Bayes classifier with two classes and binary features is a linear classifier in , and give its weights. For , , , , , find the log-odds for and . What goes wrong if feature 2 is copied twice?
Next in Supervised learning: Fit a straight line (intercept and slope) to the three points . What are the hat matrix diagonal entries , do they sum to 2, and what is the residual vector?