[R] mixed model

Doran, Harold HDoran at air.org
Wed May 25 18:06:32 CEST 2005

I may not follow entirely here, but your random effects structure isn't
correct for lme. Also, nlme cannot handle (at least well) models with
crossed random effects. A better option would be to use the lmer

Setting up the structure for the random effects in nlme would look
something like:

lme(y~ fixed, data, random~= z1 + z2 |ID)

Where ID is a variable that contains the grouping structure of your

In lmer, which is more appropriate for models with crossed random
effects, you lmer call might be something along the lines of:

lmer(y ~ fixed + (z1|ID) + (z2|ID), data)

See the most recent version of R news for more info on this topic.

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of NATALIA F
Sent: Wednesday, May 25, 2005 11:50 AM
To: r-help at stat.math.ethz.ch
Subject: [R] mixed model

 Hello all,
 I have problem with setting up random effects.
 I have a model:
 where x1, x2, x1*x2 are fixed effects
 and z1, z1*x2 are random effects (crossed effects)  I use library(nlme)
'lme' function.
 My question is: how I should set up random effects?
 I did
 lme(y~x1+x2+x1:x2, data=DATA, random=~z1+z1:x2, na.action='na.omit')
but it did not work.

 Sincerely, Natalia.

R-help at stat.math.ethz.ch mailing list
PLEASE do read the posting guide!

More information about the R-help mailing list