[R] moving from aov() to lmer()

Adam D. I. Kramer adik at ilovebacon.org
Sun Sep 14 23:22:10 CEST 2008


On Sat, 13 Sep 2008, roberto toro wrote:

> Hello,
> I've used this command to analyse changes in brain volume:
>
> mod1<-aov(Volume~Sex*Lobe*Tissue+Error(Subject/(Lobe*Tissue)),data.vslt)
>
> I'm comparing males/females. For every subject I have 8 volume measurements
> (4 different brain lobes and 2 different tissues (grey/white matter)).
>
> As aov() provides only type I anovas, I would like to use lmer() with type
> II, however, I have struggled to find the right syntaxis.
>
> How should I write the model I use with aov() using lmer()??
>
> Specifying Subject as a random effect is straightforward
>
> mod2<-lmer(Volume~Sex*Lobe*Tissue+(1|Subject),data.vslt)
>
> but I can't figure out the /(Lobe*Tissue) part...

You're trying to model a separate effect of lobe, of tissue, and of the
interaction between lobe and tissue for each subject, so you want

mod2<-lmer(Volume~Sex*Lobe*Tissue+(Lobe*Tissue|Subject),data.vslt)

...the resulting fixed effect for Lobe, Tissue, and L:T in the summary()
then corresponds to the within-subjects effect aggregated (but not exactly
AVERAGED) across subjects. So, it's not exactly providing you a Type II
ANOVA...it's doing a mixed-effects model (or HLM, if you prefer), which as
you've written it is a Type III analysis (though once again, not an ANOVA in
the classical sense).

To get something more akin to type II using the lmer function (and I trust
someone will pipe up if there is a better way), you could first fit

mod2.additive<-lmer(Volume~Sex*Lobe+Tissue+(Lobe+Tissue|Subject),data.vslt)

...and interpret the coefficients and effects provided by it, then fit the
crossed model to get the coefficients and effects for the higher-order
terms.

I hope this made sense and that I have understood you correctly.

--Adam



More information about the R-help mailing list