4

I'm analyzing an experiment that has 50 subjects and 50 items. Each item can occur in two possible conditions. Every experimental subject produces a (continuous) response to every item, but only once per item (individually, they only respond to one condition per item).

I hypothesize the following effects:

  1. item condition should affect the mean response: higher response in one condition than the other
  2. item condition should affect the variance of the response: higher variance in one condition than the other
  3. there is idiosyncratic variation between subjects: some subjects produce a higher response than others, regardless of item or condition. In addition, some subjects are more sensitive to the item condition than others.
  4. there is idiosyncratic variation between items: some items get higher responses than others, regardless of condition. In addition, some items are more sensitive to the item condition than others.

I want to model this with a linear mixed-effects model, and test the significance of (1) and (2). If I were using lme4, I would specify a model like this, with a fixed effect of condition, plus random intercepts and condition slopes for subjects and for items.

lmer(response ~ condition + (1 + condition | subject) + (1 + condition | item))

As far as I can tell, there's no way to test (2) with lme4. If someone can suggest a straightforward way to test (2) while also accounting for the other components, that would be very helpful!

This is what I've been able to do so far:

This question suggests how to use nlme to allow the variance to differ between fixed factor levels. I found via googling that I can specify crossed random effects with a hack using pdBlocked and pdIdent. My current model looks like this:

my_data$one = rep(1, nrow(my_data))

lme(response ~ condition, 
    random=list(one = pdBlocked(list(pdIdent(~ subject - 1),
                                     pdIdent(~ item - 1)))
                      ),
     weights=varIdent(form=~1|condition),
     data=my_data)

However, as far as I can tell from the model output (and comparison to lme4), this includes random intercepts but not slopes for condition, so requirements (3) and (4) of the model aren't fully satisfied. If you know how to specify condition slopes using the nlme syntax, that would also answer this question.

user102162
  • 141
  • 5
  • 1
    This can be done using the brms package for Bayesian multilevel regression. – user102162 Jun 20 '17 at 22:49
  • 2
    See here https://stats.stackexchange.com/a/214007/28666 – amoeba Jan 09 '18 at 23:16
  • @user102162 this is old but any tips on how you might use the brms package to achieve this? – qdread Nov 30 '21 at 01:43
  • Add a formula for sigma to the bf() formula argument. With the epilepsy dataset that comes with brms:

    mod <- brm(bf(count ~ Trt + (1 + Trt | patient), sigma ~ Trt), data = epilepsy)

    The brms_distreg vignette has more examples.

    – user102162 Jan 03 '22 at 02:10

0 Answers0