 # Stability of random effects across waves

Hi all,

I aim to investigate stabilities of random effects (specifically random slopes) across waves of data collection. I was wondering if this was possible using multivariate brms models.

Specifically, it would be desirable to estimate a model including random slopes and random intercepts in three datasets simultaneously and then correlate the random slopes across datasets.

However, I believe brms requires all variables to be in the same data set (and datasets have different lengths across waves). As a solution that may work, I ordered assessments between waves and created separate variables for each wave (which leads to many NAs). Because data from waves should be independent, I set rescor to FALSE.

wave1 ← bf(dat1_y ~ dat1_x + (dat1_x|p|id))
wave2 ← bf(dat2_y ~ dat2_x + (dat2_x|p|id))
wave3 ← bf(dat3_y ~ dat3_x + (dat3_x|p|id))

fit_brm ← brm(wave1+wave2+wave3+set_rescor(FALSE), data = dat)

Does this approach strike you as reasonable for estimating correlations between random slopes across waves? Is there a more elegant way to specify that three separate datasets are used?

1 Like

I think I made this work by creating subset variables.

wave1 is TRUE when the data stem from wave1
wave2 is TRUE when the data stem from wave2

The data are in the long format and y1 and y2 are the same variable, brms did not allow the same outcome variable to be used twice (despite nonoverlapping subsets).

mod1 ← bf(y1|subset(wave1) ~ x + (x|p|id))
mod2 ← bf(y2|subset(wave2) ~ x + (x|p|id))

Fit_brm ← brm(mod1+mod2+set_rescor(FALSE), data = dat)

Does this seem like a reasonable approach to estimate random effects stabilities in brms or are there some issues I might be missing? Thank you so much in advance!

1 Like

Yes, this is definitely a sensible way to code the model. I presume the waves have overlapping subjects? Ohterwise the model wouldn’t make much sense. I am not completely sure it will let you say something about stability directly (notably because correlations requrie a lot of data to estimate with any degree of precision) and one could probably conceptualize stability in a different way than by correlations.

Also note that the approach you mentioned should be quite similar to having a marged dataset with `wave` as a predictor and then having: ` y ~ x * wave + (wave | id)`.

Best of luck with your model!