# Nesting within a crossed mixed effects model necessary?

I have data from a repeated-measures experiment to analyze. In the experiment, 67 subjects gave ratings for 50 stimuli (different screenshots), all of them shown three times in distinct durations (as a within factor with 3 factor levels; a total of 10050 responses). The 50 stimuli come from 10 content domains (another within-factor). Besides these within-factors, there was a between-subjects manipulation of all stimuli regarding their brightness. At first I assumed that this dataset needs a nested random effects model. However, as I understand now, all of the factors are crossed. Therefore I tried to fit the data using lmer according to http://www.bodowinter.com/tutorial/bw_LME_tutorial2.pdf

lmer(rating ~ brightness*duration*contentdomain + (1|subject) + (1|stimulus), data=dat, REML=FALSE)


I still wonder whether I need to somehow account for the fact that all stimuli were shown three times. I do not know whether this is necessary for my analysis, since the factors are all crossed and I assume all required specifications are accomplished by including the factor duration as a fixed factor. Is this correct? Help is greatly appreciated.

Edit: Would this be correct?

lmer(rating ~ brightness*duration*contentdomain + (duration|subject) + (1|stimulus), data=dat, REML=FALSE)


Edit 2: Given the data structure and values, I think adding a random slope for duration is the solution to the problem. Is this a good idea to solve the problem? (I also updated the fixed factor structure to properly match my hypothesis.)

lmer(rating ~ (brightness*contentdomain)+duration + (1+duration|subject) + (1+duration|stimulus), data=dat, REML=FALSE)

• It would probably help if you can provide some data that reflects your data structure. Obviously this doesn't need to be all the 10050 observations, just a subset of it. Have a look here how to create one. – Stefan Dec 12 '15 at 22:53
• this looks reasonable. Since you have repeated measures for the subject:stimulus combination, I think you could add (1|stimulus:subject) to the model ... while it is theoretically possible for this design, I think you don't want to add (stimulus|subject) – Ben Bolker Dec 13 '15 at 5:10