[R] simple fit
Rolf Turner
rolf.turner at xtra.co.nz
Thu Dec 8 20:22:12 CET 2011
If one knows y, x, and a, and wishes to estimate b in
y = a*x + b (+ random error presumably)
then surely the simplest procedure is
b.hat <- mean(y-a*x)
Is it not so?
cheers,
Rolf
On 09/12/11 08:09, Ben Bolker wrote:
> 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.
> Or:
>
> lm (y~1,offset=a*x,data= ...)
>
> or
>
> lm(y-a*x~1,data=...) [not sure this will evaluate the full
> expresson on the LHS but it might]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list