Solved – Nested mixed effects with lme4

lme4-nlmemixed modelrtukey-hsd-test

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

Best Answer

I would say

response ~ brightness+duration+(duration|subject)

would probably be a little better. (The simpler (1|duration:subject) model is not necessarily wrong, but might be oversimplified. If I were a peer reviewer of this work I would certainly ask for a justification of the simpler model ...) The (duration|subject) model is a "random-slopes" model, more or less (although if you have coded duration as a categorical (factor or ordered factor) variable the thing that varies randomly among subjects is not a slope per se, but a between-duration difference). The specification you have ((1|subject:duration)) assumes all subject-duration effects are drawn from a single (iid) Normal distribution; (duration|subject) assumes that the duration effects for a single individual are drawn from a $3 \times 3$ multivariate Normal distribution.

More precisely: comparing the random effect specification (1|subject:duration) gives the model for the conditional modes/BLUPs of subject $s$ for duration $d$ (or duration effect $d$, depending on how the model is parameterized) $$ b_{sd} \sim \textrm{Normal}(0,\sigma_{sd}^2) $$ whereas (duration|subject) gives

$$ \begin{split} b_{s\cdot} & \sim \textrm{MVN}( \mathbf 0,\Sigma) \\ \Sigma & = \left( \begin{array}{ccc} \sigma^2_1 & \sigma_{12} & \sigma_{13} \\ \sigma_{12} & \sigma^2_{2} & \sigma_{23} \\ \sigma_{13} & \sigma_{23} & \sigma^2_3 \\ \end{array} \right) \end{split} $$ i.e., the different duration levels each have different among-subjects variances, and the among-subject variation in different duration levels is correlated ($\Sigma$ is a general symmetric positive (semi)definite matrix). To get back to the previous model you would need to restrict $\sigma_1^2=\sigma_2^2=\sigma_3^2=\sigma_{sd}^2$ and all of the off-diagonal elements would be zero.

Related Question