Hello everyone,
I am trying to fit a very simple drift diffusion model in Cmdstan, where I am interested in doing a parameter recovery study.
I am using the model bellow.
data{
int N; // number of trials;
int resp[N]; // correct/error responses per trial;
real rt[N]; // response times per trial
}
parameters{
real tau_raw; // logit of non-decision time
real delta; // drift-rate
real<lower = 0> alpha; // boundary separation
real<lower = 0, upper = 1> beta; // starting point
}
transformed parameters{
real tau; // non-decision time at RT scale
tau = inv_logit(tau_raw)*min(rt);
}
model{
delta ~ normal(1,.1);
alpha ~ normal(1.5,.1);
beta ~ normal(.5,.1);
tau_raw ~ normal(-.2,.48);
for (n in 1:N){
if (resp[n] == 1){
target += wiener_lpdf(rt[n] | alpha, tau, beta, delta);
} else{
target += wiener_lpdf(rt[n] | alpha, tau, 1 - beta, - delta);
}
}
}
Everything seems to be working well in rstan (Version 2.18.2)
, the model fits, no warnings, no need to change initial values, etc. However, when I try to fit the exact same model, with the same data in Cmdstan, I get the following message regarding boundary separation (alpha in the model above):
Exception: wiener_lpdf: Boundary separation is inf, but must be finite!
In some instances, the model doesn’t start to sample because there were to many exceptions.
I already have a very narrow prior on this parameter and I have tried to lower the init
parameter, with no effect.
Does anyone know why do Rstan and Cmdstan might have different behaviors?
Thanks in advance!
Rstan code
library(rstan)
options(mc.cores = 3)
rstan_options(auto_write = TRUE)
library(RWiener)
set.seed(123)
dcrt <- rwiener(n = 200,
alpha = 1.5,
tau = .5,
beta = .5,
delta = 1)
N <-nrow(dcrt)
rt <- dcrt$q
resp <- ifelse(dcrt$resp == "upper", 1,0)
dstan <- list(
N=N,
rt=rt,
resp=resp
)
# Dumping data for Cmdstan
stan_rdump(c("N","rt","resp"), file = "dCmdstan.R")
m_fit <- sampling(model_not_working,
data = dstan,
chains = 1)
Cmdstan code
cd $path_cmdstan
make $path_model/model
cd $path_wd
.$path_model/model sample data file=dCmdstan.R
Iformational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: wiener_lpdf: Boundary separation is inf, but must be finite! (in model.stan’ at line 32)