Adjacency matrix in CAR model

Okay, then if it’s NA, I would set it up as a missing value problem.

CAR model is a special kind of multivariate normal, and I would keep the same dimensions throughout the study i.e. use the same adjacency matrix for both years.

And then you need some way of dealing with NaN in the model. PyMC has methods for this and you can follow the detailed docs and the blog posts.

docs: Bayesian Missing Data Imputation — PyMC example gallery

And some general tips on the model:

  • Not sure how you came up with pm.Gamma("tau_ind", alpha=3.2761, beta=1.81) but that’s very specific. If you set the prior based on prior knowledge of the problem, we have a helper function find_constrained_prior
  • PyMC has broadcasting so you can just write pm.CAR("phi", mu=0.0, tau=tau_spat, alpha=alpha, W=adj_matrix, dims="area_idx") and the mean zero will effectively be filled as a vector
  • with the sampling, I’d probably just leave the NUTS defaults. You can play around with tuning if you want but I’d wait for the model to create divergences first. Same with the starting values: this is common practice for Gibbs sampling packages like JAGS, but here I would just let PyMC decide
1 Like