# 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 > theta > theta > theta > theta > theta`. In Stan, I can declare parameters `ordered theta` so it’s constraint that way.

``````data{
int y;
}

parameters{
ordered 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.