[R] Is it possible with two random effects in lme()?

Douglas Bates bates at stat.wisc.edu
Sun Feb 3 16:59:15 CET 2008


On Feb 1, 2008 7:30 AM, Falco tinnunculus <kestrel78 at gmail.com> wrote:
> Dear all,

> Is it possible with two random effects in lme()?

>  lmefit1<- lme(Handling ~ Mass + factor(Prey)+ Mass*factor(Prey), random = ~
> 1 |Place+Age)

I assume that Place and Age are not nested.  If so, it's possible to
fit such a model with lme but not easy. It is much better to use the
lmer function in the lme4 package.  The call would be

lmerfit1 <- lmer(Handling ~ Mass + factor(Prey) + Mass * factor(Prey)
+ (1|Place) + (1|Age))

P.S. It is often better to send such questions to the special interest
group mailing list for mixed models, R-SIG-Mixed-Models at R-project.org.
 You may get a faster answer from that list which is lower traffic.

> Here I use Place as random effect, but I also want to add Age as a random
> effect. Since there could be an effect of Age (continous variable), but I
> like to control for it rather than locking at the effect of Age on handling
> time, since Mass and Prey type are of main interest.
>
> Regards Kes,
>
>         [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list