Linear least squares

Least squares problem

Given $A \in \R^{m\times n}$ and $\v y\in \R^m$, find $\v c$ that minimises $\|A\v c - \v y\|^2$.

For $m>n$, usually the system $A\v c = \v y$ is overdetermined and there is no solution. We try to find an approximate one.

Application: least square estimator in IB Statistics.

Theorem (normal equations) open_in_new

$\v c^\ast\in \R^m$ is the solution to the least squares problem iff it solves the normal equations $$ \begin{align*} A^TA\v c^\ast = A^T \v y. \end{align*} $$ $A^TA$ is called the Gram matrix, and $\v c^\ast$ is the normal solution.

Moreover if $A$ has full rank, then $\v c^\ast = (A^T A)\inv A^T \v y$ is unique.

Proof

  • This is not suitable for numerical computation:

    1. $A^TA$ may become numerically singular;

    2. $A^TA$ can be dense even when $A$ is sparse;

    3. computing $A^TA$ may lead to a loss of accuracy.

QR factorisation and least squares open_in_new

To solve a least squares problem, let $A=QR$ be the QR factorisation of $A$, and assume $A$ has full rank $n$.

Since orthogonal transformations are length-preserving, $$ \begin{align*} \|A\v c - \v y\| = \|Q^T(A\v c - \v y)\| = \|R\v c - Q^T \v y\| \end{align*} $$ Let $Q^T \v y = \v z$. The form of $R\v c - Q^T \v y$ looks like $$ \begin{align*} \pmat{* & * & \ldots & * \\ &* & \ldots & * \\ &&\ddots & \vdots \\ &&&* \\ 0 & 0 & \ldots & 0 \\ \vdots & \vdots & & \vdots \\ 0 & 0 & \ldots & 0} \pmat{c_1 \\ c_2 \\ \vdots \\ c_n} - \pmat{z_1 \\ z_2 \\ \vdots \\ z_{n} \\ z_{n+1} \\ \vdots \\ z_{m}}. \end{align*} $$ We see that the best $\v c$ we can pick is by solving the non-singular linear system corresponding to the first $n$ equations (using back substitution).

Example (least squares using QR factorisation)