Phylogenetic repeated measures

I ran a phylogenetic analysis following these examples for repeated measures:
https://cran.r-project.org/web/packages/brms/vignettes/brms_phylogenetics.html

Nevertheless, this error always pops up, no matter if species names are the same for both data set and
the phylo tree
“Levels of the within-group covariance matrix for ‘phylo’ do not match names of the grouping levels.”

Checking species names with ‘geiger’:

name.check(data, phylo)
[1] “OK”

Code:
model_repeat1 ← brm(
v ~ bio1 + (1|gr(phylo, cov = A)) + (1|species),
data = data,
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”)
),
sample_prior = TRUE, chains = 2, cores = 2,
iter = 4000, warmup = 1000
)

  • Operating System: Windows 10
  • brms Version: 2.13.5

Any idea of what I am missing here?

Thanks in advance,
Rhainer

1 Like

This is a bit hard to debug without access to the data, but I think there needs to be a match between data$phylo and dimnames(A).

Best of luck with your model!

Hi Martin

The problem is that when we run check.names in Geiger, everything seems to match.

Prof. Dr. Rhainer Guillermo Ferreira
Lestes Lab
Departamento de Hidrobiologia
Universidade Federal de São Carlos
Fone: +55 16 3351-8316
www.lestes.ufscar.br

Yes but brms doesn’t run check names in geiger.

So perhaps geiger checks names differently than directly comparing names with the rownames of the matrix. Perhaps some names have a special encoding?

Would polytomies interfere somehow?

Prof. Dr. Rhainer Guillermo Ferreira
Lestes Lab
Departamento de Hidrobiologia
Universidade Federal de São Carlos
Fone: +55 16 3351-8316
www.lestes.ufscar.br

I dont know to be honest

Thanks, I’ll try to dig and post here if I find a solution.

1 Like

Did you find a solution?
I’m running into the same problem. I generated a tree with ete3 (python package) based on NCBI data, exported it to newick format, and then try to follow the vignette with my own data and phylogenetic tree. I did not manage to run it that way.

I am on linux with R version 4.1.2 .

It’s very hard to know what the problem is without any code or data. The row and column names of your covariance matrix need to exactly match the species names in your data. Try running e.g. setdiff(my_data$species, rownames(A)) and setdiff(rownames(A), my_data$species) to see any mismatched names.

Hi @Rhainer_Guille, was wondering if you ended up figuring this out! I have the same problem as you, (which I have described in a new post here.) Would love to hear if you solved this…
-Tracy