Using rstan to estimate Response Times IRT Model parameters with two data (matrices)

Dear 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 have two matrix data with equal ranks, which are Y[n_participant,n_item] and RT[n_participant,n_item], and I want to use these two data to estimate the model parameter in rstan.
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=10> [n_item] delta;
model {
theta ~ normal(0,1);
rho ~ uniform(0,2);
beta ~ normal(0,1);
alpha ~ lognormal(0,1);
delta ~ uniform(0,10);
for(i in 1:n_participant){
for(j in 1:n_item){
real p;
Y[i,j] ~ bernoulli§;

However, I get some errors when I try to run the model:

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:



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.


But, I still can not solve this problem. so upset… : (
This problem has been bothering me for a long time.

So I am wondering if the way I put the response time matrix into the rstan parameter estimated code is correct

If you have any suggestions for using two matrices to evaluate model parameters in a model, then please give me some guidance and I’ll be very grateful.

(I’m by no means an expert, but I’ve fitted some IRT models with Stan, although not response time models).

As far as I can see, the use of two matrices of data is not the problem here, I think you’re doing that right.

But I notice you have a lot of constraints on your parameters - are you sure they are helpful and necessary? I think they could also interact in complicated ways to give you the error message you get (but that’s more of an intuition).

With a std_normal() prior on theta, you wouldn’t need to constrain it, but I think I’d relax the prior on beta, as these two parameters are quite interdependent?

I’m not familiar with the time-related parameters in your model - what are they meant to represent? Anyhow, is there a reason to not go for less constraints and an hierarchical prior on the rho parameter? And some weakly informative prior on the delta parameter?

Also, your code would be simpler and faster with the bernoulli_logit in the likelihood.

1 Like