# Spatial and spatial temporal model problem autocorrelation

I’m trying to implement a spatial model explained in :
http://mc-stan.org/users/documentation/case-studies/mbjoseph-CARStan.html

model
{
phi ~ sparse_car(tau, alpha, W_sparse, D_sparse, lambda, n, W_n);
sigma2 ~ inv_gamma(1,1);
alpha~uniform(0,1)

``````tau ~ gamma(2, 2);
for (i in 1:n)
{
y[i] ~ poisson_log((log_offset[i]) + phi[i])));
}
``````

And this is very good,no autocorrelation in the traceplot,convergence
after,to try, i get the data in 5 years and ,for every year (5 year in total)

model
{

#2015

alpha[5]~uniform(0,1);
tau[5] ~ gamma(2,2);

phi15 ~ sparse_car(tau[5], alpha[5], W_sparse, D_sparse, lambda, n, W_n);
#2014
alpha[4]~uniform(0,1);
tau[5] ~ gamma(2,2);

phi14 ~ sparse_car(tau[4], alpha[4], W_sparse, D_sparse, lambda, n, W_n);
#2013
alpha[3]~uniform(0,1);
tau[5] ~ gamma(2,2);

phi13~ sparse_car(tau[3], alpha[3], W_sparse, D_sparse, lambda, n, W_n);
#2012
alpha[2]~uniform(0,1);
tau[5] ~ gamma(2,2);

phi12 ~ sparse_car(tau[2], alpha[2], W_sparse, D_sparse, lambda, n, W_n);
#2011
alpha[1]~uniform(0,1);
tau[5] ~ gamma(2,2);

phi11~ sparse_car(tau[1], alpha[1], W_sparse, D_sparse, lambda, n, W_n);

for (i in 1:n)
{
y2015[i] ~ poisson_log((((log_offset15[i])+ phi15)));
}

for (i in 1:n)
{
y2014[i] ~ poisson_log((((log_offset14[i])+ phi14)));
}

for (i in 1:n)
{
y2013[i] ~ poisson_log((((log_offset13[i]) + phi13)));
}

for (i in 1:n)
{
y2012[i] ~ poisson_log((((log_offset12[i]) + phi12)));
}

for (i in 1:n)
{
y2011[i] ~ poisson_log((((log_offset11[i])+ phi11 )));
}

and the traceplot are terrible;i don’t understand why.

1 Like

Just glancing at this (not really familiar with CAR models), are these typos on the index of `tau`?

``````alpha[4]~uniform(0,1);
tau[5] ~ gamma(2,2);
``````
``````alpha[3]~uniform(0,1);
tau[5] ~ gamma(2,2);
``````
``````alpha[2]~uniform(0,1);
tau[5] ~ gamma(2,2);
``````
``````alpha[1]~uniform(0,1);
tau[5] ~ gamma(2,2);
``````

? Should the index on tau match the index on alpha?