[R] lme: random effects of a quadratic term
Marc Schwartz
MSchwartz at MedAnalytics.com
Sat Mar 26 22:37:31 CET 2005
On Sat, 2005-03-26 at 22:21 +0100, Montse Rue wrote:
> I tried to replicate in R the example that Pinheiro and Bates present
> on section 1.5 of their mixed-effects book, the pixel intensity
> example.
>
> > fm1Pixel<-lme(pixel~day+day^2,data=Pixel,random=list(Dog=~day,Side=~1))
>
> When I run it in R the second order term does not appear in the
> estimated model. But, when I write
>
> > fm1Pixel<-lme(pixel~day+I(day^2),data=Pixel,random=list(Dog=~day,Side=~1))
>
> I get the same results as in the Pinheiro and Bates book, and the plot
> of the augPred values is a quadratic function as in Figure 1.18. The
> same happens with my data when I use the I(alcadakm^2) .
>
> Can it be that S accepts day^2 but R doesn't?
>
> Thanks again!
>
> Montse
<SNIP of prior exchange>
As per the main R FAQ "3.3.2 Models":
There are some differences in the modeling code, such as
* Whereas in S, you would use lm(y ~ x^3) to regress y on x^3, in
R, you have to insulate powers of numeric vectors (using I()),
i.e., you have to use lm(y ~ I(x^3))
Please read the FAQ's when comparing R and S[-PLUS] as this is but one
of the important differences:
http://cran.r-project.org/doc/FAQ/R-FAQ.html#R-and-S
Marc Schwartz
More information about the R-help
mailing list