More equations than unknowns
A regression has many observations and few coefficients: with tall ( rows, columns, ) has no exact solution, because is almost never in the column space. Least squares picks the that makes the error as small as possible, . Geometrically, is the projection of onto the column space, so the residual is orthogonal to every column of .
Orthogonality of the residual, , rearranges into the normal equations above. They always have a solution, and it is unique when the columns of are independent (then is invertible). In regression notation holds the regressors, with a first column of ones for the intercept, is the response and are the OLS coefficients. In code you still solve the system rather than invert .
- Normal equations: ; solve them, do not invert.
- Residual: , orthogonal to every column of ; with an intercept column it sums to zero.
- Independent columns are needed for a unique answer; collinear regressors make singular.
Lab · what's graded
- The normal matrix15 pts
- The slope15 pts
- The intercept15 pts
- The size of the error10 pts
- What the residual is orthogonal to15 pts
- The steps of a least squares fit15 pts
- Why residuals sum to zero15 pts