22
$\begingroup$

I have a point (x,y) that I need a linear regressor to pass through given a data set (X,Y). How do I implement this in R?

$\endgroup$
7
  • $\begingroup$ @cardinal Good answer! (Maybe you could post it as a reply?) $\endgroup$
    – whuber
    Commented Jun 29, 2011 at 20:37
  • $\begingroup$ @cardinal. Right on the money. Please post this as an answer -- let's minimize the number of unanswered questions. :O) Ps. Up-votes headed your way. $\endgroup$
    – M. Tibbits
    Commented Jun 30, 2011 at 1:30
  • $\begingroup$ Thank you cardinal. By the way, is there a way to force the regression line to have a negative slope? $\endgroup$
    – reisner
    Commented Jun 30, 2011 at 2:31
  • 1
    $\begingroup$ If the fitted line does not have a negative slope, the best you can do is a zero slope, which will pass through the point $(x,y)$, thereby uniquely determining it. $\endgroup$
    – whuber
    Commented Jun 30, 2011 at 2:57
  • $\begingroup$ I have deleted my comment and expanded it slightly into a full answer. $\endgroup$
    – cardinal
    Commented Jun 30, 2011 at 13:11

1 Answer 1

28
$\begingroup$

If $(x_0,y_0)$ is the point through which the regression line must pass, fit the model $y−y_0=\beta (x−x_0)+\varepsilon$, i.e., a linear regression with "no intercept" on a translated data set. In $R$, this might look like lm( I(y-y0) ~ I(x-x0) + 0). Note the + 0 at the end which indicates to lm that no intercept term should be fit.

Depending on how easily you are convinced, there are multiple ways to demonstrate that this does, indeed, yield the correct answer. If you want to establish it formally, one simple method is to use Lagrange multipliers.

Whether or not it is actually a good idea to force a regression line to go through a particular point is a separate matter and is problem dependent. Generally, I would personally caution against this, unless there is a very good reason (e.g., very strong theoretical considerations). For one thing, fitting the full model can provide a means for measuring lack of fit. As a second matter, if you are mostly interested in evaluating model explanatory power for values of $x$ and $y$ "far away" from $(x_0,y_0)$, then the relevance of the fixed point becomes suspect.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.