Skip to main content
5 of 5
edited tags
Ferdi
  • 5.3k
  • 10
  • 47
  • 64

Nested mixed effects with lme4

I am trying to analyze data from an experiment using lme4. In the experiment, subjects saw either dark or bright versions of 50 stimuli (between-subjects; fixed effect "brightness"). All subjects saw the 50 stimuli 3 times in varying durations (within-subjects). A previous post (Mixed Effects Model with Nesting) suggested that the following code is the correct way to deal with the nesting in the data:

lmer(response ~ brightness+duration +(1|subject:duration),REML=FALSE,data=dat)

Is (1|subject:duration) the correct way of specifying the nested data structure (that each subject saw each stimulus in multiple durations)?

Furthermore, a tutorial (http://www.bodowinter.com/tutorial/bw_LME_tutorial2.pdf) recommends the use of random slopes for random factors. Is this appropriate here?

Edit: The factor duration has 3 levels that I compare using Tukey tests

user55987