Design matrix
An n×p matrix whose rows describe observations and whose columns are predictors, optionally including a column of ones.
REFERENCE SHEET
Fit conditional means while keeping the assumptions behind inference visible.
Before this Orthogonality, least squares & SVD, Estimation & likelihood
An n×p matrix whose rows describe observations and whose columns are predictors, optionally including a column of ones.
Ordinary least squares minimizes ‖y−Xβ‖² over β.
The fitted error e=y−Xβ̂. It is not the unobserved model error ε.
With fixed full-column-rank X and E[ε|X]=0, E[β̂|X]=β.
If additionally Var(ε|X)=σ²I, OLS has minimum covariance in the positive-semidefinite order among estimators linear in y and unbiased conditional on X. Normal errors are not required.
Every OLS fit satisfies Xᵀe=0. With an intercept, residuals sum to zero.
Approximate a response from measured features, assessing error on data not used to fit.
Include measured covariates to model conditional associations; causal interpretation requires additional design or assumptions.
01 / Compute
The points lie exactly on a line.
a=1 and b=2, with all residuals zero.
02 / Prove
Use the corresponding entry of Xᵀe.
The intercept column is the all-ones vector. Its inner product with e is Σᵢeᵢ, which is zero by the normal equations.
Further reading and full-length treatments: