[R-sig-ME] Repeated-measures anova with a within-subject covariate (or varying-slopes mixed model?)

Giuseppe Pagnoni gpagnoni at gmail.com
Tue Dec 4 14:28:10 CET 2012


Dear all,

I am having quite a hard time in trying to figure out how to correctly
spell out a model in R (a repeated-measures anova with a
within-subject covariate, I guess).  Even though I have read in the
posting guide that statistical advice may or may not get an answer on
this list, I decided to try it anyway, hoping not to incur in
somebody's ire for misusing the tool.

For the sake of clarity, I will explain the problem.

We conducted an experiment measuring average response times in a
cognitive task. The task has two types of stimuli (stim1, stim2) and
was performed in a 6-run session, where subjects performed the task
under condition A on odd-numbered runs and under condition B on
even-numbered runs.  Thus, the temporal sequence of the runs was the
following:

- run 1: cond A
- run 2: cond B
- run 3: cond A
- run 4: cond B
- run 5: cond A
- run 6: cond B

where for each run and for each subject, an average RT was collected
for stim1 and for stim2.

After collecting and plotting the data, an approximately linear
decrease in RT from run1 to run6 was apparent in most subjects
(practice effect: subjects become better and faster with time).

Now, I am struggling with how to properly specify a model to perform
the group analysis by taking into account this confounding practice
effect, so that the real effects of interest (the main effect of
condition, and the interaction of condition and stimulus type) can be
better assessed.

I used a dataframe in long format, with `subj', `rt' (response time),
`stim' (stim1, stim2), `cond' (A, B), and `run' (1 to 6) as columns,
where `run' is coded as an integer so that it can be used for modeling
a linear trend. The R command I tried is:

 rt.aov <- aov(rt ~ run + stim * cond + Error(subj /(run + stim *
cond)), data=rt.df)

but I am not at all sure that the error term is correctly specified.

Furthermore, we have also collected data on an additional batch of
subjects that performed the task in the 6-run session but with the
order of conditions A and B reversed (A on even-numbered runs and B on
odd-numbered runs); now, if we wanted to analyze the data from the two
groups of subjects together, by including a between-subjects group
factor (groupAB, groupBA), would the model specification become
something like the following?

   rt.aov <- aov(rt ~ run + group * stim * cond + Error(subj /(run +
stim * cond)), data=rt.df)

Perhaps should lme() be used instead (and with which formula?)?

Many thanks in advance to anybody who'd be so kind to offer their
advice or tip on this.  I have scoured the web and some textbooks for
a few days now, but to little avail.

very best

giuseppe

-- 
Giuseppe Pagnoni
Dip. Scienze Biomediche, Metaboliche e Neuroscienze
Sezione Fisiologia e Neuroscienze
Univ. di Modena e Reggio Emilia
Via Campi 287
I-41125 Modena, Italy
Tel: +39-059-205-5742
Fax: +39-059-205-5363



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