Re: [R] how to code y~x/(x+a) in lm() function

2013-08-22 Thread Rolf Turner
I tried your suggestion on the toy example that was posted by David Carlson a while back: set.seed(42) x <- 1:15 y <- x/(1+x) + rnorm(15,0,0.02) I found that I had to: (a) Wrap the "1/x" inside "I()". (b) Set the offset term to be rep(1,length(x)). Bottom line: fit <- glm(y ~ 0+I(1/

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
On 13-08-21 05:17 PM, Rolf Turner wrote: > > > Thott about this a bit more and have now decided that I don't understand > after all. > > Doesn't > > glm(1/y~x,family=gaussian(link="inverse")) > > fit the model > > 1/y ~ N(1/(a+bx), sigma^2) > > whereas what the OP wanted was > >

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-21 Thread Ben Bolker
Rolf Turner xtra.co.nz> writes: > > On 21/08/13 11:23, Ye Lin wrote: > > T > > hanks for your insights Rolf! The model I want to fit is y=x/a+x with > > no intercept, so I transformed it to 1/y=1+a/x as they are the same. > > For crying out loud, they are ***NOT*** the same. The equations y =

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Bert Gunter
Rolf: Thanks for this. It nicely illustrates what to me is a fundamental problem: For many scientists, it is not math ("stats") that is the stumbling block, but rather the failure to understand how variability ("noise") affects the experimental/observational process. One does tend to get more phi

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
On 21/08/13 11:23, Ye Lin wrote: > T > hanks for your insights Rolf! The model I want to fit is y=x/a+x with > no intercept, so I transformed it to 1/y=1+a/x as they are the same. For crying out loud, they are ***NOT*** the same. The equations y = x/(a+x) and 1/y = 1 + a/x are indeed algebraica

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
T hanks for your insights Rolf! The model I want to fit is y=x/a+x with no intercept, so I transformed it to 1/y=1+a/x as they are the same. but i will look up nls() and see how to fit the model without transformation. On Tue, Aug 20, 2013 at 2:45 PM, Rolf Turner wrote: > > (1) It is not accept

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Rolf Turner
(1) It is not acceptable to use "wanna" in written English. You should say "I want to fit a model ". (2) The model you have fitted is *not* equivalent to the model you first state. If you write "y ~ x/(a+x)" you are tacitly implying that y = x/(a+x) + E where the "errors" E ar

Re: [R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread David Carlson
TX 77840-4352 -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Ye Lin Sent: Tuesday, August 20, 2013 4:40 PM To: R help Subject: [R] how to code y~x/(x+a) in lm() function Hey All, I wanna to fit a model y~x/(a+x) to my data, here is the c

[R] how to code y~x/(x+a) in lm() function

2013-08-20 Thread Ye Lin
Hey All, I wanna to fit a model y~x/(a+x) to my data, here is the code I use now: lm((1/y-1)~I(1/x)+0, data=b) and it will return the coefficient which is value of a however, if I use the code above, I am not able to draw a curve the presents this equation. How can I do this? Thanks for your