hi,
is that the Leroux spatial model? yes, it will be very slow - that’s a problem with the Leroux model.
There’s a great paper by Riebler et al that goes over these models and motivates the BYM2 model proposed by Dan Simpson: https://arxiv.org/abs/1601.01180
Based on that, we’ve developed the BYM2 model in Stan: https://mc-stan.org/users/documentation/case-studies/icar_stan.html
You can also use BRMS, which has implementions for the CAR and ICAR models.
The cor_errorsar(W) in brm is not identical to the random intercept model (The SAR structure is imposed on the variance-covariance matrix.) mentioned here. You can see that in a cor_errorsar(W) model, the spatial structure is built on the error term, but there is not an error term in binomial regression.
With the caveat that I have not tried this, I would use the non-centred parameterization. Sadly, Stan does not have anything that speeds up the computations based on the Markov property (yet), so there’s a limit to how fast it can be.
transformed data{
vector[N] zeros;
zeros = rep_vector(0, N);
}
parameters {
real alpha;
vector[K] beta;
vector[N] z; // non-centred phi
real<lower = 0> tau_sd; // Put this as the standard deviation NOT as precision
real<lower = -1, upper = 1> lambda;
}
transformed parameters {
vector[N] eta;
vector[N] phi;
// If I and W are symmetric then you don't need that transpose!
phi = (I - lambda * W)' \ z; // E(phi * phi') = ((I - lambda * W)' * (I - lambda * W))^{-1}
eta = alpha + X * beta + tau_sd * phi;
}
model {
z ~ normal(0,1);
alpha ~ normal(0, 3); // sensible priors on the logit scale
beta ~ normal(0, 3); // sensible prior on the logit scale
tau_sd ~ normal(0,3); // NB: This is a different prior to the one in your model!
lambda ~ uniform(-1,1);
y ~ binomial_logit(nTrials, eta);
}
I also put tighter priors on everything because the linear predictor is on the logistic scale so nothing is going to be outside [-5,5]