Least Squares
4.1 Least Squares and the Normal Equations
1) Inconsistent System
Inconsistent System: A system
that has no exact solution.
Inconsistent systems commonly occur when the number of equations exceeds the number of unknowns or when measured data contains errors.
2) Overdetermined System
Overdetermined System: A system with more equations than unknowns.
For
the system is overdetermined when
An overdetermined system generally has no exact solution.
3) Euclidean Norm
Euclidean Norm: The length of a vector.
For
the Euclidean norm, or -norm, is
4) Residual
Residual: The difference between the observed vector and the vector predicted by an approximation .
An exact solution has
5) Least-Squares Solution
Least-Squares Solution: A vector that minimizes the Euclidean norm of the residual.
Equivalently, it minimizes
6) Column Space
Column Space: The set of all linear combinations of the columns of .
The least-squares approximation is the point in closest to .
7) Orthogonality Condition
At the least-squares solution, the residual is orthogonal to every column of .
Equivalently,
Thus, is the orthogonal projection of onto .
8) Normal Equations
Normal Equations: The system obtained from the least-squares orthogonality condition.
If the columns of are linearly independent, then is nonsingular and the least-squares solution is unique.
Formally,
The inverse should not normally be computed explicitly.
9) Squared Error
Squared Error: The sum of the squared residual components.
10) Root Mean Squared Error
Root Mean Squared Error: The square root of the average squared residual.
Equivalently,
A smaller RMSE indicates a better fit to the data.
11) Least-Squares Data Fitting
Given data points
choose a model
If the model is linear in its parameters, substitution of the data produces a matrix problem
The optimal parameter vector minimizes
12) Linear Regression
Linear Regression: Least-squares fitting using the model
The design matrix is
and the parameter vector is
13) Polynomial Regression
Polynomial Regression: Least-squares fitting using a polynomial model.
For a degree- model,
The design matrix is
Polynomial regression approximates the data and does not generally pass exactly through every point.
14) Conditioning of the Normal Equations
The condition number of the normal-equation matrix satisfies approximately
when the condition number is based on the -norm.
Forming can therefore square the original conditioning problem.
The normal equations are simple but may be inaccurate for ill-conditioned problems.
4.2 A Survey of Models
1) Model Linear in Parameters
Model Linear in Parameters: A model that can be written as
where the basis functions are known and the parameters appear linearly.
The design matrix entries are
Such a model can be fitted using linear least squares even when the basis functions themselves are nonlinear in .
2) Periodic Model
Periodic Model: A model constructed using sine and cosine functions.
A basic periodic model with period is
Additional harmonics can be included:
This model is nonlinear in but linear in its parameters.
3) Orthogonal Basis Functions
Orthogonal Basis Functions: Functions whose sampled column vectors have zero dot products.
If the columns and satisfy
then is diagonal.
Orthogonal basis functions simplify the least-squares computation and improve numerical conditioning.
4) Data Linearization
Data Linearization: Transforming a nonlinear model into a model that is linear in new parameters.
This allows the transformed problem to be solved using linear least squares.
Linearization changes the error being minimized and does not generally produce the same solution as nonlinear least squares in the original variables.
5) Exponential Model
An exponential model has the form
Taking logarithms gives
Define
The transformed model is
After fitting and ,
This transformation requires
6) Power Model
A power model has the form
Taking logarithms gives
Define
Then
This transformation requires positive and .
7) Original-Space Error
For an exponential model, the original least-squares objective is
8) Transformed-Space Error
The log-linearized objective is
These objectives are different and generally produce different parameter values.
The appropriate model depends on whether absolute errors or relative/logarithmic errors are more meaningful.
4.3 QR Factorization
1) Dot Product
For vectors , the dot product is
2) Orthogonal Vectors
Orthogonal Vectors: Vectors whose dot product is zero.
3) Orthonormal Vectors
Orthonormal Vectors: Unit vectors that are mutually orthogonal.
4) Orthogonal Matrix
Orthogonal Matrix: A square matrix satisfying
Therefore,
Orthogonal matrices preserve Euclidean norms:
They also preserve dot products and angles.
5) Reduced QR Factorization
For
with linearly independent columns, the reduced QR factorization is
where:
- has orthonormal columns.
- is upper triangular.
Thus,
6) Full QR Factorization
The full QR factorization is
where:
- is orthogonal.
- is upper trapezoidal.
The first columns of span .
7) Projection onto a Vector
The projection of onto a unit vector is
For a nonunit vector ,
8) Classical Gram-Schmidt Orthogonalization
Classical Gram-Schmidt: A method that converts linearly independent vectors into orthonormal vectors.
Given the columns
calculate
and normalize:
The entries of are
and
9) Modified Gram-Schmidt
Modified Gram-Schmidt: A numerically improved version of Gram-Schmidt that subtracts projections one at a time.
Start with
Then, for ,
and
Finally,
and
Modified Gram-Schmidt is mathematically equivalent to classical Gram-Schmidt in exact arithmetic but usually more accurate in floating-point arithmetic.
10) Least Squares by Reduced QR
Given
the least-squares problem becomes
Because has orthonormal columns, the solution satisfies
Since is upper triangular, is found using back substitution.
This method avoids forming .
11) Least Squares by Full QR
For the full factorization, partition
and
Then
The least-squares solution satisfies
The minimum residual norm is
12) Householder Reflector
Householder Reflector: An orthogonal matrix that reflects vectors across a hyperplane.
For a nonzero vector ,
It satisfies
and
13) Constructing a Householder Reflector
To transform a vector into a multiple of the first coordinate vector, choose
and
Then
satisfies
The sign is chosen to reduce cancellation.
14) Householder QR Factorization
Householder reflectors successively introduce zeros below the diagonal:
Because each reflector is orthogonal and symmetric,
Thus,
Householder QR is generally more stable and efficient than Gram-Schmidt for dense matrices.
15) QR versus Normal Equations
| Method | Main Equation | Conditioning | Stability |
|---|---|---|---|
| Normal equations | Squares | Lower | |
| QR factorization | Uses directly | Higher |
QR factorization is preferred when numerical accuracy matters.
4.4 Generalized Minimum Residual Method
1) Krylov Subspace
Krylov Subspace: The vector space generated by repeated multiplication of a residual by .
Given
the order- Krylov subspace is
2) GMRES
Generalized Minimum Residual Method: An iterative method for solving large, sparse, nonsymmetric systems.
At step , GMRES selects
that minimizes
3) Arnoldi Process
Arnoldi Process: An orthogonalization process that constructs an orthonormal basis of a Krylov subspace.
Starting with
calculate
For ,
and
Then,
and
4) Arnoldi Relation
Let
The Arnoldi process produces
where is an upper-Hessenberg matrix.
5) Upper-Hessenberg Matrix
Upper-Hessenberg Matrix: A matrix whose entries below the first subdiagonal are zero.
6) GMRES Least-Squares Problem
Write the correction as
GMRES determines by minimizing
The updated approximation is
The residual norm decreases monotonically as the Krylov subspace grows.
7) Restarted GMRES
Restarted GMRES: A memory-limited version of GMRES that restarts after a fixed number of iterations.
After iterations:
- Keep the current approximation .
- Discard the existing Krylov basis.
- Restart GMRES using as the new initial guess.
Restarting reduces memory use but may slow or prevent convergence.
8) Preconditioned GMRES
Choose a preconditioner and solve
The initial residual becomes
The Arnoldi multiplication becomes
The inverse should not be formed explicitly; instead, systems involving should be solved.
4.5 Nonlinear Least Squares
1) Nonlinear Residual Function
Let
be a nonlinear residual vector.
The nonlinear least-squares problem is
2) Least-Squares Objective Function
Define
The factor simplifies derivative formulas.
3) Residual Jacobian
Residual Jacobian: The matrix of partial derivatives of the residual functions.
4) Gradient of the Squared Error
The gradient of the objective is
A stationary point satisfies
5) Exact Hessian
The Hessian of is
Gauss-Newton neglects the second term.
6) Gauss-Newton Method
Gauss-Newton Method: An iterative method for nonlinear least squares based on a local linear approximation of the residual.
At iteration , set
Solve
and update
Equivalently, solve the linear least-squares problem
Using QR to solve this subproblem is generally more stable than forming .
7) Gauss-Newton Convergence
Gauss-Newton works best when:
- The initial guess is close to a solution.
- The Jacobian has full column rank.
- The residual at the solution is small.
- The model is not severely nonlinear near the solution.
It may converge to a local minimum, a maximum, or another stationary point.
8) Nonlinear Parameter Model
Given data points
and a nonlinear model
define the residuals
The parameter vector is determined by minimizing
The residual Jacobian entries are
9) Regularization
Regularization: The addition of a stabilizing term to an ill-conditioned problem.
Regularization reduces sensitivity and controls excessively large parameter changes.
10) Levenberg-Marquardt Method
Levenberg-Marquardt Method: A regularized Gauss-Newton method for nonlinear least squares.
At iteration , let
Solve
and update
The parameter controls the amount of regularization.
11) Effect of the Damping Parameter
When
Levenberg-Marquardt becomes the Gauss-Newton Method.
For a large , the step behaves more like a scaled steepest-descent step.
Increasing generally:
- Improves conditioning.
- Produces smaller, more conservative steps.
- Expands the set of usable initial guesses.
Decreasing generally:
- Produces faster Gauss-Newton-like convergence near a solution.
- Reduces the effect of regularization.
12) Adaptive Damping
A common adaptive strategy is:
- Accept the step and decrease when the residual decreases.
- Reject the step and increase when the residual increases.
This balances convergence speed and robustness.
Comparison of Least-Squares Methods
| Method | Problem Type | Main Equation | Main Property |
|---|---|---|---|
| Normal Equations | Linear | Simple but squares conditioning | |
| QR Factorization | Linear | More stable | |
| GMRES | Large sparse linear system | Krylov least-squares problem | Handles nonsymmetric matrices |
| Gauss-Newton | Nonlinear least squares | Fast near a good solution | |
| Levenberg-Marquardt | Nonlinear least squares | Regularized Gauss-Newton system | More robust under poor conditioning |
Essential Concepts
- Inconsistent System: A system with no exact solution.
- Overdetermined System: Has more equations than unknowns.
- Residual: The vector .
- Least-Squares Solution: Minimizes .
- Orthogonality Condition: The residual satisfies .
- Normal Equations: The system .
- Squared Error: The value .
- RMSE: The residual norm divided by .
- Design Matrix: Contains the model basis functions evaluated at the data points.
- Linear Regression: Fits a straight line using least squares.
- Polynomial Regression: Fits a polynomial without requiring exact interpolation.
- Data Linearization: Transforms a nonlinear model into a linear parameter model.
- Orthogonal Matrix: Satisfies .
- QR Factorization: Expresses as an orthogonal factor times an upper-triangular factor.
- Gram-Schmidt: Constructs orthonormal vectors from linearly independent vectors.
- Modified Gram-Schmidt: Improves floating-point accuracy.
- Householder Reflector: Stably introduces zeros using an orthogonal reflection.
- Krylov Subspace: Spans repeated matrix applications to a residual.
- GMRES: Minimizes the residual over an expanding Krylov subspace.
- Residual Jacobian: Contains derivatives of nonlinear residual functions.
- Gauss-Newton Method: Applies linear least squares to a local residual approximation.
- Regularization: Stabilizes an ill-conditioned minimization problem.
- Levenberg-Marquardt Method: Combines Gauss-Newton with damping.