I want to know if a covariate for each subject interacts with three types of trials, and the difficulty of those trials. My dependent measures are accuracy and response times (RT). For this question, I’d like to focus on RTs. Traditionally, people in my field have dichotomized the covariate of interest and used ANOVAs for analysis. I would like to treat the covariate as the continuous variable it is, and treat the subjects as random effects. I want to analyze this using mixed-models in R (nlme).

The first 2 trial types can be either easy or hard and the third trial type is a combination of the first 2. These trials can be easy-easy, easy-hard, hard-easy, hard-hard.

I expect people who have higher scores on the covariate to show a smaller difference between hard and easy RTs for at least 1 trial type.

This is a repeated-measures design with each subject completing 3 blocks of 40 trials of each of the trial types (for trialtypes 1 & 2: 20 easy, 20 hard; for trialtype3, 10 easy-easy, 10 easy-hard, 10 hard-hard, 10 hard-easy). Stated differently, each subject completes 3 blocks of 120 trials with the various trialtypes randomly ordered.

Only RTs for correct trials will be analyzed (resulting in an unbalanced design for RT data). Besides a counter-balancing of response keys, this is a completely within-subjects design.

To summarize, what is the model (or models) that will allow me to test for interactions between trialtypes, difficulty, and the covariate using nlme in R?

  • $\begingroup$ Given the silence here thusfar, you should try sending this query to the R-SIG-Mixed-Models mailing list. $\endgroup$ Jan 5, 2011 at 14:44
  • 1
    $\begingroup$ Also, during the Bayesian Data Analysis session at the recent annual meeting of the Psychonomics Society, it was mentioned that Bayesian approaches can capture scenarios like this where you have two tasks but want to analyze the data simultaneously, letting the data from each task influence inference about the other. I'm working my way through the happy puppy Bayes book (indiana.edu/~kruschke/DoingBayesianDataAnalysis), but still not to the point where I can describe how to achieve this analysis. $\endgroup$ Jan 5, 2011 at 14:48
  • $\begingroup$ @Mike Lawrence Thanks for the tip. You'll probably see this on the R-Sig list soon. Although I'd lose power doing it, I can address the problem you mention below about the cell with 0 trials by running 2 separate models. I missed the Bayes session at pnomics, but find the idea of using a Bayesian approach to dual-tasks intriguing. I don't know much about Bayesian analysis, but it has me thinking about how the Bayes approach may be different from fitting a covariance matrix in mixed-models. $\endgroup$
    – Matt
    Jan 5, 2011 at 22:28

1 Answer 1


(This isn't an answer, simply an attempt at clarification of the question. I would have made this a comment to the question, but I haven't had success putting code in a comment)

Am I correct in interpreting your design as captured by the data frame resulting from the following (ignoring the arbitrary number of subjects and trials):

a = data.frame(expand.grid(
    s = factor(1:10)
    , trial = 1:20
    , task1 = c('absent','easy','hard')
    , task2 = c('absent','easy','hard')
a = a[!(a$task1=='absent' & a$task2=='absent'),]




       easy absent hard
easy    200    200  200
absent  200      0  200
hard    200    200  200

I'm more familiar with lme4 than nlme, but I know that the absent/absent cell will cause lmer to fail if you try a model with a task1:task2 interaction. Somehow we need to get lmer to recognize that this is a nested model with two tasks that are presented either singly or combined...

  • $\begingroup$ in your dataframe there should only be 100 trials in each cell that is a combination of the 2 tasks. Also as an aside, I'm not wed to nlme. I've just begun using (or trying to use) mixed-models. nlme() is the first function that I've been introduced to. $\endgroup$
    – Matt
    Dec 30, 2010 at 3:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.