Varying slope with phylogenetic structure


I just looked at the vignette “Estimating Phylogenetic Multilevel Models with brms”. Really cool stuff.

Towards the end it’s mentioned that it would be possible to estimate a varying intercept and a varying slope for these models. Does anybody has an example on how to write such models?

Thanks a lot in advance!


Please also provide the following information in addition to your question:

  • Operating System: macOS high sierra
  • brms Version: 2.5

If x is your variable for which you want to model a varying slope, replace (1 | phylo) with (1 + x | phylo).

1 Like

Ah! thanks a lot!
It was indeed quite slow as you warned.

I was trying to understand how these models work and I am puzzled that the Cholesky factor obtained via make_standata is different from what I get using chol(as.matrix(A)).

That is, using the example from the vignette, if I do

d <- make_standata(
phen ~ cofactor + (1|phylo), data = data_simple,
family = gaussian(), cov_ranef = list(phylo = A))

then d$Lcov_1 has different values than chol(as.matrix(A))

Is there something I’m missing?

brms sorts the rows and columns according to the levels of the grouping factor and then transposes the cholesky factor as R and Stan have different definitions of cholesky factors. See brms:::data_gr for the code.

great, thank you!