# Analyzing a 2x3 repeated measures design using a logit mixed model

An experiment I conducted recently used a 2 (between participants) x 3 (within participants) design. That is, participants were randomly allocated to one of two conditions, and then completed three similar tasks each (in a counterbalanced order).

In each of these tasks, participants made binary choices (2AFC) in a number of trials, each of which had a normatively correct answer.
In every trial, participants were presented a distractor, which was assumed to bias responses towards one of the alternatives. The tasks differed only in presence and magnitude of this distractor (i.e. no distractor vs. distractor of small and large magnitude).

I would like to examine the error rates (deviations from the normatively correct answer) across these conditions. I hypothesize that the error rate will increase when a distractor is present, but will not increase further when the magnitude of the distractor is increased. Also, I expect this increase to differ between the between-subjects conditions. The latter interaction is the central interest.

From discussions here and from the literature (Dixon, 2008; Jaeger, 2008), I gather that logit mixed-models are the appropriate analysis method, and that, in R, the lme4 package is the tool of choice.
While I could compute some basic analyses (e.g. random intercept model, random effects ANCOVA) with lme4, I am stuck as to how to apply the models to the design in question -- I have the feeling that I am very much thinking in terms of HLMs, and have not yet quite understood the entirety of mixed effects models. Therefore, I would be very grateful for your help.

I have two basic questions:

1. In a first analysis, I would like to consider the error rates in only those trials in which participants were biased towards the wrong answer. The first model would therefore look only at trials in which the bias would point away from the correct answer.

If my observations were independent, i would probably use a model like this:

correct ~ condition + distractor + condition:distractor

... but obviously, they aren't: Observations are grouped within a task (with a constant presence of a distractor) and within participants. My question, then, is this: How do I add the random effects to reflect this?

2. (If I haven't lost you already :-) ) Would it be possible to include all trials (those where the bias would be into the direction of the wrong and of the correct answer), and include this difference (i.e. direction of the bias) as a trial-level predictor?

In my imagination of HLMs, such a predictor (at the level of the trial) would depend on on the magnitude of the distractor present (at the level of the block), which again would depend on the condition of the participant (plus, possibly, a unique factor for each participant).
The interactions would then emerge ›automatically‹ as cross-level interactions. How would such a model be specified in the ›flat‹ lme4 syntax? (Would such a model make sense at all?)

Ok, I hope all of this makes sense -- I will gladly elaborate otherwise. Again, I would be most grateful for any ideas and comments regarding this analysis, and would like to thank you for taking the time and trouble to respond.

References

Dixon, P. (2008). Models of accuracy in repeated-measures designs. Journal of Memory and Language, 59(4), 447-456. doi: 10.1016/j.jml.2007.11.004

Jaeger T. F. (2008). Categorical data analysis: Away from ANOVAs (transformation or not) and towards logit mixed models. Journal of Memory and Language, 59(4), 434-446. doi: 10.1016/j.jml.2007.11.007

I would definitely use all your data and add direction of intended bias induction as a variable. Since you already have variables in the model describing the difference between the tasks, I don't believe that adding task as a random effect is necessary. The model would be:

my_model = lmer(
correct ~ (1|subject) + condition*distractor*direction
, family = 'binomial'
, data = my_data
)


Check out the ezMixed function from the ez package for an automated way of evaluating evidence for each effect in the model.

• Thank you very much -- your suggestion worked very well indeed. Also, thank you for your pointer to ezMixed, which is also a huge help -- I wasn't aware that ez offered support for mixed models. (Actually, while I'm at it: Thank you for your work on ez, which is a great pleasure to use :-) ) – mezzopiano Feb 28 '11 at 23:04

I disagree with the other responder, you shouldn't just fit varying intercept, fixed slope by default.

y~1+condition*distractor*direction+(1+condition*distractor*direction|subject) should at least be fit for model testing. Otherwise, you are just assuming the subject effect is only on the intercept and you are assuming there is no correlation of the slope and intercept random effects. Don't skip these crucial investigations. See http://lme4.r-forge.r-project.org/book/Ch4.pdf and http://www.stat.columbia.edu/~gelman/research/unpublished/multi.pdf