title: Constrained least-square regression - Matlab or R
body: <p>I'm doing a least-square regression on some data, the function has the form </p>
  
  <pre><code>y ~ a + b*x
  </code></pre>
  
  <p>and I want the regression line to pass through a specific point P(x,y) (which is not the origin).
  How can I do that?</p>
  
  <p>I'm using the lm command in R and the basic fitting GUI in Matlab.
  I think that I could use the constrOptim command (in R) or translate the origin into the point P, but I'm wondering if there's a specific command to do that. </p>
  
  <p>I only need the solution for one of these programs, then I can use the coefficients in the other one.</p>