Dear stan forum users,
I ran into some trouble when fitting an IRT-Diffusion model via Stan. When I run the following code it first displays several messages of type:
“Rejecting initial value: Log probability evaluates to log(0), i.e. negative infinity. Stan can’t start sampling from this initial value.”
and then shows the error message "Initialization between (-2, 2) failed after 100 attempts. ". (I do not understand how an initialization between -2 and 2 appears considering the usage of invers-gamma priors for all model parameters - see model code below)
Therefore i fitted the same model but now with completely specified initial values (the true model parameter values used for generation). But then i get another error: It displays “Gradient evaluation took 0 seconds.
1000 transitions using 10 leapfrog steps would take 0 seconds…”
and then the program shuts down.
I would be grateful for any advices on how to fit the model properly.
Thank you for any help!
stan model
data {
int<lower=1> N; // total number of observations
vector[N] Y; // response variable
int<lower=0,upper=1> dec[N]; // decisions
int<lower=1> k; // number of items
int<lower=1> J_1[N]; // vector which indicates subject id
int<lower=1> I_1[N]; // vector which indicates item id
int<lower=1> n; //number of subjects
int<lower=1> p; //dimension of person parameter
}
transformed data {
real min_Y = min(Y);
}
parameters {
vector<lower=0>[n] theta; // accuracy parameters; 1 per subject
vector<lower=0>[n] g; // speed_boundary parameter; 1 per subject
vector<lower=0>[k] v; // item (invers)drift parameter
vector<lower=0>[k] a; // item (invers)boundary parameter
vector<lower=0, upper=min_Y>[k] ndt; // item non decision time
}
model {
for (l in 1:k) {
ndt[l] ~ inv_gamma(4, 3)T[0,min_Y];
v[l] ~ inv_gamma(4, 3);
a[l] ~ inv_gamma(4, 3);
}
for (l in 1:n) {
theta[l] ~ inv_gamma(4, 3);
g[l] ~ inv_gamma(4, 3);
}
for (j in 1:N) {
if(dec[j]==1) {
Y[j] ~ wiener(g[J_1[j]]/a[I_1[j]],ndt[I_1[j]],0.5,theta[J_1[j]]/v[I_1[j]]);
}
else {
Y[j] ~ wiener(g[J_1[j]]/a[I_1[j]],ndt[I_1[j]],0.5,-theta[J_1[j]]/v[I_1[j]]);
}
}
}