I specified a hierarchical (extended) signal detection model where I parametrized multiple, ordered decision criteria (cr1, cr2, cr3; cr1 < cr2 < cr3) through an ordered vector in Stan. When fitting the model using Cmdstan with a large number of samples (4 chains, 10000 samples each) on a dataset of about 450 participants, about 35 samples contained some participant level samples of the ordered vector that were not strictly ordered (i.e., cr1 = cr2, or cr2 = cr3).
However, I only noticed this when I tried to apply bridgesampling to the posterior samples where I got the following error message:
āError in object@.MISC$stan_fit_instance$unconstrain_pars(pars) :
Exception: Error transforming variable limits_ind: stan::io::ordered_unconstrain: Vector is not a valid ordered vector. The element at 2 is 0.613933, but should be greater than the previous element, 0.613933 (in āmodel31487641bc0_C_DPSD_new_paramā at line 140)ā
For the mentioned vector (more specifically a matrix containing ordered parameters for all 450 participants), about 35 samples do not satisfy the strict order constraint for one individual parameter vector (i.e., at least two elements of the vector are equal).
Meanwhile, the Stan documentation states that āorderedā specifies a strictly ordered vector (10.6 Ordered Vector | Stan Reference Manual).
I am thankful for any hint as to a) why some samples do not satisfy the specified constraint and b) why I canāt apply bridgesampling if the constraint is not satisfied - and of course for ideas on how to solve this!
Relevant part of the Stan code is below - I can also try to provide a reproducible example of this error but this will be difficult since this issue only seems to occur very rarely.
parameters {
ordered[3] Mu_limits;
vector[3] Sig_limits;
// individual parameters
ordered[3] limits_ind[nsubj];
}
model {
Mu_limits[1] ~ normal(-0.5, 0.5);
Mu_limits[2] ~ normal(0, 0.5);
Mu_limits[3] ~ normal(0.5, 0.5);
to_vector(Sig_limits) ~ inv_gamma(2, 3);
for (i in 1:nsubj) {
for (l in 1:3) limits_ind[i, l] ~ normal(Mu_limits[l], Sig_limits[l]);
}
}