Least Squares and QR
Summary
When
Prerequisites
Orthogonality and Projections, Matrices and Row Reduction, Systems of Linear Equations. Hub: Linear Algebra.
Definition / Statement
Given
If the columns of
A QR factorization of full-column-rank
where
Objects and Dimensions
| Object | Meaning | Dimensions |
|---|---|---|
|
|
data / design matrix |
|
|
|
observations |
|
|
|
least-squares coefficient vector |
|
|
|
thin QR factors |
|
|
|
residual |
|
Notation
| Symbol | Meaning |
|---|---|
|
|
Euclidean norm |
|
|
normal equations |
|
|
thin QR factorization |
Conditions / Assumptions
- Prefer the Euclidean norm (least squares =
). - Unique
when (full column rank), so is invertible. - If columns are dependent, least-squares solutions still exist but are not unique; use pseudoinverse or additional constraints.
- QR assumes full column rank for the thin
to be invertible.
Matrix / Vector Form
Normal equations
Geometry:
Via QR (
(solve by forward/back substitution on the triangular system).
Procedure
- Check whether
is consistent; if not, use least squares. - If using normal equations: form
and , solve the system (watch conditioning). - If using QR: factor
(Gram–Schmidt, Householder, or library routine), solve . - Report residual norm
as a fit diagnostic.
Worked Example
Fit a line
Solve
subtract first equation from second after scaling gives
Model:
Common Mistakes
- Minimizing
instead of . - Using
when is not square. - Ignoring rank deficiency when
is singular. - Forgetting that least squares yields the projection of
onto , not necessarily itself.
Connections
- Related: Orthogonality and Projections, Matrices and Row Reduction, Systems of Linear Equations
- Applied statistics/numerics: Least Squares when present under numerical methods
- Next: applications in regression and numerical linear algebra under Numerical Methods
References
Least squares and QR as in MIT 18.06.[1]
MIT OpenCourseWare, 18.06 Linear Algebra, https://ocw.mit.edu/courses/18-06-linear-algebra-spring-2010/ ↩︎