2. Fitting a Linear Model to Data
Sign In
Make a table of values to determine the residuals.
Sum for y=2x+3.1: 18.44
Sum for y=2x+3.5: 21
Better Line of Fit: y=2x+3.1
We have been given the following table.
| x | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| y | 2 | 9 | 7 | 12 |
| Lines of Fit | |
|---|---|
| y=2x+3.1 | y=2x+3.5 |
In order to determine which line of fit is better, let's calculate the residuals for both lines.
| x | y (Actual) | y Predicted by y=2x+3.1 | Residual for y=2x+3.1 | y Predicted by y=2x+3.5 | Residual for y=2x+3.5 |
|---|---|---|---|---|---|
| 1 | 2 | y=2( 1)+3.1= 5.1 | 2- 5.1= -3.1 | y=2( 1)+3.5= 5.5 | 2- 5.5= -3.5 |
| 2 | 9 | y=2( 2)+3.1= 7.1 | 9- 7.1= 1.9 | y=2( 2)+3.5= 7.5 | 9- 7.5= 1.5 |
| 3 | 7 | y=2( 3)+3.1= 9.1 | 7- 9.1= -2.1 | y=2( 3)+3.5= 9.5 | 7- 9.5= -2.5 |
| 4 | 12 | y=2( 4)+3.1= 11.1 | 12- 11.1= 0.9 | y=2( 4)+3.5= 11.5 | 12- 11.5= 0.5 |