Hi, I was wondering if there’s currently a way to easily fit besag and bym CAR models in brms.

Thanks,

Paul

Hi, I was wondering if there’s currently a way to easily fit besag and bym CAR models in brms.

Thanks,

Paul

To be honest, I am lost in the various names of CAR models and always forget which of those is named how. The CAR models supported in brms are explained in two case studies, which are linked to under `?cor_car`

. It may very well be that one of those (perhaps the one by @mitzimorris?) also goes under one of the names you mentioned.

the functions for the CAR models are those supplied in the Max Joseph case study:

https://mc-stan.org/users/documentation/case-studies/mbjoseph-CARStan.html

the Stan code itself is here:

I wrote a case study on the ICAR models: https://mc-stan.org/users/documentation/case-studies/icar_stan.html - the critical implementation detail there is the use of a soft sum-to-zero constraint for the ICAR component which really speeds up computation.

I thought that RStanArm implemented the R package `car-bayes`

- maybe @bgoodri knows the status of this?

1 Like

Imad had a branch but we haven’t merged it. I’m not sure if it is ready but we really can’t add any more models to rstanarm until the compilation time goes way down.

Thanks, I’ve gone through your case study as well as a recent publication that used a similar approach. It is hard for me to tell if the ICAR specification in brms is equivalent to a bym model, though.

the devil’s in the definition of ‘BYM model’. I think the answer is no - the BYM model is a Poisson GLM with both a multi-variate normal random effects component as well as an ICAR component and you can’t just do that. there are lots of flavors of BYM models.

I would love to see the BYM2 model go into BRMS - @paul.buerkner is this feasible? how can I help?

1 Like

Thanks @mitzimorris for offering to help out. I am not an expert for these kinds of models so first I need to see the mathematical formulation of the BYM2 model, before I can judge if is feasible in brms. Is such a formulation available somewhere?

mathematical formulation (thanks @Daniel_Simpson!) in this paper: https://arxiv.org/pdf/1403.4630.pdf, equation 6.1

and more discussion of BYM models in Riebler et al: https://arxiv.org/pdf/1601.01180.pdf

and it would be super-cool to add in stuff I worked out for maps which have disconnected sub-regions - see this paper - https://www.sciencedirect.com/science/article/abs/pii/S1877584517301600?via%3Dihub

1 Like

Thanks! This is very helpful. It is only now that I realize you are discussing the BYM2 model in your case study already. Please excuse my question for a reference earlier. I should have looked at your case study beforehand.

Just for clarity, what you discuss in your case study as ICAR model (and what I have implemented in brms via `cor_icar`

), is some flavor of the classical BYM model, right? More precisely, when me model

```
brm(y ~ ... + (1 | obs), family = poisson(), autocor = cor_icar(...))
```

where `obs`

is an indicator of the rows (i.e. unique per observation), we end up with the BYM model you discuss in Section “Example: disease mapping using the Besag York Mollié model”. Is my understanding correct?

Provided that the above is roughly correct, The BYM2 model (where we have a joint prior over the spatial and non spatial residuals) should be relatively straightforward to implemented. From the user perspective it would simply look like

```
brm(y ~ ..., family = poisson(), autocor = cor_icar_het(...))
```

(or a better name than `cor_icar_het`

for the icar structure with depending non-spatial residuals) as the non-spatial residuals are now part of the autocorrelation structure so `(1|obs)`

is no longer needed.

I will take a look at the disconneted sub-regions paper later and then respond separately.

not really - it’s an ICAR model as introduced in Besag 1974. the innovation of the BYM model was to add a 2nd component for extra-spatial variation. Max Joseph implemented both the CAR and ICAR models in Stan. my understanding is that the epidemiologists use some version of the BYM model, and that they generally use INLA to fit it.

That makes sense. Thanks for taking the time to help me understand this topic. I have opened an issue for brms (https://github.com/paul-buerkner/brms/issues/710) so that I don’t forget to work on this topic.

3 Likes

Thanks to both of you! Yes it’s something that I have to use INLA for at the moment, and while INLA has its difficulties to learn it is straightforward to bring in a shapefile from GIS, build an adjacency matrix, and plug that into a besag or bym model in INLA.

what format, exactly? the Stan model is written in terms of the set of <i,j> edges in the graph - we can handle the conversion - it’s just a matter of deciding on the set of accepted input formats and documenting them properly.

1 Like

I believe I’ve been using the nb2adj function in spdep, starting with a shapefile.