[R-sig-ME] lme repeated measures model statement

Ben Bolker bbolker at gmail.com
Mon Feb 7 04:03:49 CET 2011


Matt Meier <memeier at ...> writes:

> 
> Hello,
> I'm transitioning from repeated measures ANOVAs to mixed effects and
> could use some help. I want to describe how people who differ in a
> cognitive ability (wmcz) differ in the performance of an experimental
> task. Currently, I'm interested in response times as the dependent
> measure. This project is a totally within-subjects repeated measures
> design. The following is what the dataframe looks like:
> 
>         id        trialtype con    rrt             wmcz
> 201 7000    stroop   1 0.002150538 0.6408047
> 202 7000    stroop   0 0.002114165 0.6408047
> 207 7000     simon   0 0.002475248 0.6408047
> 210 7000     simon   0 0.002739726 0.6408047
> 211 7000    stroop   1 0.002283105 0.6408047
> 213 7000     simon   1 0.002277904 0.6408047
> 214 7000     simon   0 0.003125000 0.6408047
> 215 7000     simon   0 0.002777778 0.6408047
> 216 7000     simon   1 0.002309469 0.6408047
> 217 7000    stroop   0 0.002114165 0.6408047
> 
> id - is the subject number
> trialtype - is a  discrete predictor with 2 levels
> con(congruency) - is a discrete predictor with 2 levels
> rrt(reciprocal of response time)-  is the outcome variable
> wmcz- is a subject variable that is a continuous predictor
> 
> .frame':   66463 obs. of  5 variables:
>  $ id       : int  7000 7000 7000 7000 7000 7000 7000 7000 7000 7000 ...
>  $ trialtype: Factor w/ 2 levels "simon","stroop": 2 2 1 1 2 1 1 1 1 2 ...
>  $ con      : Factor w/ 2 levels "0","1": 2 1 1 1 2 2 1 1 2 1 ...
>  $ rrt      : num  0.00215 0.00211 0.00248 0.00274 0.00228 ...
>  $ wmcz     : num  0.641 0.641 0.641 0.641 0.641 ...
> 
> There are 228 subjects with about 300 observation per subject. 50% of
> the trials are of the trialtype stroop and 50% are congruent(con = 0).
> I'm interested in the interaction between wmcz, con, and trialtype on
> rrt. I think wmcz will interact with  stroop trialtype crossed with
> congruency but not with simon trialtype crossed with congruency. I
> plan on comparing a model with both interaction effects to a model
> with only the stroop*con*wmcz interaction.
> 
> I would describe the design as trialtype crossed with congruency
> nested within subjects. Also nested within the subjects is wmcz. I've
> been taught that ideally wmcz should be treated as a random effect
> because I want to generalize the results to wmcz values not in my
> sample, but I if I did this I don't think I would be able to model the
> interaction between wmcz, trialtype, and congruency. Am I right about
> this? If not, an example of how to do this would be greatly
> appreciated.

  Here are my opinions.  Treat them with caution.

  I find the "nested" terminology quite confusing.  My operational
definition for nesting is that a factor is nested within another if
each level of that factor appears in **only one level** of the
nesting factor.  For example, if we have sites (numbered 1 to 5)
within blocks (lettered A to E), sites are nested within blocks
because we don't want to compare what's happening in site 1 within
block A with what's happening in site 1 within any of the other blocks.
(only if the sites were numbered in some systematic way, e.g. east to west,
would we want to do this comparison).  Thus, trialtype and congruency
are NOT (by my definition) nested within subjects, because it's reasonable
to suppose that trialtype and congruency (and their interaction) have
some overall (cross-subject) effect.  However, if trialtype and congruency
are measured multiple times within subject (which I guess they must
be if you have 300 observations per subject!) you can also evaluate
the interaction of trialtype*congruency with subject, i.e. evaluate
across-subject variation in the response.

  As for wmcz: it sounds like it's a subject-level factor (i.e.
identical for all observations on a given subject).  However, I would
not treat it as a random effect; because it is continuous, the way
you generalize to wmcz values not in your sample is that you assume
that it has a linear effect (this is an assumption that should be
evaluated).  If every subject has a unique wmcz value (which makes
sense if it's a continuous measure), then making wmcz a random effect
would confound it with the effect of subject.

 
lme(rrt~trialtype*con*wmcz, random=~trialtype*con|id, data=...)

 or in the lme4 package (which I would suggest you try out if only because
is more computationally efficient than the nlme package, although you
will lose things like p-values)

lmer(rrt~trialtype*con*wmcz+(trialtype*con|id), data = ...)




More information about the R-sig-mixed-models mailing list