Hi,

I am relatively new to Stan and I have not been able to solve this problem. I am modeling daily arrivals at a refugee camp (y) considering people are arriving from many areas in conflict (matrix X with each column a conflict zone, and each row a day). The parameter beta is the proportion of people contributing from each conflict zone but it depends on the distance from the conflict zone to the camp (if the camp is further away, the probability of going there would decrease because there are many other refugee camps). If I run the model just considering this, it works but if I add an autoregresive term with the arrivals at the camp the previous day (ylag with parameter eta), I get a compiling error. It must be a simple fix but I have not been able to figure it out.

Any thoughts would be greatly appreciated.

When including Stan code in your post it really helps if you make it as readable as possible by using Stan code chunks (```stan) with clear spacing and indentation. For example, use

```
data {
int N; //number of days of confict
int K; //number of conflict zones
int <lower=0> y[N]; //refugee arrivals at the camp
int <lower=0> ylag[N]; //refugee arrivals at the camp the previous day (t-1)
matrix[N,K] X; //daily departures of refugees from conflict zones
real dis[K]; //Distances from each conflict zone to the camp (in log km)
}
parameters {
real <lower=0> alpha;
real f; // for the estimation of beta based on distances
real eta; //for the autorregressive term
vector [K] c; // intercept for the estimation of beta based on distances
}
transformed parameters {
vector[K] beta; //Dependends on the distance to the camp
for (i in 1:K){
beta[i] = c[i] + f*(1-tanh(dis[i]));
}
}
model {
alpha ~ normal(4,10); //the mean set as mean(log(Y)) across all camps
f ~ uniform (0,10);
c ~ normal (0,2.5);
eta ~ normal (0,2.5);
y~poisson_log(alpha +X*beta +ylag*eta); //the error is here in ylag*eta
}
"
```