title: Use of offset in lm regression - R
body: <p>I have this code</p>
  
  <pre><code>dens &lt;- read.table('DensPiu.csv', header = FALSE)
  fl &lt;- read.table('FluxPiu.csv', header = FALSE)
  mydata &lt;- data.frame(c(dens),c(fl))
  
  dat = subset(mydata, dens&gt;=3.15)
  colnames(dat) &lt;- c("x", "y")
  attach(dat)
  </code></pre>
  
  <p>and I would like to do a least-square regression on the data contained in <em>dat</em>, 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(x0,y0) (which is not the origin). </p>
  
  <p>I'm trying to do it like this</p>
  
  <pre><code> x0 &lt;- 3.15 
  
   y0 &lt;-283.56
  
   regression &lt;- lm(y ~ I(x-x0)-1, offset=y0)
  </code></pre>
  
  <p>(I think that data = dat is not necessary in this case) but I get this error : </p>
  
  <pre><code>Error in model.frame.default(formula = y ~ I(x - x0) - 1, : variable
   lengths differ (found for '(offset)').
  </code></pre>
  
  <p>I don't know why. I guess that I haven't defined correctly the offset value but I couldn't find any example online.</p>
  
  <p>Could someone explain to me how <em>offset</em> works, please?</p>