Hello, I am just starting with stan, and was hoping to use it for phylogenetic comparative methods. I was following a tutorial which I found to try to learn how to do this ( Estimating Phylogenetic Multilevel Models with brms) , and using the sample data of the tutorial it worked fine. So I decided to try to run it on my own data, as follows:
A <- ape::vcv.phylo(SSBTreeEdge)
model_global <- brm(
OSSB ~ Sexual_Dichromatism_Score +
Sexual_Size_Dimorphism_Percent_Imputed + Sexua_Dichroamtism_Binary_Imputed +
Female_Song_Present + devo_mode + breedsys_known + median_clutch_size +
Pop_Density_Log + (1|gr(SSBTreeEdge, cov = A)),
data = SSBDensityImputed,
family = gaussian(),
data2 = list(A = A),
chains = 4, iter = 500000, thin = 5000,
prior = c(
prior(normal(0, 10), "b"),
prior(normal(0, 25), "Intercept"),
prior(student_t(3, 0, 20), "sd"),
prior(student_t(3, 0, 20), "sigma")
)
)
)
Where SSBTreeEdge is the phylo object with branch lengths of the species which I am interested in my analysis. However, when I did this, I got the following error:
Error: The following variables can neither be found in 'data' nor in 'data2':
'SSBTreeEdge'
I tried two ways to get SSBTreeEdge into data2, one was to mate SSBTreeEdge = A, and the other to make A = SSBTreeEdge. The latter got me the error:
Error in UseMethod("isSymmetric") :
no applicable method for 'isSymmetric' applied to an object of class "phylo"
and the former got me the error of
Error: Object 'A' was not found in 'data2'.```
How do I resolve this issue so that I can include the phylogeny in the covariance matrix