16. Projection Matrices and Least Squares
Overview
Projection matrices split a vector into its closest point in a matrix's column space and a perpendicular error, with the projection given by P = A(AᵀA)⁻¹Aᵀ when A has independent columns. A three-point line-fitting example derives the least-squares normal equations and finds the best line y = 2/3 + t/2; the lecture then proves why AᵀA is invertible and previews orthonormal columns.
Key takeaways
- The projection P = A(AᵀA)⁻¹Aᵀ sends any vector b to its nearest point in the column space of A, provided A has independent columns.
- Least squares minimizes ||Ax − b||²; its minimizer satisfies AᵀA x̂ = Aᵀb, known as the normal equations.
- For the points (1,1), (2,2), and (3,2), least squares gives C = 2/3 and D = 1/2, so the fitted line is y = 2/3 + t/2.
- At the least-squares solution, the residual b − Ax̂ is perpendicular to every column of A and therefore belongs to N(Aᵀ).
- If A has independent columns, xᵀAᵀAx = ||Ax||² proves that AᵀA has no nonzero null vectors and is invertible.
- Orthonormal columns make AᵀA the identity matrix, simplifying the algebra of projections and least-squares solutions.
Chapters
- For a matrix A with independent columns, P = A(AᵀA)⁻¹Aᵀ projects b onto the column space of A.
- If b is already in the column space, write b = Ax; applying P returns Ax, which equals b.
- If b is perpendicular to every column of A, then Aᵀb = 0 and Pb = 0.
- The complementary projection I − P gives the perpendicular component, and P plus I − P reconstructs the original vector.
- The data points are (1,1), (2,2), and (3,2), and no single line passes through all three.
- Model the line as y = C + Dt, giving three equations: C + D = 1, C + 2D = 2, and C + 3D = 2.
- Write the system as Ax = b, where A has columns (1,1,1) and (1,2,3), x = (C,D), and b = (1,2,2).
- Because b is not in the column space of A, exact solution is impossible; choose C and D to minimize the error instead.
- The residual vector e = Ax − b records the three vertical differences between observed heights and the fitted line.
- Least squares minimizes the squared length of e, equivalently the sum e₁² + e₂² + e₃².
- The squared-error objective is widely used in regression because it leads to a clean linear system.
- Squaring gives outliers disproportionate influence, so a single unusually large measurement error can substantially change the fitted line.
- The fitted values P₁, P₂, and P₃ form a vector in the column space of A, since they are generated by a line C + Dt.
- The least-squares fit selects the point in that column space closest to b = (1,2,2).
- The data plot shows vertical residuals, while the vector-space plot shows b decomposed into its projection and perpendicular error.
- The fitted parameter vector determines the projection through P = Ax̂.
- The minimizing parameters satisfy AᵀA x̂ = Aᵀb, the normal equations used in least-squares estimation.
- For the example, AᵀA = [[3,6],[6,14]] and Aᵀb = (5,11), giving 3C + 6D = 5 and 6C + 14D = 11.
- Elimination yields D = 1/2 and C = 2/3, so the best-fit line is y = 2/3 + t/2.
- Setting the partial derivatives of the squared-error function with respect to C and D to zero produces the same normal equations.
- Evaluating y = 2/3 + t/2 at t = 1, 2, and 3 gives the fitted vector P = (7/6, 5/3, 13/6).
- Using e = b − P gives e = (−1/6, 1/3, −1/6), and b = P + e.
- The dot product Pᵀe is zero, confirming that the residual is perpendicular to the projection.
- The residual is also perpendicular to both columns of A: (1,1,1) and (1,2,3), so it lies in the null space of Aᵀ.
- The fitted vector P lies in the column space of A, while the residual e lies in its perpendicular complement, N(Aᵀ).
- In the data plot, the residuals are vertical differences; in the vector-space picture, they form one perpendicular error vector.
- The best-fit parameters C and D specify the combination of A's two columns that produces P.
- For line-fitting homework, solve the normal equations for x̂ and then calculate the fitted values with P = Ax̂.
- To establish invertibility, assume AᵀAx = 0 and show that the only possible x is the zero vector.
- Left-multiplying by xᵀ gives xᵀAᵀAx = (Ax)ᵀ(Ax) = 0, the squared length of Ax.
- A vector with squared length zero must be zero, so Ax = 0.
- Independent columns imply that Ax = 0 has only the solution x = 0; therefore AᵀA has a trivial null space and is invertible.
- Perpendicular nonzero columns are independent; requiring each column to have unit length gives an orthonormal set.
- The standard basis vectors in three dimensions are orthonormal, and a matrix formed from them has AᵀA = I.
- In two dimensions, (cos θ, sin θ) and (−sin θ, cos θ) are unit vectors with zero dot product.
- Orthonormal vectors simplify projection calculations and form the starting point for the next lecture's methods for constructing orthonormal bases.
Transcript excerpt
0:07 OK. Here's lecture sixteen and if you remember I ended up the last lecture with this formula for what I called a projection matrix. And maybe I could just recap for a minute what is that magic formula doing? For example, it's supposed to be -- it's supposed to produce a projection, if I multiply by a b, so I take P times b, I'm supposed to project that vector b to the nearest point in the column space. OK.
0:54 Can I just -- one way to recap is to take the two extreme cases. Suppose a vector b is in the column space? Then what do I get when I apply the projection P? So I'm projecting into the column space but I'm starting with a vector in this case that's already in the column space, so of course when I project it I get B again, right. And I want to show you how that comes out of this formula. Let me do the other extreme. Suppose that vector is perpendicular to the column space. So imagine this column space as a plane and imagine b as sticking straight up perpendicular to it.
1:43 What's the nearest point in the column space to b in that case? So what's the projection onto the plane, the nearest point in the plane, if the vector b that I'm looking at is -- got no component in the column space, it's sticking completely -- ninety degrees with it, then Pb should be zero, right. So those are the two extreme cases. The average vector has a component P in the column space and a component perpendicular to it, and what the projection does is it kills this part and it preserves this part. OK.
2:30 Can we just see why that's true? Just -- that formula ought to work.
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, MIT OpenCourseWare.