Least Squares Regression

We first consider the most common case in practical applications, where the noise in the observations is additive white Gaussian noise.

Let

\begin{displaymath}
y = f(\mathbf{x}, \boldsymbol\beta) + \varepsilon
\end{displaymath} (4.3)

be a function, generally nonlinear, of some parameters $\boldsymbol\beta$ and some inputs $\mathbf {x}$, to which additive, zero-mean Gaussian noise with variance $\sigma^2$ is added. To estimate the parameters robustly, the number of input samples $\mathbf{x}=\left\{ \mathbf{x}_1 \ldots \mathbf{x}_n \right\}$ must be large, much larger than the number of parameters.

The function may differ across samples, so that different quantities are observed, each depending on the same parameters $\boldsymbol\beta$. In this case, Equation (4.3) can be generalized as

\begin{displaymath}
y_i = f_i(\boldsymbol\beta) + \varepsilon_i
\end{displaymath} (4.4)

where the subscript $i$ denotes both the type of function and the i-th input sample (which is, in effect, a constant parameter of the function).

We introduce the vector $\mathbf{r}$, defined as

\begin{displaymath}
%r_i = y_i - f_i(\mathbf{x}_i, \boldsymbol\beta)
r_i = y_i - f_i(\boldsymbol\beta)
\end{displaymath} (4.5)

which contains the residual associated with the i-th observation (or i-th function). $r_i$ depends on $\boldsymbol\beta$ in the same way as $f_i$ and has the same derivatives (up to a sign, under this convention).

To obtain a maximum likelihood estimator, the quantity to minimize is the negative log likelihood (Section 2.7) of the function (4.3). In the case of Gaussian noise, the likelihood function is given by

\begin{displaymath}
\mathcal{L}(r_i \vert \boldsymbol\beta, \sigma) = \frac{1}{\sqrt{2 \pi \sigma_i^2}} e^{ - \frac{r_i^2}{2\sigma_i^2} }
\end{displaymath} (4.6)

for independent observations. Applying the definition of negative log likelihood to the likelihood function shows that, in the case of Gaussian noise, the maximum likelihood estimator is the least squares method.

Least squares regression is a standard optimization technique for overdetermined systems. It finds the parameters $\boldsymbol\beta=(\beta_1, \ldots, \beta_m)$ of a function $f(\mathbf{x},\boldsymbol\beta): \mathbb{R}^{m} \mapsto \mathbb{R}^{n}$ that minimize an error $S$, calculated as the sum of the squared errors (Sum Of Squared Errors) of the residuals $r_i$ over a set of $n$ observations $y_1 \ldots y_n$:

\begin{displaymath}
S(\boldsymbol\beta) = SSE(\boldsymbol\beta) = \mathbf{r} \cd...
...= \sum_{i=1}^{n} { \Vert y_i - f_i(\boldsymbol\beta) \Vert^2 }
\end{displaymath} (4.7)

$S(\boldsymbol\beta)$ is defined as the Residual Sum of Squares (RSS), that is, the sum of the squares of the observed residuals.

$S:\mathbb{R}^{m} \mapsto \mathbb{R}$ is a function whose minimum value is sought as the parameters $\boldsymbol\beta \in \mathbb{R}^{m}$ vary:

\begin{displaymath}
\beta^{+} = \argmin_\beta S(\beta)
\end{displaymath} (4.8)

For this reason, it is called the objective function or cost function. A minimum obtained using a procedure such as the one described by Equation (4.8) is called a global minimum.

From a computational standpoint, finding a global minimum is difficult, and techniques are generally used to find only local minima.

Let $S(\boldsymbol\beta)$4.1 be differentiable, that is, let $f$ be differentiable. A necessary condition for $\boldsymbol\beta$ to be a minimum is that, at that point in parameter space, the gradient of $S(\boldsymbol\beta)$ vanishes:

\begin{displaymath}
\frac{\partial S(\boldsymbol\beta)}{\partial \beta_j} = 2 \m...
...i(\boldsymbol\beta)}{\partial \beta_j} = 0 \qquad j=1,\ldots,m
\end{displaymath} (4.9)

A sufficient condition for a stationary point ( $S'(\boldsymbol\beta)=0$) to be a minimum is that $S''(\boldsymbol\beta)$ (the Hessian) be positive definite. Clearly, the existence of a local minimum guarantees only that there is a neighborhood $\delta$ of $\boldsymbol\beta$ such that the function $S(\boldsymbol\beta + \delta) \geq S(\boldsymbol\beta)$.

The discussion so far has assumed that the noise is additive $\varepsilon$ with constant variance across all samples (homoscedasticity). If the measurement noise is still additive, zero-mean Gaussian noise, but its variance is not constant, each observation $y_i$ is an independent random variable with associated variance $\sigma^{2}_i$. Intuitively, the optimal regression in this case should assign greater weight to samples with low variance and less weight to samples with high variance. To achieve this, a normalization is used, similar to the one shown in Section 2.4.1 and arising directly from the likelihood in Equation (4.6). Thus, rather than minimizing the unweighted sum of squared residuals, we minimize the weighted sum of squared residuals:

\begin{displaymath}
\chi^{2} = \sum^{n}_{i=1} \frac{ \Vert r_i \Vert^2 } { \sigma_i^2 }
\end{displaymath} (4.10)

The cost function, calculated as the sum of squares of standardized residuals,4.2 is commonly denoted by $\chi^{2}$. When the variance is constant, the minimum of this cost function coincides with that obtained earlier using least squares. The condition (4.9) for finding the minimum is modified accordingly:
\begin{displaymath}
\sum_{i=1}^{n} \frac{r_i}{\sigma_i^2} \frac{\partial f_i(\boldsymbol\beta)} {\partial \beta_j} = 0 \qquad j=1,\ldots,m
\end{displaymath} (4.11)

More generally, when the observation is affected by Gaussian noise with known covariance matrix $\boldsymbol\Sigma$, the Weighted Sum of Squared Errors (WSSE) can be written as

\begin{displaymath}
\chi^{2} = \mathbf{r}^{\top} \boldsymbol\Sigma^{-1} \mathbf{r}
\end{displaymath} (4.12)

Note that this cost function formulation is equivalent to that in Equation (4.7), except that the Mahalanobis distance (Section 2.4) is used instead of the Euclidean distance.

Any Weighted Least Squares problem can be reduced to an unweighted problem $\boldsymbol\Sigma = I$ by premultiplying the residuals $\mathbf{r}$ (and consequently their derivatives) by a matrix $\mathbf{L}^{\top}$ such that $\boldsymbol\Sigma^{-1} = \mathbf{L} \mathbf{L}^{\top}$, using, for example, a Cholesky decomposition when the matrix is not diagonal.

All these estimators, which account for the observation variance, coincide with the negative log likelihood for the variable $\mathbf{y}$ perturbed by zero-mean Gaussian noise with covariance $\boldsymbol\Sigma$.



Footnotes

...#tex2html_wrap_inline14831#4.1
In the literature, the function $S$ is often scaled by a factor $1/2$ so that the gradient of $S$ is not affected by the factor $2$ and has the same sign as $f$, simplifying the notation.
... residuals,4.2
Under the usual assumptions of independent Gaussian noise, the resulting statistic follows a $\chi^2$ distribution. If the model parameters are estimated from the data, the degrees of freedom of the distribution are reduced to $n-m$.


Subsections
Paolo medici
2026-10-19