I have a finite Binomial mixture model coded up in stan as below:
data {
int<lower=1> K; // number of mixture components
int<lower=1> S; // number of nodes
int N[S]; // sample size for each nodes
int y[S]; // number of "successes" for each node
}
parameters{
simplex[K] lambda; // mixing proportions
positive_ordered[K] p; // probability of success
}
model{
vector[K] log_lambda = log(lambda); //caching
// Priors
p ~ beta(1, 1);
// Likelihood
for (s in 1:S){
vector[K] lps = log_lambda;
for (k in 1:K){
lps[k] += binomial_lpmf(y[s] | N[s], p[k]);
}
target += log_sum_exp(lps);
}
}
My issue here is that p needs to be between 0 and 1 but Stan doesn't seem to allow setting bounds for ordered vectors (i.e. ordered<lower=0, upper=1>[K] p doesn't work) and I need them ordered for identifiably. Is there a way to set bounds for an ordered vector?
Also, I tried ordering the simplex instead as in https://discourse.mc-stan.org/t/ordered-simplex/1835 but that didn't work. The sampling took very long and the chains hadn't mixed well.