Brms & covariance among random effects

I am interested in specifying correlation among random effects in brms. Suppose, for example, you have individuals that serve as both the subject (animal) expressing a single phenotype and an environment (foster) for other individuals expressing that same phenotype. You are interested to know whether individuals who express higher levels of a trait also elicit higher levels of that trait in the individuals that they foster-parent. Is there a way to directly estimate this covariance in brms?

For example, in MCMCglmm:
phenotype ~ 1, random=~str(animal + foster), rcov=~units

My second question is whether the above can be extended to a multiple membership model. I have a scenario with individuals who express a trait and who interact with multiple other individuals, and I am interested in the covariance between an individual’s expression and his (social) influence on others.

  • Operating System: Mac OS 10.13.6
  • brms Version: 2.0.1

First, I would suggest updating your brms to the lastest CRAN version (2.4.0).

You can read more about the models you want in vignette("brms_multilevel") and (incidentally) in vignette("brms_multivariate").

Thank you, I updated to brms 2.4.0. I have read both vignettes, but I do not see how to do what I describe. Here is an example below with the error message.

In this scenario, the same individuals show up in multiple grouping factors, and I am interested in the covariance/correlation between these effects. Ultimately, I would like to extend to a multiple membership model but I cannot see how to do this even in the simpler model below. Many thanks for any help you can provide.

DATA <- data.frame(focalID=rep(as.character(1:100),each=5), alterID=sample(rep(1:100,each=5)), Time=rep(seq(1,5, by=1),100), focalEFFECT=rep(runif(100,10,20),each=5))
DATA$alterID <- factor(DATA$alterID); DATA$focalID <- factor(DATA$focalID, levels=levels(DATA$alterID))
DATA$alterEFFECT <- DATA$focalEFFECT[match(DATA$alterID, DATA$focalID)]
DATA$focalEFFECT <- DATA$focalEFFECT + rep(rnorm(100,0,2), each=5)
DATA$X1 <- DATA$focalEFFECT - DATA$alterEFFECT + rnorm(500,20,5)

library(brms)

set.seed(101)
mod <- brm(X1 ~ Time + (1|ID|focalID) + (1|ID|alterID), data=DATA, cores=1, chains=1, iter=500)

Error: Can only combine group-level terms of the same grouping factors.

I am sorry, I misunderstood what you were trying to do. Currently, it is not possible to model varying effects as correlated across grouping variables. Maybe I can implement this, though, I just need to think of it a little bit more.

As you will have read, multi-membership terms can be specified via the mm() function, but given that you are interested in specific correlation, I am not sure this will be of help.

Ok, thank you very much!

Would you mind opening an issue about this on https://github.com/paul-buerkner/brms/issues ?
That way we can better keep track of the progress.

Done, thanks.

Hi just thought to put the link to the GitHub issue here for easier tracking: covariance among distinct random effects with the same levels · Issue #502 · paul-buerkner/brms · GitHub