I’m new to Stan.

I coded Poisson mixture model by copying stan tutorial.

My code is here.

```
data {
int N;
int K;
int x[N];
}
parameters {
ordered[K] theta;
simplex[K] pi;
}
model {
real lp[K];
for(n in 1:N){
for (k in 1:K){
lp[k] = log(pi[k]) + poisson_lpmf(x[n] | theta[k]);
}
target += log_sum_exp(lp);
}
}
```

I learned to define theta as an order variable to escape label switching problem from this code.

Next, I want to model multinomial mixture model.

A situation what I thought is below.

There are two dices. One is normal dice whose probability of getting one particular value is all 1/6. Another one is cheating dice whose probability is not all same. I want to infer which dice is thrown from the result.

So, I modified my code like below.

```
data {
int N;
int S;
int K;
int x[S,N];
}
parameters {
simplex[S] theta[K];
simplex[K] pi;
}
model {
real lp[K];
for(n in 1:N){
for (k in 1:K){
lp[k] = log(pi[k]) + poisson_lpmf(x[,n] | theta[k]);
}
target += log_sum_exp(lp);
}
}
```

I don’t know how to define theta as order variable because theta is not scalar but vector.

As a result of modeling, inferred parameters may not be convergenced.

Please someone tell me how to fix my code. Thank you!