Multiple-membership multilevel models with repeated measures

I have longitudinal data from approximately 55,000 participants, 5 observations each. These participants are nested within counties, and I am interested in looking at county-level predictors. However, approximately 20% of the cohort moved to a new county over the study period, and so I would like to fit a multiple membership multilevel model (using brms). In the paper “Advanced Bayesian multilevel modeling with the R package brms” by @paul.buerkner, he provides the following code for a multiple membership multilevel model:

fit_mm <- brm(y ~ 1 + (1 | mm(s1, s2)), data = data_mm)

where s1 and s2 are the clustering variable at time 1 and time 2, respectively. As such, the data is in wide format: However, to be able to fit a traditional multilevel model for repeated measures, the data will need to be in long format. Is there a way to fit a multiple membership model with repeated measures using brms? If so, how should the data be structured, and what would the code look like? Thank you!

1 Like