Before you readIf no line goes through every point, what makes one line the best fit?
Watch: Linear Regression, Clearly Explained!!! · StatQuest with Josh Starmer
Fit a line with intercept and slope At each input the residual is the observed minus the line’s prediction.
The design matrix has one row per observation. The column of ones adds to every prediction. With and the vector of observed outputs, the predictions are Least squares minimises the sum of squared residuals:
The best predictions are the projection of onto the column space of The residual is orthogonal to each column, so This gives the normal equations:
If the columns of are independent, is invertible and With independent Gaussian noise of mean zero and common variance, least squares is also the maximum-likelihood fit.
Sum of squared errors = 14.84Minimum = 3.77
Recall
Why does the design matrix have a column of ones?Recall
What does least squares minimise?Recall
Give the normal equations for least squares.Exercise
Use the normal equations to fit a line to and Give and in that order.Exercise
Find the that minimises when the observed values are and