I have an experimental paradigm with n stimuli, where pairs of stimuli are presented to participants (one on the left, one on the right) and participants are asked to indicate which seems most likely to be intentionally produced. Each stimulus is presented with each other stimulus to each participant.
My hypothesis is that a given property of the stimuli is predictive of which stimuli are going to be more likely to be indicated as intentional. I also want to control for “random effects” of stimuli, and participant variability in assessing the property.
The difficulty is that each trial has two stimuli, and the same stimuli can sometimes happen in the left and sometimes in the right.
With much help from Richard McElreath, I put this together in Stan: contest_outcome_raters.stan · GitHub
which works just fine.
However, I was wondering whether this was possible to create in brms as well
A null model (with no role of the hypothesized feature) could be:
fit0 <- brm(Outcome ~ 1 +
(1 | mm(StimulusRight, StimulusLeft)),
data = d,
family=bernoulli)
This works.
A model including the feature (coded as numeric -1,0,1) could be (intuitively):
fit1 <- brm(Outcome ~ 1 + mm(FeatureRight,FeatureLeft) +
(1 | mm(StimulusRight, StimulusLeft)) +
(1 + mm(FeatureRight,FeatureLeft) | ID),
data = d,
family=bernoulli)
However, this generates the error
Error in model.frame.default(bterms$allvars, data, na.action = na.action, :
invalid type (list) for variable ‘mm(PeriodR, PeriodL)’
The mm() help page indicates this could work:
d$Feature = (d$FeatureR + d$FeatureL) / 2
fit1a <- brm(Outcome ~ 1 + Feature +
(1 | mm(StimulusRight, StimulusLeft)) +
(1 + mmc(FeatureRight,FeatureLeft) | ID),
data = d,
family=bernoulli)
This also gives an error
Error: ‘mmc’ is only supported in multi-membership terms.
which suggests this can only be applied to “random slopes” on the mm random intercept.
Any better way of implementing what I am trying to in brms?