Multiple Linear Regression

Multiple linear regression generalizes simple linear regression from one predictor to predictors per observation. With observations where each holds the predictor values for observation , the model is

or equivalently with absorbing the intercept and . Stacking all observations into matrix form,

where , is the design matrix whose row is , and is the vector of noise terms.

The OLS estimator is the closed-form minimizer of :

The inverse exists when the columns of are linearly independent, which requires at minimum. The geometric interpretation is that is the orthogonal projection of onto the column space of , with the residual vector perpendicular to every predictor.

Multicollinearity is close to singular and the OLS estimator becomes numerically unstable: small changes in produce large swings in , individual coefficient standard errors blow up, and individual coefficients can flip sign run-to-run while the joint fit remains stable. The standard remedies are dropping correlated predictors, pre-processing with PCA, or moving to ridge regression which adds to the diagonal of and stabilizes the inverse.

When predictors are highly correlated,

Intuition

Multiple linear regression is the same idea as simple regression, scaled up: find the coefficient vector that makes the linear combination of predictors closest to the response in squared-error sense. The matrix formula is the multidimensional version of the slope formula from simple regression, with playing the role of and playing the role of .

The geometric picture is even cleaner. The fitted vector lies in the column space of (it is a linear combination of the predictors), and the residual vector is the part of that the predictors cannot explain. The OLS criterion picks the unique in the column space that minimizes the residual length, which by elementary geometry is the orthogonal projection of onto the column space. The orthogonality condition is exactly the matrix equation that produces the closed-form solution.

Properties

(OLS Solution) The closed-form estimator is when has full column rank.

The derivation comes from the orthogonality of the residual vector to the column space of . Setting gives the normal equations , and inverting the Gram matrix produces the solution. The Gram matrix is invertible exactly when the predictor columns are linearly independent, which requires and consequently . When or columns are collinear, the inverse fails to exist and the problem is ill-posed without regularization.

(Hat Matrix) The fitted values are a linear projection of the response.

Defining the hat matrix , the fitted values are , justifying the name (it puts the “hat” on ). The hat matrix is the orthogonal projector onto the column space of : it is symmetric, idempotent (), and its trace equals (the number of fitted parameters, equal to the rank of the projection). The diagonal entries are the leverages of each observation, measuring how much observation ‘s own response influences its own fitted value, and large leverages identify points whose removal would significantly change the fit.

(Gauss-Markov Theorem) OLS is the BLUE under uncorrelated, constant-variance noise.

If and , then among all linear unbiased estimators of , the OLS estimator has the smallest variance — it is the best linear unbiased estimator (BLUE). The result requires no distributional assumption beyond the first two moments. When the noise covariance is not scalar, the BLUE becomes the generalized least squares estimator , which weights observations by the inverse noise covariance.

(Residual Variance) is the unbiased estimator of .

The denominator is the degrees of freedom remaining after fitting parameters. The MLE under Gaussian noise is the corresponding biased estimator that divides by ; dividing by corrects for the lost degrees of freedom and produces an unbiased estimator. This is the variance estimator that goes into standard errors and -statistics.

(Adjusted ) Penalizes added predictors that do not improve fit enough.

The ordinary can only increase as predictors are added, since the optimization has more freedom. The adjusted version

divides each sum of squares by its degrees of freedom, so adding a predictor that does not reduce SSE proportionally enough actually decreases . This makes it a more honest metric for comparing models of different sizes.

(Inference Under Normality) The coefficient vector is jointly Gaussian.

Under , the estimator is exactly Gaussian: . Individual coefficients can be tested via under , and groups of coefficients via -tests on nested models. Without Gaussianity, the same statistics are approximately Normal by the central limit theorem when is large.

When two unrelated variables both trend over time (or both have unit-root behavior), an OLS regression of one on the other often produces a high and small -values even though the variables share no real dependence — the common trend is mistaken for a relationship. This is why blindly regressing time-series quantities is dangerous; the standard remedies are differencing the series, including a trend term explicitly, or testing for cointegration. See 2.4 Time Series Regression for the time-series-specific treatment.

(Iterative Computation by Gradient Descent) When or is too large for the closed form, gradient descent solves the same optimization.

For very large (millions of rows) or very large (thousands of features), the cost of forming and inverting becomes prohibitive. Iterative methods such as gradient descent

converge to the same OLS minimum at per step and avoid the matrix inversion entirely. This is the algorithm of choice when fitting linear models on big data, and it is the same machinery (with a different loss) that drives logistic regression and most of deep learning.

Examples

Predicting house price from multiple features

is sale price; predictors are square footage, number of bedrooms, age, and distance to downtown ( including intercept). Fit OLS on houses.

Polynomial regression as a special case

Fit to a curved scatter plot.

Geometric derivation of the normal equations

Show that being the orthogonal projection of onto implies .

See Also