Please also provide the following information in addition to your question:

- Operating System: macOS Mojave v 10.14.2
- brms Version: 2.8.0

Hello all,

I just wanted to ask about including two matrices to describe the covariance structure of the group-level effects using brm(). Essentially I have a model with a binary y variable and several predictors, and I want to account for both phylogenetic and spatial dependence. I used brm(), adding the two matrices in the cov_ranef argument. From what I understand, in the current implementation, the model assumes both these matrices have equal contribution - is this correct(?) or is it possible for the model to return the variance parameters associated with each matrix separately?

I am adapting this from the lmekin() function in coxme(), which unfortunately only deals with continuous response variables. But in there, the variance structure is fitted as V=s1A + s2B, where A and B are two matrices given as input, and the variances s1 and s2 are parameters that lmekin() is optimizing and returning.

Many thanks!

Example dummy code:

set.seed(123)

inv_logit <- function(x) 1 / (1 + exp(-x))

ability <- rnorm(100)

p <- 0.33 + 0.67 * inv_logit(ability)

answer <- ifelse(runif(100, 0, 1) < p, 1, 0)

dat_ir <- data.frame(ability, answer)

dat_ir$species<-as.character(1:100)

#create two covariance matrices

n <- 100

A <- matrix(runif(n^2)*2-1, ncol=n)
Sigma <- t(A) %*% A

rownames(Sigma)<-colnames(Sigma)<- dat_ir$species

n <- 100

A <- matrix(runif(n^2)*2-1, ncol=n)
Sigma2 <- t(A) %*% A

rownames(Sigma2)<-colnames(Sigma2)<- dat_ir$species

model <- brm( answer ~ ability + (1|species), data = dat_ir, family = bernoulli(), cov_ranef = list(species = Sigma, species=Sigma2))