Linear Least Squares Regression

When $f$ is a linear function of the parameters $\boldsymbol\beta$, the method is called Linear Least Squares (LLS). The most common formulation is Ordinary Least Squares (OLS).

This function can be represented as a linear system:

\begin{displaymath}
y_i = \mathbf{x}_i \boldsymbol\beta + \varepsilon_i
\end{displaymath} (4.13)

where $\boldsymbol\beta$ is the vector of unknown parameters to be estimated and $\varepsilon_i$ is a zero-mean additive Gaussian noise term. The parameters $\boldsymbol\beta$ are the regression coefficients: they measure the association between the variable $\mathbf{x}_i$ and the variable $y_i$. Each observation provides a constraint, and all the individual constraints can be collected in matrix form:
\begin{displaymath}
\mathbf{y} = \mathbf{X} \boldsymbol\beta + \boldsymbol\varepsilon
\end{displaymath} (4.14)

$\mathbf{y} \in \mathbb{R}^n$ is the vector of responses (dependent variables), the matrix $\mathbf{X} \in \mathbb{R}^{n \times m}$ containing the independent variables (explanatory variables) is called the design matrix, and $\boldsymbol\varepsilon$ is the error vector, whose elements are assumed to be independent and zero-mean, $\E[\boldsymbol\varepsilon]=0$, with covariance matrix $\boldsymbol\Sigma$. The parameter vector $\boldsymbol\beta$ is called the Linear Projection Coefficient or Linear Predictor. The random variable $\mathbf{y}$ therefore consists of a deterministic component and a stochastic component.

The goal is to estimate the parameter vector $\boldsymbol\beta$ that defines the regression hyperplane that best fits the data $(\mathbf{y},\mathbf{X})$.

The value $\boldsymbol\beta$ that minimizes the cost function defined in Equation (4.7), for zero-mean errors with constant variance, coincides with the Best Linear Unbiased Estimator (BLUE), that is, the unbiased linear estimator with minimum variance.

Definizione 11   The Best Linear Unbiased Estimator (BLUE) of a parameter $\boldsymbol\beta$ based on a data set $Y$ is
  1. a linear estimator of the observations $Y$, so that it can be written as $\hat{\boldsymbol\beta} = \mathbf{A} Y$;
  2. unbiased ( $\E[\mathbf{A}Y] = \boldsymbol\beta$);
  3. the estimator with the lowest variance among all possible linear estimators.

The Gauss-Markov theorem shows that the ordinary least squares estimator is the BLUE (Best Linear Unbiased Estimator) when the errors are zero-mean, have constant variance (homoscedastic), and are uncorrelated.

The best least squares estimate $\hat{\boldsymbol\beta}$, which minimizes the sum of squared residuals (assuming that the matrix $\mathbf{X}$ has full column rank), is the solution to the problem

\begin{displaymath}
\hat{\boldsymbol\beta} = \argmin_{\mathbf b} \Vert \mathbf y...
...2 = (\mathbf X^\top \mathbf X)^{-1} \mathbf X^\top \mathbf y .
\end{displaymath} (4.15)

The same result was obtained in Section 1.1 on the pseudoinverse of a matrix: an SVD of the matrix $\mathbf{X}$ also yields the solution that is best in terms of error propagation.

The matrix $\mathbf{P}$, defined as

\begin{displaymath}
\mathbf{P} = \mathbf{X} (\mathbf{X}^{\top} \mathbf{X} )^{-1} \mathbf{X}^{\top}
\end{displaymath} (4.16)

is a projection matrix that maps the response vector $\mathbf{y}$ to its estimate $\hat{\mathbf{y}}$ (the estimate of the noise-free observation):
\begin{displaymath}
\mathbf{P}\mathbf{y}
=
\mathbf{X}\hat{\boldsymbol\beta}
=
\hat{\mathbf{y}}.
\end{displaymath} (4.17)

Because of this property, $\mathbf{P}$ is called the hat matrix.

When the observed samples have nonconstant noise variance (heteroscedastic noise), the Weighted Least Squares estimator is the BLUE.


\begin{displaymath}
w_i = \frac{1}{\sigma_i}
\end{displaymath} (4.18)

where $\sigma_i$ is the standard deviation associated with observation $y_i$ and $w_i>0$ is the corresponding weight.

Placing these weights in a diagonal matrix

\begin{displaymath}
\mathbf W =
\operatorname{diag}(w_1,\ldots,w_n)
\end{displaymath} (4.19)

gives a new linear system in which all observations have unit variance.

The solution can be written as

\begin{displaymath}
\hat{\boldsymbol\beta}
=
(\mathbf W \mathbf X)^+
\mathbf W \mathbf y
\end{displaymath} (4.20)

with

\begin{displaymath}
\mathbf W^\top \mathbf W
=
\boldsymbol\Sigma^{-1}.
\end{displaymath} (4.21)

More generally, when the observed samples have nonconstant variance and are correlated, the best linear BLUE estimate must account for the noise covariance $\boldsymbol\Sigma$:

\begin{displaymath}
\hat{\boldsymbol\beta} = (\mathbf{X}^{\top} \boldsymbol\Sigm...
...hbf{X})^{-1} \mathbf{X}^{\top}\boldsymbol\Sigma^{-1}\mathbf{y}
\end{displaymath} (4.22)

This estimator is called Generalized Least Squares (GLS).

This system minimizes the variance

\begin{displaymath}
Var[\hat{\boldsymbol\beta}_{GLS}] = (\mathbf{X}^{\top} \boldsymbol\Sigma^{-1} \mathbf{X})^{-1}
\end{displaymath} (4.23)

Paolo medici
2026-10-19