Variance/Covariance from brm random slopes model

@paul.buerkner

Assume a standard random slopes model:

mod <- brm (1 + x + (1+x|id), data = dat)

Is it a safe assumption that it would be straightforward to calculate the variances and covariance from the posterior samples? Something like:

post <- posterior_samples(mod)
post$intercept_variance <- post$sd_id__Intercept^2
post$slope_variance <- post$sd_id__x^2
post$covariance <- post$cor_id__Intercept__x * post$sd_id__Intercept * post$sd_id__x

That seems like it would do the trick, but it’s not clear if there are things “under the hood” of a brm model that should be kept in mind. Danke!

1 Like

this looks correct to me.

1 Like