Custom distance matrix for GP terms in brms

Hello all,

There is a growing interest in regression models with a latent Gaussian process in my field, and I was really happy to see the addition of more covariance kernels in brms, particularly ones which are useful for spatial and phylogenetic analysis, like Matern 3/2 and 1/2.

The main limitation of brms for both spatial and phylogenetic analysis is that there is no way, to my knowledge, of giving the model a precomputed matrix of distances as input (e.g. cophenetic distances between nodes in a tree, or geodesic distances for spatial analysis). I know that it’s possible to implement this in Stan by coding the kernel function myself, but it would greatly increase the accessibility of these methods if they were available in brms. Particularly since the Matern kernels (which are so useful for spatial modelling) are available now, it would be fantastic to be able to to use more realistic distance metrics than Euclidean distance.

Is this something that there is interest in implementing in the near future? What are the main obstacles to doing so?

Thank you for taking the time to read this!

MM

Are you aware of the ability to pass data via the data2 argument? See Estimating Phylogenetic Multilevel Models with brms

Or is this not what you need?

Yes, I am aware of this, but it doesn’t work with a GP term. This kind of phylogenetic model doesn’t work exactly the same way, and in any case, it wouldn’t work for modelling geodesic distances with a GP.

My issue is essentially the same as what’s discussed in this thread: Custom distance metric with gaussian process - #6 by Matias_Guzman_Naranjo

If you’re hiring, paying, I can probably add some of this in the math library, but this is something that might be better handled using the Stan modeling language. BRMS is sweet, but you’re sacrificing a bit of the modeling language flexibility of using just Stan.