I have now been working with phylogenetically corrected models in brms for the past two years. I noticed that the previously used cov_ranef function was now replaced with a grouping argument inside the gr function. However, when I tried the implement the same structure as the one I used with cov_ranef, I get the following error: Grouping structure ‘gr’ expects only a single grouping term. I am not well versed enough to understand specifically what it means as I only have one grouping factor in my very simple database. I therefore looked at the example that was posted in the phylogenetic vignette of brms and copied it into my R session. However, I still get the same error when trying to run the model… Would you be able to help me on how to solve this issue?

All the best!

Antoine

Session info:
R version 4.0.0 (2020-04-24)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

phylo <- ape::read.nexus("https://paul-buerkner.github.io/data/phylo.nex")
data_simple <- read.table(
"https://paul-buerkner.github.io/data/data_simple.txt",
header = TRUE
)
A <- ape::vcv.phylo(phylo)
model_simple <- brm(
phen ~ cofactor + (1|gr(phylo, cov = A)),
data = data_simple,
family = gaussian(),
data2 = list(A = A),
prior = c(
prior(normal(0, 10), "b"),
prior(normal(0, 50), "Intercept"),
prior(student_t(3, 0, 20), "sd"),
prior(student_t(3, 0, 20), "sigma")
)
)
Output: Error: Grouping structure 'gr' expects only a single grouping term

If you need to use math formula, use Latex syntax:

Y \sim N(\mu, \sigma)

Don’t forget to attach tags (top right of this form) for application area/class of models or other general subject areas your topic touches on.

I am having the same error with my own data and the " Estimating Phylogenetic Multilevel Models with brms" vignette simple data. brms version is 2.13.5

I am running this on our compute cluster here with R version 3.5.1. Could that be contributing to it?

I don’t think you have brms 2.13.5 on the system as cov argument exists there already. For what it’s worth, try out also the latest github version of brms.

I am having issues with the devtools package on our cluster, bur installed the github version on my personal machine and the grouping issue was fixed. Thanks Paul!

I encounter the same problem on our cluster. brms is version 2.9.0; R version 3.6.1 (2019-07-05).

I am using Miniconda and I don’t think I can install any newer versions of R/brms, but I will find out. Is there a work around for this cluster set up with older versions of brms/R? Should I use cov_ranef instead?