When you call counts[i] %/% 10
you’re still not using a valid signature, unfortunately the %/%
operator is not vectorised, so you’ll have to loop over each integer in counts[i]
:
model {
target += dirichlet_lpdf(theta | alpha);
for(i in 1:N) {
int counts_normalised[G];
for(g in 1:G) {
counts_normalised[g] = counts[i, g] %/% 10;
}
target += multinomial_lpmf(counts_normalised | theta);
}
}
Note that I’ve also moved the dirichlet_lpdf
outside of the loop, as including it within the loop is essentially weighting the posterior N
times.
Just to also quickly clarify, the key thing here is that T
is constant throughout all iterations (in this model at least), so there is no benefit to performing the division in the transformed parameters
/parameters
blocks.
If this more of a dummy model, and you’re intending to construct T
using something declared in the parameters
block, then you’re likely to run into a different set of issues. Taking a continuous parameter and discretising it to return an integer would result in discontinuities in the respective parameters, and result in seriously poor sampling performance