Fitting regression
For a full-column-rank design X=QR, least-squares coefficients solve R beta = Q-transpose y.
On this page 8 sections
01A full-rank design has a unique least-squares coefficient vector#
A full-rank design has a unique least-squares coefficient vector. Use its supplied thin QR factorization: , with orthonormal columns in and nonzero diagonal entries in .
To compute , dot each column of with . Let have rows ; ; ; and .
The first dot is . The second is . Thus . Next solve .
Full rank. rows ; ; ; ; . rows ; . Solve .
Show answer and explanation
; .
02Suppose R has rows (2,2),(0,2) and d=(6,4)#
Suppose has rows and . The last equation is , so the slope is .
Use that slope in the first equation: . Subtract , then divide by . The intercept is , so the full result is .
rows ; , . Diagonal-only answer . Repair .
Show answer and explanation
; , .
03A closer look#
Dividing each right-hand side by the matching diagonal is insufficient when has an off-diagonal term. Back substitution first removes the already-solved coefficient’s contribution.
Report coefficients in the design’s column order. A small training residual describes the fit to these observations; it does not establish accuracy on new observations.
Columns: intercept, x. rows ; , . Give coefficients.
Show answer and explanation
; , .
Compute Q-transpose y, solve the triangular system backward, and report every coefficient in the design’s column order.
- Obtain coefficients for a full-rank regression using a supplied QR least-squares procedure.
Further questions
What do observation-minus-prediction residuals tell us about this fit?
Sources & further reading
- [1]