Approximate the point by a multiple . Ordinary distance picks . If an error in the first coordinate should cost twice as much as an error in the second, the best multiple changes, although neither the target nor the line has moved. Weighted least squares replaces the dot product by a weighted inner product and applies the projection theorem there, which leads to the weighted normal equations and to a clear line between a unique fitted vector and coefficients that may not be unique. Throughout, is or , is the conjugate transpose, inner products are conjugate-linear in the first argument, and a tuple such as stands for a column vector.
Key terms
Positive definite weight matrix
Definition A matrix is a positive definite weight matrix if it is Hermitian, , and
Over this means that is real symmetric with for . A diagonal matrix qualifies exactly when its diagonal entries are positive real numbers. Such a is invertible, because gives and hence . A Hermitian matrix with for some nonzero , such as a singular positive semidefinite matrix or an indefinite one, is not a weight in this sense. Multiplying by a constant multiplies every weighted squared error by , so it does not change which fit is best.
In plain words The weight matrix declares how much each error vector costs, and positive definiteness says that every nonzero error costs something.
Example The Hermitian matrix with rows and is positive definite. Expanding shows
which is positive unless . At the value is . The real symmetric matrix with rows and is not a weight, since gives . Fitting the target by multiples with this matrix gives the would-be squared error , which decreases without bound, so no best fit exists. The matrix is not a weight either, since it gives the nonzero vector zero cost.
Weighted inner product
Definition Let be a positive definite weight matrix. The weighted inner product on and its norm are
It is linear in , conjugate symmetric because , and positive definite because is, so it is an inner product. Conversely, every inner product on has this form, with the Gram matrix of the standard basis. For a diagonal weight the squared length is
In plain words The weighted inner product measures lengths and angles with the costs built in. In the real plane its unit circle is an ellipse.
Example On with , the vector has weighted length , the same as , and the unit circle becomes the ellipse . The vectors and are orthogonal in this inner product, since , although their dot product is .
Weighted orthogonality
Definition Let be a positive definite weight matrix. Vectors are -orthogonal if . For , and a coefficient vector , the residual is -orthogonal to the column space of exactly when
Indeed for every . If , this is zero for every . If it is zero for every , the choice gives the ordinary squared norm , so . By the projection theorem in the inner product , the vector is the point of the column space closest to in the weighted norm exactly when this condition holds.
In plain words Perpendicular now means perpendicular for the weighted inner product. A residual can look slanted in an ordinary drawing and still be orthogonal in the weighted geometry.
Example Fit by with . At the residual is , and
so is -orthogonal to the line, even though its dot product with is . The ordinary fit has residual , which is orthogonal for the dot product but has weighted inner product with . Its weighted squared error is , larger than the of the weighted fit.
Weighted normal equations
Definition Let and , and let be a positive definite weight matrix. A coefficient vector minimizes the weighted squared error exactly when it solves the weighted normal equations
They are the orthogonality condition of the previous card, rearranged. They always have a solution, because the projection theorem supplies a closest point of the column space, and every with solves them. The matrix is Hermitian with . It is positive definite, hence invertible, exactly when the columns of are linearly independent, and then
With these are the ordinary normal equations, and over they read . The formula describes the answer. Forming and inverting is not always the most accurate way to compute it.
In plain words Each column gives one equation, which says that the residual is orthogonal to that column in the weighted inner product. Solving them gives the coefficients of the best fit.
Example Fit a line to the data points , and with weights , and , so that the last point counts a third as much as each of the others. Here and
so the weighted normal equations are
with solution . The fitted values are , and the residual satisfies , since and . The unweighted fit is . Giving the third point less weight produces a flatter line that stays closer to the first two points.
Uniqueness of the fitted vector
Definition In the setting of the weighted normal equations, the fitted vector is the same for every minimizer . It is the orthogonal projection of onto the column space of in the inner product , and it depends only on , and that column space. If is one minimizer, the set of all minimizers is
Two minimizers give the same unique closest point, so their difference lies in , and adding a vector of does not change . The coefficient vector is therefore unique exactly when , that is, when the columns of are linearly independent.
In plain words The best fitted output is always unique. Its recipe in terms of the columns is unique only when no column is a combination of the others.
Example Take both columns of equal to , with and . The weighted normal equations
say only that . The coefficient vectors , and all solve them. They differ by multiples of , which spans , and each one gives the same fitted vector .
Inner product from sample values
Definition Let be distinct real nodes and positive weights. On , the polynomials of degree at most with coefficients in , set
This is linear in and conjugate symmetric. It is positive definite, and so an inner product, exactly when . If , then forces at or more points, so . If , the nonzero polynomial lies in and has norm , so the formula gives only a seminorm. With the sample vector and the formula reads . Projecting onto a subspace in this inner product is therefore weighted least squares, with and with the columns forming .
In plain words Two polynomials are compared only through their weighted values at the chosen nodes. There must be enough nodes to tell any two different polynomials apart.
Example The line fit in the normal equations card is a projection of this kind. On with nodes and weights , the data are the samples of , and the projection of onto is . With only the nodes and and weights , the formula is an inner product on but not on , because vanishes at both nodes. The polynomials and then have the same samples . A fit from to these samples has a unique fitted sample vector, but every polynomial produces it.
Check yourself
- Fit by with the weight . Find , the residual and the weighted squared error, and check that the residual is -orthogonal to .
Show the answer
The normal equation is the scalar equation , so . The fitted point is and the residual is . Its weighted inner product with is , and the weighted squared error is
The heavy weight now sits on the second coordinate, so the fit moves toward the second coordinate of , which is .
- Is an inner product on the real polynomials ? On ?
Show the answer
On it is. The formula is symmetric and bilinear, and a polynomial of degree at most that vanishes at the two distinct nodes and is the zero polynomial, so for . On it is not, because is nonzero and has . Positive weights alone are not enough. The number of distinct nodes must be at least .
- Let and , and let have columns , and . Find all minimizers of the weighted squared error, the fitted vector and the residual, and check weighted orthogonality.
Show the answer
The third column is the sum of the first two, so the columns are dependent and is spanned by . The weighted normal equations are
The third equation is the sum of the first two, which say and . So the minimizers are for every scalar , and all of them give the fitted vector . The residual satisfies
so is also -orthogonal to the third column, which is the sum of the first two. The weighted squared error is . The ordinary dot product of with is , so the residual is orthogonal only in the weighted sense.