Constrained ordered prior for ordered logistic model

Hello, I have a task for modeling ordered discrete response outcome but I struggled to make my prior ordered for ordered logistic model so theta[6] > theta[5] > theta[4] > theta[3] > theta[2] > theta[1]. In Stan, I can declare parameters ordered[6] theta so it’s constraint that way.

data{
    int y[120];
}

parameters{
    ordered[6] theta;
}

model{
    theta ~ normal(0,1);
    for (i in 1:120) {
        y[i] ~ ordered_logistic(0,theta);
    }
}

In Turing, how do I reproduce above?

y = [6, 5, 4, 3, 2, 1,
     1, 2 ,3 ,4 ,5 ,6]
y = repeat(y, 10)

@model function gdemo(y)
    theta ~ filldist(Normal(1, 2),6)
    y .~ OrderedLogistic(0, theta)
end
chn = sample(gdemo(y), NUTS(), 1000)

julia> ERROR: TaskFailedException: cutpoints are not sorted

I guess you can transform the unordered vector theta to an ordered one with some transformation. E.g., you could use the same transformation as Stan: 10.6 Ordered vector | Stan Reference Manual

It can be done with an intermediate variable, something like this:

@model function gdemo(y)
    x ~ filldist(AStrictlyPositiveDistribution, 6)
    theta = cumsum(x)
    y .~ OrderedLogistic(0, theta)
    return theta
end

I haven’t run the code so probably it doesn’t work without some syntactical massaging but the idea works. The return statement is important too since otherwise you won’t have theta in your traces. You could of course reconstruct with the same logic.