Hello all, this is the first time I using Stan, I want to ask some naïve questions about Multinomial distribution.

My data like this form

Ob1 Ob2 Ob3

16 17 7

10 20 10

…

which there are T times data set with three objects that each time’s total is 40.

Therefore I want to use multinomial distribution to estimate parameters.

My process model is

Y_t = U + B * Y_t-1 + W

where Y is time t’s data, which should be a 3*1 matrix mathematically.
And U is a 3*1 parameter vector, B is a 3

*3 parameter matrix.*

W is the 31 error term.

W is the 3

My stan code as follows

```
functions{
matrix B_r(matrix B){
matrix[3,3] B_r;
B_r[1,1]=B[1,1];
B_r[1,2]=B[1,2];
B_r[2,1]=B[2,1];
B_r[2,2]=B[2,2];
B_r[1,3]=0;
B_r[2,3]=0;
B_r[3,3]=0;
B_r[3,2]=0;
B_r[3,2]=0;
return B_r;
}
vector U_r(matrix U){
vector[3] U_r;
U_r[1]=U[1,1];
U_r[2]=U[2,1];
U_r[3]=0;
return U_r;
}
}
data{
int<lower=0> T;
int<lower=0> Sp;
int<lower=0> y[T,Sp];
real min_log_y;
real max_log_y;
}
parameters{
vector<lower = min_log_y, upper = max_log_y>[T] log_y[3];
matrix<lower=0>[1,3] U;
matrix[3,3] B;
matrix[3,1] sigma;
}
transformed parameters{
vector[3] P;
P[1]=y[T,1];
P[2]=y[T,2];
P[3]=y[T,3];
}
model{
// Data Model ===================================
for (t in 1:T){
y[t] ~ multinomial(P/40);
}
// End of Data Model ===============================
// Process model============================
for (t in 2:T){
log_y[t,]~ multi_normal(U_r(U) + B_r(B)*log_y[t-1], sigma);
}
sigma[,1] ~ uniform(0,1000);
U[,1] ~ normal(0,100);
//End of process model
}
generated quantities{
vector [2] U_op;
matrix [2,2] B_op;
matrix [2,1] sigma_op;
U_op[1] = U_r(U)[1];
U_op[2] = U_r(U)[2];
B_op[1,1] = (1-B_r(B)[1,1])/U_op[1];
B_op[1,2] = -B_r(B)[1,2]/U_op[1];
B_op[2,2] = (1-B_r(B)[2,2])/U_op[2];
B_op[2,1] = -B_r(B)[2,1]/U_op[2];
sigma_op = sigma;
}
```

Then I use rstan to fit this model, the code i used is

fit <- stan(file = “0208.stan”, data = MB2_3, pars = c(“U”,“B”,“sigma”), warmup = warmup, iter = iter, chains = 3, thin = thin)

But there is a error occurred as follows

here are whatever error messages were returned [[1]] Stan model ‘0208’ does not contain samples.

I am sorry for my ignorance. If possible please give me some advice, thank you very much!