Chapter 11: Problem 85
Least Squares Regression Line Given \(n\) points \(\left(x_{1}, y_{1}\right),\) \(\left(x_{2}, y_{2}\right), \ldots,\left(x_{n}, y_{n}\right),\) where the \(x_{i}\) 's are not all alike, the least squares regression line is the line \(y=a x+b\) that minimizes the sum of the squares of the vertical distances from the points to the line. Use calculus to show that $$ S(a, b)=\sum_{i=1}^{n}\left(a x_{i}+b-y_{i}\right)^{2} $$ is minimum when \(a\) and \(b\) are the unique solutions to the system of equations $$ \begin{aligned} n b+\left(\sum_{i=1}^{n} x_{i}\right) a &=\sum_{i=1}^{n} y_{i} \\ \left(\sum_{i=1}^{n} x_{i}\right) b+\left(\sum_{i=1}^{n} x_{i}^{2}\right) a &=\sum_{i=1}^{n} x_{i} y_{i} \end{aligned} $$