Hi,

I have programmed two 1st-order random walk models that, in principle, should be equivalent but I obtain different results. The first model corresponds to a full-conditional formulation of a Poisson time series where each element of the series is conditioned to the rest of the series (both “past” and “future”), the second model corresponds to the traditional formulation of random walk time series where each observation is conditioned just on its past.

Specifically, the first of the models is:

```
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real beta;
real<lower=0> sigma_phi;
vector[N] phi;
}
model {
y ~ poisson_log(beta + phi * sigma_phi);
phi[1] ~ normal(phi[2],1);
phi[2:(N-1)] ~ normal((phi[1:(N-2)]+phi[3:N])/2, 2^(-0.5));
phi[N] ~ normal(phi[N-1],1);
mean(phi) ~ normal(0, 0.001);
}
generated quantities {
vector[N] mu = exp(beta + phi * sigma_phi);
}
```

and the second

```
data {
int<lower=0> N;
array[N] int<lower=0> y;
}
parameters {
real beta;
real<lower=0> sigma_phi;
vector[N] phi;
}
model {
y ~ poisson_log(beta + phi * sigma_phi);
for(i in 2:N){
phi[i] ~ normal(phi[i-1], 1);
}
mean(phi) ~ normal(0, 0.001);
}
generated quantities {
vector[N] mu = exp(beta + phi * sigma_phi);
}
```

I have used improper flat prior distributions for beta, phi[1] (in the second model) and sigma_phi (on the positive real line). I have called these two models (“RW_fullcond.stan” and “RW_past.stan”) from R by doing

```
# Call to the full conditional model
data = list(N=length(y), y=y)
set.seed(123)
fit.RW.fullcond <- stan(file = "RW_fullcond.stan", data = data, chains = 3, iter = 5000)
# Call to the model conditioning on the past
set.seed(1)
fit.RW.past <- stan(file = "RW_past.stan", data = data, chains = 3, iter = 5000)
```

where I obtain the following summary statistics for sigma_phi:

```
summary(fit.RW.fullcond)$summary["sigma_phi",]
# mean se_mean sd ...
# 0.04345 0.00324 0.01735 ...
summary(fit.RW.past)$summary["sigma_phi",]
# mean se_mean sd ...
# 3.70e-01 3.15e-03 9.16e-02 ...
```

corresponding differences were also observed for phi, even for mu.

What are these differences due to? Does Stan maybe missunderstand the cyclic conditional relationships of the full conditional model? Should I avoid model formulations of that kind in Stan (JAGS and Nimble do not allow them)? Is this documented anywhere?

Thanks in advance.