Hello, I’m working on spatial data by a GLMM.

The model reads,

y \sim binomial\left ( n,p \right )

p= logit(\eta)

\eta = \alpha + X\beta + \phi

\phi \sim MVN(0, \left [ \tau_{\mu}\left ( I-\lambda W \right )\left ( I-\lambda {W} \right )' \right ]^{-1} )

The stan code that I use

```
data{
int<lower=1> N;
int y[N];
int nTrials[N];
int<lower = 1> K;
matrix [N, K] X;
matrix<lower=0, upper=1>[N,N] I;
matrix<lower = 0 >[N, N] W;
}
transformed data{
vector[N] zeros;
zeros = rep_vector(0, N);
}
parameters {
real alpha;
vector[K] beta;
vector[N] phi;
real<lower = 0> tau;
real<lower = -1, upper = 1> lambda;
}
transformed parameters {
vector[N] eta;
eta = alpha + X * beta + phi;
}
model {
phi ~ multi_normal_prec(zeros, tau * crossprod(I - lambda * W));
alpha ~ normal(0,1000);
beta ~ normal(0,1000);
tau ~ gamma(2, 2);
lambda ~ uniform(-1,1);
y ~ binomial_logit(nTrials, eta);
}
```

It works, but it runs very slow on STAN. I wonder whether there are some ways (i.e. coding tricks) to accelerate this model on STAN?

Thanks in advance.

Charles