Issues fitting phylogenetic brms model

Hi,

I am trying to fit a phylogenetic regression using brms but it seems that the model can’t find the tree even though everything else works file.

I get the error “Error: The following variables can neither be found in ‘data’ nor in ‘data2’:
‘phylo’”

Any help is greatly appreciated

#import Data
root.high<-read.csv(file="Data/roothigh.data.csv")
phylo <- ape::read.tree(file = "Data/Phylogeny/Tree2.txt")
[Tree2.txt|attachment](upload://xFYGBeg4tOebVn9pEA0ZLlupumG.txt) (924 Bytes)

A <- ape::vcv.phylo(phylo,corr = FALSE)

library(brms)
model_simple <- brm(
  Number.of.Root.Tips ~ Treatment + (1|gr(phylo, cov = A)), 
  data = root.high, 
  family = gaussian(), 
  data2 = list(A = A))

roothigh.data.csv (3.5 KB)
Tree2.txt (924 Bytes)

Where the brms phylogenetic regression vignette has (1|gr(phylo, cov = A)), phylo refers to a column of the dataframe, not to the object named phylo that is loaded into the R environment. This column needs to contain the species names in the data that are matched to the tree. That is, write (1|gr(species_column, cov = A)), where species_column is the name of the column root.high that contains species names matched to phylo.

@paul.buerkner it might be worth changing the vignette so that phylo isn’t re-used in these two different contexts.

Wow yes this fixed it THANK YOU

1 Like