[R] how to code y~x/(x+a) in lm() function
Ben Bolker
bbolker at gmail.com
Thu Aug 22 02:54:33 CEST 2013
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
>
> y ~ N(x/(a+x),sigma^2) ???
I goofed slightly.
y ~ 1/x with inverse link gives
1/y = a + b*(1/x)
y = 1/(a+b*(1/x))
= x/(a*x+b)
Hmmm. Is there an offset trick we can use?
y = x/(a+x)
1/y = (a+x)/x
1/y = (a/x) + 1
1/y = a*(1/x) + 1
So I *think* we want
glm(y~1/x+0+offset(1),family=gaussian(link="inverse"))
I'm forwarding this back to r-help.
>
> I can't see how these models can be equivalent. What am I missing?
>
> cheers,
>
> Rolf
>
>
>
> On 22/08/13 03:49, Ben Bolker wrote:
>> Rolf Turner <rolf.turner <at> 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 =
>>> x/(a+x) and
>>> 1/y = 1 + a/x are indeed algebraically identical, but if an "error" or
>>> "noise" term is added
>>> to each then then the nature of the error term is vastly different. It
>>> is the error or
>>> noise term that is of central concern in a statistical context.
>>>
>>> cheers,
>>>
>>> Rolf
>>
>> For what it's worth this model can also be fitted (without messing
>> up the error structure) via
>>
>> glm(1/y~x,family=gaussian(link="inverse"))
>>
>> Although you may not get the parameters in exactly the form you
>> want.
>>
>> ______________________________________________
>> 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