# Re: [R] lme: random effects of a quadratic term

From: Montse Rue <montse.rue_at_gmail.com>
Date: Sun 27 Mar 2005 - 07:21:36 EST

> 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?

Montse

On Sat, 26 Mar 2005 17:39:43 +0000 (GMT), Prof Brian Ripley <ripley@stats.ox.ac.uk> wrote:
> On Sat, 26 Mar 2005, Montse Rue wrote:
>
> > 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?
>
> WHy are you expecting a non-linear plot from a linear fit?
>
> > Montse
> >
> >
> > On Sat, 26 Mar 2005 09:39:07 +0000 (GMT), Prof Brian Ripley
> > <ripley@stats.ox.ac.uk> wrote:
> >> On Sat, 26 Mar 2005, Montse Rue wrote:
> >>
> >>> I am estimating the following model:
> >>>
> >>>
> >>> And when I try to plot the random effects of the quadratic term with
> >>> respect to a covariate (mam) I get an error:
> >>>
> >>>> so2.lmeRE<-ranef(so2.lme,augFrame=T)
> >>> Error in plot.ranef.lme(so2.lmeRE, form = I(alcadakm^2) ~ mam ) :
> >>> Only single effects allowed in left side of form.
> >>>
> >>> Any suggestion?
> >>
> >> 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().
> >>
> >> --
> >> Brian D. Ripley, ripley@stats.ox.ac.uk
> >> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> >> University of Oxford, Tel: +44 1865 272861 (self)
> >> 1 South Parks Road, +44 1865 272866 (PA)
> >> Oxford OX1 3TG, UK Fax: +44 1865 272595
> >>
> >
> >
>
> --
> Brian D. Ripley, ripley@stats.ox.ac.uk
> Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
> University of Oxford, Tel: +44 1865 272861 (self)
> 1 South Parks Road, +44 1865 272866 (PA)
> Oxford OX1 3TG, UK Fax: +44 1865 272595
>

R-help@stat.math.ethz.ch mailing list