Matrix Approach
Multiple Regression in Matrix Form
Put the model in one equation
Multiple linear regression is written y = Xbeta + epsilon. The response y has n entries, X is an n by p design matrix whose rows are observations and whose columns contain the p design variables associated with the coefficients, beta has p entries, and epsilon has n entries.
An intercept is represented by a column of ones when it is included. This dimension check is a powerful first defense against transpose errors.
Least squares and the normal equations
Least squares chooses beta-hat to minimize the squared length of y minus Xbeta. When X has full column rank, the normal equations X′X beta-hat = X′y have the unique solution beta-hat = (X′X)−1X′y.
The residual vector is orthogonal to every column of X, expressed as X′e = 0. This is a geometric condition, not an assertion that every residual entry is zero.
Rank and uncertainty
Full column rank is needed for the inverse of X′X. If columns are exactly linearly dependent, coefficient values are not uniquely identified without changing the parameterization or adding a constraint.
Under the standard homoscedastic uncorrelated-error model, the covariance matrix of beta-hat is sigma squared times (X′X)−1. That formula describes sampling uncertainty conditional on the design and model assumptions; it does not by itself make a causal claim.
For a full-rank model, X′X = [[5, 1], [1, 2]] and X′y = [9, 5]T. What is beta-hat?
Which design-matrix condition allows beta-hat = (X′X)-1X′y to be uniquely defined without adding constraints?