Hey everyone!

I’m trying to perform the NUTS with Stan, but I keep repeatedly getting the following error when I try to use stan_model():

rstan:::rstudio_stanc(“scriptStan_tp2.stan”)

Error in stanc(filename, allow_undefined = TRUE) : 0

Semantic error in ‘string’, line 50, column 6 to column 40:

Ill-typed arguments to ‘~’ statement. No distribution ‘poisson’ was found with the correct signature.

I’ve tried multiple things, checked my data, but everything seems correct. Could anyone please help me?

Thats my code:

```
// data block
data {
int<lower=1> n;
int<lower=1> t;
vector[n] E;
matrix[n,t] X1;
matrix[n,t] X2;
matrix[n,n] Sig_delta;
matrix[t,t] Sig_gamma;
real m0;
real m1;
real m2;
real <lower=0> v0;
real <lower=0> v1;
real <lower=0> v2;
real <lower=0> a_phi;
real <lower=0> b_phi;
real <lower=0> a_delta;
real <lower=0> b_delta;
real <lower=0> a_gamma;
real <lower=0> b_gamma;
}
// parameters block
parameters {
real beta0;
real beta1;
real beta2;
real<lower=0> tau_phi;
real<lower=0> tau_delta;
real<lower=0> tau_gamma;
matrix[n, t] phi;
vector[n] delta;
vector[t] gamma;
}
// transformed parameters block
transformed parameters{
matrix[n, t] theta;
for(i in 1:n){
for(j in 1:t){
theta[i, j] = exp(beta0 + beta1*X1[i,j] + beta2*X2[i,j] + phi[i,j] + delta[i] + gamma[j]);
}
}
}
// model block
model {
matrix[n, t] Y;
// likelihood
for(i in 1:n){
for(j in 1:t){
Y[i,j] ~ poisson(theta[i,j]*E[i]);
phi[i,j] ~ normal(0, sqrt(tau_phi));
}
}
// priors
delta ~ multi_normal(rep_vector(0,n), tau_delta*Sig_delta);
gamma ~ multi_normal(rep_vector(0,t), tau_gamma*Sig_gamma);
tau_phi ~ gamma(a_phi, b_phi);
tau_delta ~ gamma(a_delta, b_delta);
tau_gamma ~ gamma(a_gamma, b_gamma);
beta0 ~ normal(m0, sqrt(v0));
beta1 ~ normal(m1, sqrt(v1));
beta2 ~ normal(m2, sqrt(v2));
}
```

Thank you very much!