Definition
A method for choosing the unknown parameters in a Linear regression model by the principle of least squares (minizing the residual sum of squares).
Intuition
OLS = MLE + Gaussian noise assumption.
Setting
Given an input vector . The linear regression model:
In a machine learning, we often subsume the by using a full one column in the design matrix (Zhang et al., 2024):
with
Estimation
Assume
- Linear regression model.
- Loss function: the residual sum of squares as the measure of the overall model fit:
The value of which minimizes this sum is called the OLS estimator for
This RSS is a quadratic function in the parameters. Differentiating w.r.t. , we obtain:
Assuming that has full column rank, and hence is Positive definite Set the first derivative to zero
to obtain the unique solution:
Prediction
The predicted values at an input vector are given by:
- : Augmented vector. The fitted values (optimal point estimator) at all the training inputs are:
- .
- : The “hat” matrix (because it puts the hat on ), the projection matrix.
//TODO: Gauss-Markov theorem
Geometric interpretation
The columns of : span a subspace of (the column space of ) with ; for simplicity, assume they span a plane (2D).
The goal of OLS is to minimize the RSS
The unique vector within the column space of that minimizes this distance is the orthogonal projection of onto that space. Geometrically, this means
This leads to the normal equation
Properties of least-squares estimators
Assumptions: uncorrelated and constant variance of the observations . The variance-covariance matrix of the least squares parameter estimates:
Unknown variance can be estimated by: