Hi all,
Sorry to bother...
I recently tried to use rstan to model a binary decision process with the basic structure as follows:
...
prob = (1 - lapse) * 1 / (1+ exp( (a-x) / b ) ) + lapse * 0.5
y ~ binomial( prob )
....
I have constrained the lapse rate to be within 0 and .1, and also the probability p.
Further complication is that I am also modeling how lapse rate change over trials, i.e.
...
lapse_sum = lapse + k_l * f(trial)
prob = (1 - lapse_sum) * 1 / (1+ exp( (a -x) / b ) ) + lapse_sum * 0.5
...
In the model, how I am currently specifying the model is
...
parameter{
real a ;
real b ;
real<lower = 0, upper = 0.1> lapse ;
real k_l ;
}
transformed parameters{
real<lower = 0, upper = 1> prob ;
real>lower = 0, upper = .1> lapse_sum ;
prob = (1 - lapse_sum) * 1 / (1+ exp( (a -x) / b ) ) + lapse_sum * 0.5
}
model{
a ~ normal(0, 100) ;
b ~ normal(0, 100) ;
lapse ~ uniform(0, .1) ;
k_l ~ normal(0, .1)
y ~ binomial(p)
}
...
However, I kept getting issues with the sampling processes. The model would either
1) The sampler cannot initialize and return no samples. I got message saying things like:
"Rejecting initial value:" " Error evaluating the log probability at the initial value." "Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:"
"validate transformed params: prob[k0__] is 1.38673, but must be less than or equal to 1"
"If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,"
"but if this warning occurs often then your model may be either severely ill-conditioned or misspecified."
I am a bit confused here. I first thought it is an underflow issue, but I thought that would just give me an NAN? Given that the equation is by nature bounded, I am confused how it can produce prob that is larger than 1 or smaller than 0. Is it because my priors are too generous?
2) When the sampler did get initialized. I sometimes will still get warnings like
"1: There were 3000 divergent transitions after warmup. Increasing adapt_delta above 0.8 may help.
2: Examine the pairs() plot to diagnose sampling problems"
When I increased the delta to .9, sometimes it solves the issue and all chains converge some reasonable number that makes intuitive sense. However, sometimes one or more of the chains still get stuck at the constrained boundaries and does not change much once it gets there nor converge to the same place where other chains converge.
Has anyone run into similar issues? And if so, what are the ways to solve the issue? When the sampler did move out of the boundaries, they do converge and always converge on numbers that are meaningful and interpretable. So I had the intuition that it could probably be solve by some re-parameterization and correspondingly adopt different sets of priors.
Thank you so much for your help!
Best,
Shaorong