Proving the method of least squares for $2$ points in $\mathbb R^2$

67 Views Asked by At

How do you show that if you only have two data points $(x_1, y_1)$ and $(x_2,y_2)$ then the best fit line given by the method of least squares is the line through $(x_1,y_1)$ and $(x_2,y_2)$

1

There are 1 best solutions below

0
On

If $x_1 \ne x_2$, then we can construct a line linking them and since the points lie on the line, there is no error.

However, precaution is the case where $x_1 = x_2$. In that case we want to minimize $$(\hat{y}-y_1)^2+(\hat{y}-y_2)^2$$

and the minimal is attain as long as $\hat{y}= \frac{y_1+y_2}2$, that is the best fit line has to passes through $(x_1, \frac{y_1+y_2}2)$.