[R-sig-ME] more than 2 within-subjects factors in lme(r)
Douglas Bates
bates at stat.wisc.edu
Fri Jun 13 20:02:48 CEST 2008
On Thu, Jun 12, 2008 at 9:25 PM, Ullrich Ecker <ullrich.ecker at uwa.edu.au> wrote:
> Dear expeRts,
> I am facing some problems with lme with 3 fixed within-subjects
> factors (S, R, T) to be followed up by a post-hoc test.
> Each of the 3 factors can be 0 or 1 (in fact, all 3 could be 0, so
> there are 8 conditions).
> I know how to do this with an 8-level condition factor:
> require(nlme) ## for lme()
> require(multcomp) ## for multiple comparison stuff
> RT.aov <- aov(RT ~ Condition + Error(Subject/Condition), Data)
> RT.lme <- lme(RT ~ Condition, random = ~1 | Subject/Condition, Data)
> summary(glht(RT.lme, linfct=mcp(Condition="Tukey")))
> but I am unable to get lme to work with 3 factors despite trying to
> use some hints provided in the archives.
> The lme solution should be equivalent to:
> RT.aov <- aov(RT ~ S*R*T + Error(Subject / (S*R*T)), Data)
> and then I want to do:
> RT.lme <- lme(RT ~ S*R*T ---THE GAP---)
Well, I can tell you about fitting the model. I'm not really sure
what the multiple comparisons code below does so someone else will
need to comment.
I find it easier to express the model in the lmer syntax as
Rt.lmer <- lmer(RT ~ S * R * T + (1|Subject) + (1|Subject:S:R:T), ...)
A term like "(1|Subject/Condition)" in an lmer formula is just a
shortened form of "(1|Subject) + (1|Subject:Condition)"
If you want to express Subject:Condition in terms of Subject, S, R and
T then you just need to generate a factor with a separate level for
each distinct combination of Subject, S, R and T, which is what
Subject:S:R:T is.
In this regard parsing a random-effects specification is actually
easier than for fixed effects. With fixed effects you must be careful
to determine a non-redundant set of basis vectors for the column span
of the intercept, the main effects given the intercept, any two-factor
interactions given the main effects, etc. With random effects you can
include both (1|Subject) and (1|Subject:Condition) in a model and not
need to adjust the random effects for the interaction
(1|Subject:Condition) for the fact that random effects for the term
(1|Subject) are also included in the model.
> summary(glht(RT.lme, linfct=mcp(? S*R*T ? = "Tukey")))
> These didn't work:
>
> RT.lme <- lme(RT ~ S*R*T, random = ~1 | Subj/(S*R*T), WMU2C)
> #Error in getGroups.data.frame(dataMix, groups) : Invalid formula for groups
>
> RT.lme <- lme(RT ~ S*R*T, random = ~1 | (Subj + (S %in% Subj) + (R
> %in% Subj) + (T %in% Subj)), WMU2C)
> #Error in sprintf(gettext(fmt, domain = domain), ...) : object
> "form" not found
>
> RT.lme <- lme(RT ~ S*R*T, random = ~S*R*T|Subj, WMU2C)
> #R stalls
>
>
> and I couldn't make use of this suggestion - R complains about
> unexpected characters and I to be honest I don't understand what it
> is supposed to do anyway:
>
> > lme((y~fact1*fact2,
> + random=list(subj=pdIdent(form=~fact1-1),
> + subj=~1,
> + fact2=~1),
>
>
> Thanks very much for your help!
>
> Ulli
>
> Ullrich Ecker
> Cognitive Science Laboratories
> University of Western Australia
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
More information about the R-sig-mixed-models
mailing list