Dear community,
in my R data simulation for a drift diffusion model using cmdStanr and the wiener_full_lpdf function, I receive negative initial values for my nondecision time. Also, for some iterations the random variable is smaller than the nondecision time.
Here is the relevant code:
data {
int<lower=1> M; // Number of participants
...
int<lower=1> N; // Tials per participant
...
}
parameters {
// Population level
...
real<lower=0> mu_t0;
real<lower=0> sigma_t0;
real<lower=0> mu_xi;
real<lower=0> sigma_xi;
...
// Individual level
...
vector<lower=0>[M] t0_j;
vector<lower=0>[M] xi_j;
...
// Trial level
matrix<lower=0>[M, N] t0_ij;
}
model {
// Population level
...
mu_t0 ~ normal(0,.1);
sigma_t0 ~ normal(0,.1);
mu_xi ~ normal(0,.1);
sigma_xi ~ normal(0,.1);
...
// Individual level
...
t0_j ~ normal(mu_t0,sigma_t0);
xi_j ~ normal(mu_xi,sigma_xi);
...
// Trial level
for (j in 1:M) {
for (i in 1:N) {
t0_ij[j, i] ~ normal(t0_j[j],xi_j[j]);
}
}
// Likelihood
for (j in 1:M) {
for (i in 1:N) {
if (response[j, i] == 1) {
target += wiener_full_lpdf(rt[j, i] | a_ij[j, i], t0_ij[j, i], 0.5, v_ij[j, i], sv_j[j], 0, st0_j[j]);
} else {
target += wiener_full_lpdf(rt[j, i] | a_ij[j, i], t0_ij[j, i], 0.5, -v_ij[j, i], sv_j[j], 0, st0_j[j]);
}
}
}
}
Here is an excerpt from the output:
Chain 1 Rejecting initial value:
Chain 1 Error evaluating the log probability at the initial value.
Chain 1 Exception: wiener_full_lpdf: Nondecision time is -0.144704, but must be nonnegative! (in ...)
...
Chain 1 Exception: wiener_full_lpdf: Random variable = 1.02586, but must be greater than nondecision time = 1.14669 (in ...)
...
Chain 1 Try specifying initial values, reducing ranges of constrained values, or reparameterizing the model.
Chain 1 Initialization failed.
Warning: Chain 1 finished unexpectedly!
I use Windows 11 and package version 0.6.1