Dear all, 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. What should I do ? I would like to thank you in advance for your help B.R Alex [[alternative HTML version deleted]]
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. Michael On Thu, Dec 8, 2011 at 10:52 AM, Alaios <alaios at yahoo.com> wrote:> Dear all, > ?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. > > What should I do ? > > I would like to thank you in advance for your help > > B.R > Alex > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > 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. >
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]
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.
Reasonably Related Threads
- FW: How to fit an linear model withou intercept
- Draw a perpendicular line?
- Extracting information from lm results (multiple model runs)
- how to get perfect fit of lm if response is constant
- fit linear regression with multiple predictor and constrained intercept