Skip to content

lme: random effects of a quadratic term

6 messages · Montse Rue, Brian Ripley, Marc Schwartz

#
Hello,

I am estimating the following model:

so2.lme<-lme(so2~1+I(alcadakm^2)+dia,data=subjectes2,na.action=na.omit)

And when I try to plot the random effects of the quadratic term with
respect to a covariate (mam) I get an error:
Error in plot.ranef.lme(so2.lmeRE, form = I(alcadakm^2) ~ mam ) : 
	Only single effects allowed in left side of form.

Any suggestion?

Thanks!

Montse Rue
#
On Sat, 26 Mar 2005, Montse Rue wrote:

            
Try renaming the variable, e.g. alcadakm2 = alcadakm^2, and refit.

NB: this is not `a quadratic term' but a transformed variable, since you 
used I().
#
Thanks! I already tried it, but then I have problems with the augPred
values. I get straight lines instead of quadratic lines when plotting
the augPred values.

What can I do?

Montse


On Sat, 26 Mar 2005 09:39:07 +0000 (GMT), Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
#
On Sat, 26 Mar 2005, Montse Rue wrote:

            
WHy are you expecting a non-linear plot from a linear fit?

  
    
#
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.
When I run it in R the second order term does not appear in the
estimated model. But, when I write
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



On Sat, 26 Mar 2005 17:39:43 +0000 (GMT), Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
#
On Sat, 2005-03-26 at 22:21 +0100, Montse Rue wrote:
<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