I am getting the message
Chain 3: Rejecting initial value:
Chain 3: Log probability evaluates to log(0), i.e. negative infinity.
Chain 3: Stan can't start sampling from this initial value.
when running my model. It seems that Stan is then able to proceed normally as sampling then continues.
However, I thought I had all my variables constrained, such that this case is not possible, i.e. I should never get values that cause this problem.
Is it somehow possible to get more diagnostics from Stan so it can tell me where this problem occurs?
Here is my current model:
data {
int<lower=1> N; // Number of trials
int<lower=1> M; // Number of subjects
vector<lower=0>[N] RT; // Reaction times
int<lower=1> subj[N]; // Subject number for RT i
vector<lower=0,upper=1>[N] resp_l; // 1 if the response was on the left, 0 otherwise
vector<lower=0,upper=1>[N] incomp; // 1 if the trial was incompatible, 0 otherwiese
vector<lower=0,upper=1>[N] acc; // Accuracy: correct (1) or incorrect (0) response
int<lower=1,upper=2> hp[N]; // Hand position: Down (1) or up (2)
real<lower=0> NDTMin; // Minimal Non-Decision time
real<lower=0> minRT[M];
}
parameters {
// Group level parameters
real alpha_mu[2]; // Boundary separation mean (parameter to log normal)
real<lower=0> alpha_sigma[2]; // Boundary separation variance (parameter to log normal)
real<lower=1> beta_alpha[2]; // alpha parameter to beta distribution for starting value
real<lower=1> beta_beta[2]; // beta parameter to beta distribution for starting value
real delta_mu[2]; // mean drift rate (group level)
real<lower=0> delta_sigma[2]; // variance
real eta_mu[2]; // Drift rate difference between compatible / incompatible trials
real<lower=0> eta_sigma[2]; // Drift rate difference (variance component)
// Individual parameters
vector<lower=0>[M] alpha[2]; // Individual boundary separation
vector<lower=0,upper=1>[M] beta[2]; // Individual starting value
vector[M] delta[2]; // Individual drift rate
vector<lower=NDTMin>[M] tau; // non-decision time (no hierarchical model)
vector[M] eta_z[2]; // Congruency effect of this participants (z-score)
}
transformed parameters {
vector[N] alpha_trl;
vector[N] beta_trl; // Beta for each trial
vector[N] delta_trl; // Drift rate in each trial
vector[M] eta[2]; // Individual compatibility effects
for(i in 1:2) {
eta[i] = eta_mu[i] + eta_z[i]*eta_sigma[i];
}
for(i in 1:N) {
alpha_trl[i] = alpha[hp[i],subj[i]];
// initial offset should mostly depend on handedness etc.
// i.e. a single offset towards left/right responses
// therefore, we reverse the beta, if the response was on
// the left
beta_trl[i] = beta[hp[i],subj[i]] + resp_l[i]-2*beta[hp[i],subj[i]] .* resp_l[i];
delta_trl[i] = (delta[hp[i],subj[i]] + incomp[i] .* eta[hp[i],subj[i]]) .* (2*acc[i]-1);
}
}
model {
alpha_mu ~ std_normal();
alpha_sigma ~ exponential(10);
tau ~ uniform(NDTMin, minRT);
delta_mu ~ normal(0,10);
delta_sigma ~ cauchy(0,10);
beta_alpha ~ exponential(1);
beta_beta ~ exponential(1);
eta_mu ~ normal(0,10);
eta_sigma ~ cauchy(0,100);
for(i in 1:2) {
alpha[i] ~ lognormal(alpha_mu[i],alpha_sigma[i]);
beta[i] ~ beta(beta_alpha[i], beta_beta[i]);
delta[i] ~ normal(delta_mu[i],delta_sigma[i]);
eta_z[i] ~ std_normal();
}
RT ~ wiener(alpha_trl, tau[subj], beta_trl, delta_trl);
}
The problem does not appear if I just take a subset of the data, but I have not figured out which part of the data is responsible, yet.