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@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.