Hi, All,
I'm trying to develop new psychometric model using Rstan for estimation process with defaulted non-informative priors, but I encounter the following error which I have no idea what's going on now. Anyone can help me interpret this problem?
> Bayesian_2PL <- stan_model(model_code = Bayesian_2PL_Model_NI, model_name = "Bayesian_2PL_NI") # compile once
> Fit_Bayesian_2PL_NI <- sampling(Bayesian_2PL, data = init, iter = 2000, chains = 4, control = list(adapt_delta = 0.8))
Error in new_CppObject_xp(fields$.module, fields$.pointer, ...) :
variable does not exist; processing stage=data initialization; variable name=y; base type=int
In addition: Warning messages:
1: In is.na(x) : is.na() applied to non-(list or vector) of type 'NULL' 2: In FUN(X[[i]], ...) : data with name y is not numeric and not used
failed to create the sampler; sampling not done
The dataset is a 5000 by 10 response pattern matrix, with only 0s and 1s, and the latent ability and item difficulties and item discriminations were estimates. The stan code I'm using is
Bayesian_2PL_Model_NI<-'data {
int<lower=0> n_student; // n_student: the number of students
int<lower=0> n_item; // n_item: the number of items
int<lower=0,upper=1> y[n_student, n_item]; // the matrix of responses patterm
}
parameters {
real item_diff[n_item]; // item difficulty for items
real item_disc[n_item]; // item discrimination for items
real theta[n_student]; // latent ability theta for n student
}
transformed parameters {
real psm[n_student, n_item]; // problem-solving model
real pprocess[n_student, n_item]; // the probability of a correct response
for(i in 1:n_student)
{
for (j in 1:n_item)
{
psm[i, j] <- item_disc[j]*(theta[i] - item_diff[j]); // 2PL IRT model
pprocess[i, j] <- inv_logit(psm[i, j]); // convert to the probability
}
}
}
model {
for(i in 1:n_student)
{
for (j in 1:n_item)
{
y[i,j] ~ bernoulli(pprocess[i, j]);
}
}
}
'
The code can be run without error in Windows OS, but with MAC OS, the problem occurs. Does anyone know what's the problem here?
Thanks,
Sincerely,
Jiaqi