Dear All Stan users:
I’m a student and Stan’s beginner.
Recently, I try to use stan to estimate the Response Times IRT Model (RT-IRTM), and the formula for this model is as follows:
As we can see, the tij in this model is response time, so it is a given fixed variable that obtained during test, just like the response data.
I I wrote some code to estimate the item parameters for the model, Here is my Stan code:
data {
int<lower=0> n_participant;
int<lower=0> n_item;
int<lower=0, upper=1> Y[n_participant,n_item]; // the response of each student to answer each item
real RT[n_participant,n_item]; // the response times of each student to answer each item
}
parameters {
vector<lower=-3,upper=3> [n_participant] theta;
vector<lower=0,upper=2> [n_participant] rho;
vector<lower=0,upper=2.5> [n_item] alpha;
vector<lower=-3,upper=3>[n_item] beta;
vector<lower=0,upper=0.2> [n_item] gamma;
vector<lower=0,upper=10> [n_item] delta;
}
model {
theta ~ normal(0,1);
rho ~ uniform(0,2);
beta ~ normal(0,1);
alpha ~ lognormal(0,1);
gamma ~ uniform(0,0.2);
delta ~ uniform(0,10);
for(i in 1:n_participant){
for(j in 1:n_item){
real p;
p=inv_logit(-1.7alpha[j](theta[i]-((rho[i]*delta[j])/RT[i,j])-beta[j]));
Y[i,j] ~ bernoulli(gamma[j]+(1-gamma[j])*p);
}}}
However, I get some errors when I try to run the model:
SAMPLING FOR MODEL ‘4PL’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
…
And the R code are as follows:
library(“rstan”)
rstan_options(auto_write=TRUE)
options(mc.cores=parallel::detectCores())
#data
data<-read.csv(“C:/Users/Y.Luis/Desktop/4PL.csv”,header=T)
I<-nrow(data)
J<-ncol(data)
RT<-read.csv(“C:/Users/Y.Luis/Desktop/4PLRT.csv”,header=T)
data_4pl<-list(n_participant=I,n_item=J,RT=RT,Y=data)
irt_4pl<-stan(file=“4PL.stan”,data=data_4pl,iter=1000,chains=1)
I would be very grateful if you could take the time to give me some guidance.
4/25
Today, I try to change the RT[i,j] term to a constant 10, of course I deleted the code related to response time, and I found the model could be fit. So I think it might be a code problem with the response time data.
p=inv_logit(-1.7alpha[j](theta[i]-((rho[i]delta[j])/RT[i,j])-beta[j]));
p=inv_logit(-1.7alpha[j]*(theta[i]-((rho[i]*delta[j])/10)-beta[j]));
But, I still can not solve this problem. so upset… : (