This page shows how to calculate the regression line for our example using the least amount of calculation.
First form the following table:
x | x^2 | y | y^2 | x y |
5 | 25 | 6 | 36 | 30 |
1 | 1 | 0 | 0 | 0 |
10 | 100 | 8 | 64 | 80 |
4 | 16 | 6 | 36 | 24 |
20 | 142 | 20 | 136 | 134 |
[The last row represents the column totals.] We see that xmean = 20 / 4 = 5.0, and ymean = 20 / 4 = 5.0.
The variance of x (= (the standard deviation of x)^2) is Sx^2 = (sum x^2 - n xmean^2) / (n - 1) or
Sx^2 = (142 - 4 * 5.0^2) / (4 - 1) = 42 / 3 = 14.
The covariance is Sxy = ( sum xy - n xmean ymean) / (n - 1) or
Sxy = (134 - 4 * 5.0 * 5.0 ) / ( n - 1) = 34 / 3 = 11.33.
The slope of the regression line is b1 = Sxy / Sx^2, or b1 = 11.33 / 14 = 0.809.
The intercept is b0 = ymean - b1 xmean, or b0 = 5.00 - .809 x 5.00 = 0.95
Thus the equation of the least squares line is yhat = 0.95 + 0.809 x.