According to the method of least squares, the line of best fit is the one that minimizes the squares of the differences between the data points' observed (experimental) y-values and their expected (theoretical) y-values. This line is known as the least squares regression line.
To calculate the sum of squares of a line, find the expected y value of each point by substituting the corresponding x value into the linear regression equation. Then, find the difference between the observed y value and the expected y value for each point. Finally, square the difference between the observed and expected y value for each point, and then sum those values. The lines that were shown on the previous page are calculated below:
Point | x | Observed y | Expected | Difference y- | Difference Squared (y-)2 |
| | | A | B | C | A | B | C | A | B | C |
1 | 10 | 5.0 | 8.0 | 10.0 | 12.0 | -3.0 | -5.0 | -7.0 | 9.0 | 25.0 | 49.0 |
2 | 18 | 24 | 14.4 | 18.0 | 22.0 | 9.6 | 6.0 | 2.0 | 92.16 | 36.00 | 4.00 |
3 | 38 | 27.5 | 30.4 | 38.0 | 45.0 | -2.9 | -10.5 | -17.5 | 8.41 | 110.25 | 306.25 |
4 | 50 | 60.0 | 40.0 | 50.0 | 60.0 | 20.0 | 10.0 | 0.0 | 400.00 | 100.00 | 0.00 |
5 | 63 | 50.0 | 48.0 | 63.0 | 74.0 | 2.0 | -13.0 | -24.0 | 4.00 | 169.00 | 576.00 |
The total sum of squares for line A = 513.57; line B = 440.25; line C = 935.25. As said before, the line that minimizes this value is the line of best fit according to the least squares method. Therefore, line B is the best fit of these 3 lines.