Is there a way to construct a matrix with simplex columns in Stan? The model I want to construct is similar to the following, where I model counts as dirichlet-multinomial:
data {
int g;
int c;
int<lower=0> counts[g, c];
}
parameters {
simplex [g] p;
}
model {
for (j in 1:c) {
p ~ dirichlet(rep_vector(1.0, g));
counts[, j] ~ multinomial(p);
}
}
However I would like to use a latent [g, c]
matrix for further layers of a hierarchical model similar to the following:
parameters {
// simplex_matrix would have columns which are each a simplex.
simplex_matrix[g, c] p;
}
model {
for (j in 1:c) {
p[, j] ~ dirichlet(rep_vector(1.0, g));
counts[, j] ~ multinomial(p[, j]);
}
}
If there's another way to construct this latent variable that would of course also be great! I'm not massively familiar with stan having only implemented a few hierarchical models.