Dear Stan Developers,
I am trying to fit a 2PL longitudinal graded reponse IRT model in Stan. I started off with just the GRM IRT part, without the longitudinal component. I am getting an error related to the initial value generation. I tightened the bounds and variances on the priors, but still get the same error (Initialization failed after 100 attempts....).
The model has 7 ordinal variables, with a variable maxium level for each dimension.
data {
int<lower=0> N; // number of subjects
int<lower=0> J; // number of items
int<lower=1, upper=7> K[J]; // max level for each item
int Y[N, J]; // data
}
parameters {
real kappa[J, 6]; // intercept
real theta[N]; // ability
real<lower=0.0, upper=2.0> alpha[J]; // discrimination
}
model{
real p[N, J, 7];
real Q[N, J, 6];
theta ~ normal(0.0, 1.0);
// alpha ~ uniform(0.0, 2.0);
for (j in 1:J) {
for (k in 1:(K[j] - 1)) {
kappa[j,k] ~ normal(0.0, 2.0);
}
}
for (i in 1:N) {
for (j in 1:J) {
for (k in 1:(K[j] - 1)) {
Q[i, j, k] <- inv_logit(kappa[j,k] - alpha[j]*theta[i]);
}
p[i, j, 1] <- Q[i, j, 1];
for (k in 2:(K[j] - 1)){
p[i, j, k] <- Q[i, j, k] - Q[i, j, k-1];
}
p[i, j, K[j]] <- 1 - Q[i, j, K[j] - 1];
// incement log probability directly because Y[i, j]
// has categorical distribution with varying dimension
increment_log_prob(log(p[i, j, Y[i, j]]));
}
}
}
I have attached the simulated data and the error message.
Data set name is: Y
Input parameters are:
# n.variables
J <- dim(Y)[2]
# sample size
N <- dim(Y)[1]
# K - max level for ordinal variable for each item
K <- apply(Y, 2, max)
Data are in csv format.