[R] simple fit

Ben Bolker bbolker at gmail.com
Thu Dec 8 20:09:09 CET 2011

R. Michael Weylandt <michael.weylandt <at> gmail.com> writes:

> Fit y-b without an intercept? (which you do by adding "+ 0" or "- 1"
> to the model formula) Not sure if this is the optimal result, but it
> will give you a pretty reasonable answer.

 This seems backward.  The OP has the slope and wants the intercept.

> On Thu, Dec 8, 2011 at 10:52 AM, Alaios <alaios <at> yahoo.com> wrote:

> >  I have a formula of the form
> > y=ax+b
> > I know everything except b. 
> > How I can ask R to do fitting to find only the value of b?
> > I already know the lm() but it always return both an intercept point
> >  (b) and the a.


  lm (y~1,offset=a*x,data= ...) 


  lm(y-a*x~1,data=...)  [not sure this will evaluate the full
expresson on the LHS but it might]

More information about the R-help mailing list