I have a problem related to a previous thread here on the forums (here). Namely, how to fit an IRT model (GRM) when items have a varying number of response categories. The previous thread does not answer the question, hence I am seeking for some help.
Here is my current model. It works fine when all items have the same number of response categories (e.g., all items are dichotomous, or all items have 4 response categories). Instead of using a matrix of observed scores like the other thread, I vectorized y in order to be able to remove all NAs (no need to impute these):
data{
int<lower=1> C; // number of persons
int<lower=1> I; // number of items
int<lower=1> K; // number of response categories
int<lower=1> N_obs; // number obs. scores (no NAs)
array[N_obs] int<lower=1, upper=C> cc; // person index
array[N_obs] int<lower=1, upper=I> ii; // item index
array[N_obs] int<lower=1, upper=K> y_obs; // observed item scores
}
parameters {
vector[C] theta; // person abilities
real<lower=0> alpha[I]; // item discriminations
ordered[K-1] kappa[I]; // response category thresholds
real mu_kappa; // hyper-parameter
real<lower=0> sigma_kappa; // hyper-parameter
}
model{
// Omitting priors on theta, alpha, mu_kappa, sigma_kappa.
for (i in 1:I){
for (k in 1:(K-1)) {
kappa[i, k] ~ normal(mu_kappa, sigma_kappa);
}
}
for (n in 1:N_obs) {
y_obs[n] ~ ordered_logistic(alpha[ii[n]] * theta[cc[n]], kappa[ii[n]]);
}
}
I need to extend the model above to when K is not a constant. Say, I have four items, two dichotomous and two with 4 response categories. Then K is vector (2, 2, 4, 4). How can I rewrite the program? Here is what I tried:
- Declare K in the data block as a vector (
array[I] int<lower=1> K;
). But this breaks kappa in the parameters block. - I looked on how to set up ragged arrays in Stan. From what I could find, this is not allowed in Stan. I did find this, but I donât know how to implement this (especially in the parameters block).
Can someone point me in the right direction?
Thank you.