How do you find the equation for a best fit line that passes a specific point?

63 Views Asked by At

All I have been given are a set of x and y coordinates, and another point that the best-fit line should pass through (not the origin). I know how to use linear regression to find the slope and intercept of the regular best-fit line, but I don't know how to force the line through a specific point. Any help would be appreciated.

2

There are 2 best solutions below

0
On

Let $(x_0, y_0)$ be the point that the regression line, $\hat{y} = \beta x + \beta_0$, must pass through. Since we require the estimated slope and intercept to satisfy $y_0 = \beta x_0 + \beta_0$, we can rewrite $\beta_0 = y_0 - \beta x_0$, which now allows us to consider the problem of estimating the regression as having only one parameter: either $\beta_0$ or $\beta$ (you can take your pick and express the other parameter in terms of the one you selected). Now, I would encourage you to rewrite the regression in terms of only one of the parameters ($\beta_0$ or $\beta$) along with $x_0$ and $y_0$. Hopefully it shouldn't be too difficult to do the rest from there.

2
On

If you were forcing the line through $(0,0)$ then the line would be of the form $\hat y = \beta x$ and to minimise the sum of squares of residuals you would use $\beta = \dfrac{\sum x_iy_i}{\sum x_i^2}.$

But here you want to force the line to pass through $(x_0,y_0)$, a change of co-ordinates, so the line would be of the form $(\hat y -y_0)= \beta (x-x_0)$, i.e. $$\hat y= \beta x +(y_0-\beta x_0),$$ and to minimise the sum of squares of residuals you need to use $$\beta = \dfrac{\sum (x_i-x_0)(y_i-y_0)}{\sum (x_i-x_0)^2}.$$