Hi, everyone.

Lately, I have been learning Bayesian inference with Julia and Turing and trying to implement IRT(Item response model; logistic regression with latent variables).

Today, I ask a question related to ordered variables in Turing model.

Now, I want to model polytomous data using Graded Response Model (ordered logistic model with latent variables), which models categorical variables with some ordered threshold parameters.

I referenced a link below,

then wrote the model as described below.

```
@model graded(data) = begin
N, J = size(data)
θ = Vector{Real}(undef, N)
α = Vector{Real}(undef, J)
β = Vector{Vector}(undef, J)
β_diff = Vector{Vector}(undef, J)
for j in 1:J
cat = sort(unique(skipmissing(data[:,j])))
K = length(cat)
α[j] ~ LogNormal(0, 2)
# Assign normal prior with ordered constraints
β[j] = Vector{Real}(undef, K-1)
β_diff[j] = Vector{Real}(undef, length(cat) - 2)
for k in 1:K - 1
if k == 1
β[j][k] ~ Normal(-3, 1)
else
β_diff[j][k-1] ~ Normal(0, 1)
β[j][k] = β[j][k - 1] + exp(β_diff[j][k-1])
end
end
end
# assign distributon to each element
for i in 1:N
θ[i] ~ Normal(0, 1)
end
for i in 1:N
for j in 1:J
data[i,j] ~ OrderedLogistic(α[j]*θ[i], β[j])
end
end
end
```

This model seems to work well judging from simulation data, however, the prior settings about β and β_diff are not so intuitive that customizing prior is some tricky.

So, I come up with to use truncated distributions as follows.

```
β[j] = Vector{Real}(undef, K-1)
bounds = [-Inf; sort(rand(Normal(0, 2), K-2)); Inf]
for k in 1:K-1
β[j][k] ~ truncated(Normal(0, 2), bounds[k], bounds[k+1])
end
```

But this model returns the error below.

```
ERROR: cutpoints are not sorted
```

Do you know the more sophisticated idea to handle ordered categorical variables in Turing?