Grouping structure 'gr' expects only a single grouping term

Dear Paul,

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.

Your brms version is likely just out of date.

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.

Here is the code and results from our server:

> 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")
+   )
+ )
Error: Grouping structure 'gr' expects only a single grouping term

 > packageVersion("brms")
[1] ‘2.13.5’


> version
               _
platform       x86_64-pc-linux-gnu
arch           x86_64
os             linux-gnu
system         x86_64, linux-gnu
status
major          3
minor          5.1
year           2018
month          07
day            02
svn rev        74947
language       R
version.string R version 3.5.1 (2018-07-02)
nickname       Feather Spray

Can you try again with the brms gihub version?

Dear Paul,

I just updated my brms version to 2.13.5 using github and it works perfectly now!

Thank you for your help!

Antoine

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?

Many thanks,
Annemarie