Skip to content
Prev 70405 / 398526 Next

mixed model

NATALIA F TCHETCHERINA wrote:
The answer will depend on the types of x1, x2 and z1 (i.e. whether each
of them is numeric or a factor).  Because you use x1:x2 I will assume
that x1, x2 and z1 are all factors.  In that case the formula term x1*x2
is equivalent to x1 + x2 + x1:x2 and you could write the call to lme as

lme(y ~ x1*x2, data = DATA, random = ~1|z1/x1)

For lmer from the lme4 package it would be

lmer(y ~ x1*x2 + (1|z1) + (1|z1:x1), data = DATA)