[R] LM with summation function

Bert Gunter gunter.berton at gene.com
Fri May 18 23:24:43 CEST 2012


Following up on Rolf's post:

1) cumulative summation (cumsum) maybe?
2) In fact, you should probably **not** fit the non-summation version
as you have stated. See ?poly.

I would guess that context is important here. Based on (my
interpretation) of the rather strange nature of your request,  I
suspect that you shouldn't be trying to do what you're doing **at
all**;  but that's just a guess, of course.

-- Bert

On Fri, May 18, 2012 at 1:56 PM, Rolf Turner <rolf.turner at xtra.co.nz> wrote:
> On 19/05/12 05:44, Robbie Edwards wrote:
>>
>> Hi all,
>>
>> I'm trying to model some data where the y is defined by
>>
>> y = summation[1 to 50] B1 * x + B2 * x^2 + B3 * x^3
>>
>> Hopefully that reads clearly for email.
>>
>> Anyway, if it wasn't for the summation, I know I would do it like this
>>
>> lm(y ~ x + x2 + x3)
>>
>> Where x2 and x3 are x^2 and x^3.
>>
>> However, since each value of x is related to the previous values of x, I
>> don't know how to do this.  Any help is greatly appreciated.
>
>
> If your mail says what it seems to say, then your question makes
> no sense.  You are in effect trying to fit a linear model to a single
> point:
>
>    y = B1*s1 + B2*s2 + B3*3
>
> where s1 = sum(x), s2 = sum(x^2) and s3=sum(x^3)
>
> and you have only a single value of each of s1, s2, s3.
>
> If you have replicate values of s1, s2, and s3 (i.e. replicate
> vectors (x1, ... x50)) --- and of course a corresponding y value
> for each replicate --- then just form s1, s2, and s3 as vectors
> whose entries correspond to the replicates and then fit
>
>    lm(y ~ s1 + s2 + s3)
>
> If I have misunderstood what you are asking then please provide
> a self-contained reproducible example as the posting guide requests.
>
>    cheers,
>
>        Rolf Turner
>
> ______________________________________________
> 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.



-- 

Bert Gunter
Genentech Nonclinical Biostatistics

Internal Contact Info:
Phone: 467-7374
Website:
http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm



More information about the R-help mailing list