| Bivariate Linear Regression: Least Squares Method | ||||||||||||||||||
| Recall from high school geometry the definition of a straight line | ||||||||||||||||||
| Y=a+bX | a=the Y interceptof the X axis | |||||||||||||||||
| b=the slope of the line | ||||||||||||||||||
| Switched for plotting | ||||||||||||||||||
| Y | X | X | Y | |||||||||||||||
| Dealer | Sales (000) | Permits | Permits | Sales (000) | ||||||||||||||
| 1 | 77 | 86 | 86 | 77 | ||||||||||||||
| 2 | 79 | 93 | 93 | 79 | ||||||||||||||
| 3 | 80 | 95 | 95 | 80 | ||||||||||||||
| 4 | 83 | 104 | 104 | 83 | ||||||||||||||
| 5 | 101 | 139 | 139 | 101 | ||||||||||||||
| 6 | 117 | 180 | 180 | 117 | ||||||||||||||
| 7 | 129 | 165 | 165 | 129 | ||||||||||||||
| 8 | 120 | 147 | 147 | 120 | ||||||||||||||
| 9 | 97 | 119 | 119 | 97 | ||||||||||||||
| 10 | 106 | 132 | 132 | 106 | ||||||||||||||
| 11 | 99 | 126 | 126 | 99 | ||||||||||||||
| 12 | 121 | 156 | 156 | 121 | ||||||||||||||
| 13 | 103 | 129 | 129 | 103 | ||||||||||||||
| 14 | 86 | 96 | 96 | 86 | ||||||||||||||
| 15 | 99 | 108 | 108 | 99 | ||||||||||||||
|
Correlation | Permits | Sales (000) | |||||||||||||||
| Permits | 1 | |||||||||||||||||
| Sales (000) | 0.9356056 | 1 | ||||||||||||||||
| Step 1: Estimate Beta - solve for Beta hat | Y | Y square | X | X square | XY | |||||||||||||
|
Dealer | Sales (000) | Permits | |||||||||||||||
| 1 | 77 | 5929 | 86 | 7396 | 6622 | |||||||||||||
| 2 | 79 | 6241 | 93 | 8649 | 7347 | |||||||||||||
| 3 | 80 | 6400 | 95 | 9025 | 7600 | |||||||||||||
| 4 | 83 | 6889 | 104 | 10816 | 8632 | |||||||||||||
| 5 | 101 | 10201 | 139 | 19321 | 14039 | |||||||||||||
| 6 | 117 | 13689 | 180 | 32400 | 21060 | |||||||||||||
| 7 | 129 | 16641 | 165 | 27225 | 21285 | |||||||||||||
| 8 | 120 | 14400 | 147 | 21609 | 17640 | |||||||||||||
| 9 | 97 | 9409 | 119 | 14161 | 11543 | |||||||||||||
| beta hat = | 15(193,345)-((1,497)*(1,875) | 10 | 106 | 11236 | 132 | 17424 | 13992 | |||||||||||
| 15(245,759)-(1875)^2 | 11 | 99 | 9801 | 126 | 15876 | 12474 | ||||||||||||
| 12 | 121 | 14641 | 156 | 24336 | 18876 | |||||||||||||
| beta hat = | 93300 | = | 0.546 | 13 | 103 | 10609 | 129 | 16641 | 13287 | |||||||||
| 170760 | 14 | 86 | 7396 | 96 | 9216 | 8256 | ||||||||||||
| 15 | 99 | 9801 | 108 | 11664 | 10692 | |||||||||||||
| Step 2: Estimate the intercept - solve for a hat | Sums | 1497 | 153283 | 1875 | 245759 | 193345 | ||||||||||||
|
Y-Bar | 99.8 | X-bar | 125 | ||||||||||||||
| a hat = | 99.8-0.54638(125) | = | 31.5 | |||||||||||||||
| Step 3: Estimate Y based on the regression, i.e. find Y hat | ||||||||||||||||||
| Y hat = | 31.5+(0.546)X | |||||||||||||||||
| We can now generate the line of best fit or the trend line. | ||||||||||||||||||
| Plot Y hat (or the best linear estimate of Y) for each X. | ||||||||||||||||||
| Actually, pick a low and a high X plot those and draw a straight line | ||||||||||||||||||
| Y | X | deviation | Explained | error | Error | |||||||||||||
| Dealer | Sales (000) | Permits | Y Hat | yhat-ybar | Variance | y-yhat | Variance | |||||||||||
| 1 | 77 | 86 | 78.46 | -21.344 | 455.56634 | -1.456 | 2.119936 | |||||||||||
| 2 | 79 | 93 | 82.28 | -17.522 | 307.02048 | -3.278 | 10.745284 | |||||||||||
| 3 | 80 | 95 | 83.37 | -16.43 | 269.9449 | -3.37 | 11.3569 | |||||||||||
| 4 | 83 | 104 | 88.28 | -11.516 | 132.61826 | -5.284 | 27.920656 | |||||||||||
| 5 | 101 | 139 | 107.39 | 7.594 | 57.668836 | -6.394 | 40.883236 | |||||||||||
| 6 | 117 | 180 | 129.78 | 29.98 | 898.8004 | -12.78 | 163.3284 | |||||||||||
| 7 | 129 | 165 | 121.59 | 21.79 | 474.8041 | 7.41 | 54.9081 | |||||||||||
| 8 | 120 | 147 | 111.76 | 11.962 | 143.08944 | 8.238 | 67.864644 | |||||||||||
| 9 | 97 | 119 | 96.47 | -3.326 | 11.062276 | 0.526 | 0.276676 | |||||||||||
| 10 | 106 | 132 | 103.57 | 3.772 | 14.227984 | 2.428 | 5.895184 | |||||||||||
| 11 | 99 | 126 | 100.30 | 0.496 | 0.246016 | -1.296 | 1.679616 | |||||||||||
| 12 | 121 | 156 | 116.68 | 16.876 | 284.79938 | 4.324 | 18.696976 | |||||||||||
| 13 | 103 | 129 | 101.93 | 2.134 | 4.553956 | 1.066 | 1.136356 | |||||||||||
| 14 | 86 | 96 | 83.92 | -15.884 | 252.30146 | 2.084 | 4.343056 | |||||||||||
| 15 | 99 | 108 | 90.47 | -9.332 | 87.086224 | 8.532 | 72.795024 | |||||||||||
| Y-bar | 99.8 | Sum of Squares | 3393.79 | 483.95 | ||||||||||||||
| Step 4: F test for Statistically Significant Differences | ||||||||||||||||||
| Total Deviation = Devaition explained by the regression + Deviation not explained (residual error) | ||||||||||||||||||
| Y - Ybar = (Y hat - Y bar)+(Y-Y hat) | ||||||||||||||||||
| Total Variation = Variation explained by the regression + Variation not explained (residual error) | ||||||||||||||||||
|
||||||||||||||||||
| Sources of Variance | Sum of Squares |
df
|
Mean Square
|
F-value | p | |||||||||||||
| Explained | 3393.79 |
(K-1) = 1
|
3393.79 | 91.1649 | < .01 | |||||||||||||
| Error | 483.95 |
(n-k) = 13
|
37.2269 | |||||||||||||||
| Total | 3877.74 | |||||||||||||||||
| Step 5: Calculate the percentage of variance accounted for or r-square | ||||||||||||||||||
| r-square = 1- (SS-unexplained/SS-total) | ||||||||||||||||||
| r-square = | 0.8752 | |||||||||||||||||