Estimate variance components for different groups

Dear all,

Just want to say first that I am a big fan of brms.

Currently, I want to compare variance components (group level estimates) and repeatability between two treatment groups. At the moment, I have been subsetting my data, running the same models using each subset data to estimate the variance components I wish to compare. However, I feel like this method reduces my statistical power. I have implemented this form of estimation in MCMCglmm previously using syntax such as: “random = ~us(sex):ID”. Is there a way to specify this in brms to estimate variance components for each treatment group and avoid subsetting my data.

My model structure looks like this

cc_mod.z3.1.obj <- brm(lnmr ~ treatment*z_temp + z_lnmass + z_age + (1 | id) + (1 | samp_session) + (1 | series_temp),
                     data = data, 
                     chains = 4, cores = 1, iter = 4000, warmup = 1500, thin = 5,
                     control = list(adapt_delta = 0.99))
  • Operating System: Mac OSX High Sierra 10.13.6
  • brms Version: 2.14

Apologies for such an old brms version, I am writing up my thesis right now and am too scared to update anything!

I think the by argument of gr() could help, as in (1 | gr(id, by = sex))

1 Like

Thank you Paul! It worked perfectly!