Skip to content
Prev 68451 / 398506 Next

random interactions in lme

Jacob Michaelson wrote:
The grouping factor is rep because the random effects are associated 
with the levels of rep.

I don't always understand the SAS notation so you may need to help me 
out here.  Do you expect to get a single variance component estimate for 
Rep*Compacting and a single variance component for Rep*Variety?  If so, 
you would specify the model in lmer by first creating factors for the 
interaction of Rep and Compacting and the interaction of Rep and Variety.

dat$RepC <- with(dat, Rep:Compacting)[drop=TRUE]
dat$RepV <- with(dat, Rep:Variety)[drop=TRUE]
fm <- lmer(DryMatter ~ Compacting*Variety+(1|Rep)+(1|RepC)+(1|RepV), dat)