It's helpful for us to help diagnose your problem if you
cut and paste the exact message you're getting into your
mail. Otherwise, we have to guess what the "some problem" is.
Your model has a number of bugs.
1. alpha1, alpha2, beta1, and beta2 all need to be declared
as simplexes because they're variants drawn from Dirichlet priors.
Daniel noticed they had to be vectors, but the requirement's
even stricter than that. In Stan, the constraints on the variables
need to match the support.
So that's
simplex[3] alpha1;
...
2. I have no idea what you want to do with this:
culm ~ multinomial(theta[1] * alpha1[j] * beta1[k]
+ theta[2] * alpha2[j] * beta2[k]);
but the argument to multinomial() needs to be a 9-simplex (a
size 9 vector with non-negative entries summing to 1).
As is, you get a single scalar, because all those indexed
variables are simplexes.
I also don't understand why it's a doubly-nested loop. You
wind up sampling the same data, culm, 9 times.
If you're trying to create some kind of mixture model, there's a chapter in
the manual on how to do that.
Rather than using a 2-simplex, it's easier to understand and more efficient
to just use a single variable constrained to <lower=0,upper=1>. Then you
can put a beta prior on it instead of a Dirichlet and get exactly the
same posterior for theta with:
parameters {
real<lower=0,upper=1> theta;
...
model {
theta ~ beta(a[1],a[2]);
...
culm ~ multinomial(theta*alpha1[j]*beta1[k] + (1 - theta)*alpha2[j]*beta2[k]);
The right side of this still won't compile because it's just a scalar
and you need a simplex.
- Bob