I’m pretty new to brms. I’m attempting to write a model with crosses random effects and with one of those random effects also nested within another hierarchical category. I think I’m writing basic underlying cross-classified model correctly, but I’m not entirely sure how to add in the multi-level component into the brms model. So I’d greatly appreciate any suggestions for specifying the more complex model.
Some background about the data structrure:
The dataset consists of download actions (did or did not download) for a large number of subjects and preprints. Preprints are categorized by whether they have a COI or not (non-manupulated fixed factor, coi_cond). Subjects are randomly assigned to 1 of 2 visibility conditions which alters whether they see a preprints COI information (vis_cond variable). Subjects can have download action data for >= 1 preprint. Across the preprint they have download data for, subjects stay in the same vis_cond, but may naturally encounter preprints in different coi_cond categories. Preprints stay in the same coi_cond regardless of which subjects have download data for them, but by chance may ended up having data in both vis_conds because of the subjects who view them. I’m interested in estimating the interaction between the coi_cond and vis_cond variables and their simple effects.
I think I have the code for this ‘basic’ model with:
single_level_model <- brm(
download ~ coi_cond + vis_cond + coi_cond*vis_cond + (1|subj_id) + (1|pp_id) + (coi_cond|subj_id) + (vis_cond|pp_id),
family = ‘bernoulli’,
seed = 5)
The part that I’m having trouble with is how to add in a level of nesting when preprints can belong to only 1 service but subjects can potentially have multiple membership in services. Each preprint belongs to one of ~20 different preprint services. Each preprint belongs to only 1 service, but subjects may have download data associated with multiple different services. There is reason to believe that the effects of coi_cond and vis_cond may not be the same in each service, and so I’d like to add this service level in, get an estimate of the degree to which the vis_cond*coi_cond interation and it’s simple effects vary across service, as well as estimates of these effects within each service. Does anyone have suggestions on how to incorprotate the service information into the model?