Re: [R] random interactions in lme

From: Douglas Bates <bates_at_stat.wisc.edu>
Date: Mon 25 Apr 2005 - 00:52:47 EST

Jacob Michaelson wrote:
> Hi All,
>
> I'm taking an Experimental Design course this semester, and have spent
> many long hours trying to coax the professor's SAS examples into
> something that will work in R (I'd prefer that the things I learn not be
> tied to a license). It's been a long semester in that regard.
>
> One thing that has really frustrated me is that lme has an extremely
> counterintuitive way for specifying random terms. I can usually figure
> out how to express a single random term, but if there are multiple terms
> or random interactions, the documentation available just doesn't hold up.
>
> Here's an example: a split block (strip plot) design evaluated in SAS
> with PROC MIXED (an excerpt of the model and random statements):
>
> model DryMatter = Compacting|Variety / outp = residuals ddfm =
> satterthwaite;
> random Rep Rep*Compacting Rep*Variety;
>
> Now the fixed part of that model is easy enough in lme:
> "DryMatter~Compacting*Variety"
> But I can't find anything that adequately explains how to simply add the
> random terms to the model, ie "rep + rep:compacting + rep:variety";
> anything to do with random terms in lme seems to go off about grouping
> factors, which just isn't intuitive for me.

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)



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Mon Apr 25 00:57:51 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:25 EST