Ordinary Least Squares (OLS) & Normal Equation Derivations
“The OLS weight vector w* = (X^T X)^{-1} X^T y projects target vector y orthogonally onto the Column Space Col(X).”
- —Residual Sum of Squares (RSS): RSS(w) = ||y - Xw||_2^2 = (y - Xw)^T (y - Xw) = y^T y - 2 w^T X^T y + w^T X^T X w.
- —Matrix Gradient: grad_w RSS(w) = -2 X^T y + 2 X^T X w = 0.
- —Normal Equations: (X^T X) w* = X^T y.
- —Projection Matrix (Hat Matrix): H = X (X^T X)^{-1} X^T. Hat matrix is symmetric (H^T = H) and idempotent (H^2 = H).
- —Predicted Values: y_hat = H y. Residual Vector: e = y - y_hat = (I - H) y.
- —Gauss-Markov Theorem: Under homoscedastic and uncorrelated errors, OLS estimator is BLUE (Best Linear Unbiased Estimator).
- —The matrix X^T X is invertible if and only if design matrix X has FULL COLUMN RANK (columns of X are linearly independent).
- —If features are collinear (multicollinearity), Det(X^T X) = 0 and OLS fails to yield a unique solution.