> On Apr 6, 2017, at 6:03 PM, Cole Monnahan <
mon...@uw.edu> wrote:
>
> It may be worth pointing out that divergences can be caused by large approximation errors in the Hamiltonian, or a NaN. Obviously the latter case would be divergent if the Hamiltonian could be calculated, and are related. As far as I know there is no way to tell the difference between these cases in Stan.
>
> In some models in fisheries we have holes in the posterior where the log density is undefined (essentially 0 probability). This results from poorly parameterized models. The behavior of the divergences is different than those where the step size is simply too big.
There are really four ways I can think of to diverge:
1. Hamiltonian diverges but remains finite (finite divergence)
2. update target with NaN or -infinity (non-finite divergence)
3. a. execute a reject() statement (exception)
b. pass an illegal argument to a function (exception)
Cases (2) or (3) may arise from
* an infinite step in the Hamiltonian because floating-point arithmetic
fails for a well-defined Hamiltonian
* there are holes in your density
The arithmetic causes make (2) and (3) just like (1), as Cole points
out in his first paragraph.
Non-arithmetic causes, like holes in the density, can be equally
disastrous for estimation, as they cause HMC to fall back into a kind of
rejection sampler, which will usually mix poorly if there's not a smooth
boundary. Whatever you do, you want to be careful to test the calibration
of the model on simulated data.
Stan reports these slightly differently. If the NaN or infinite value
gets all the way through (unlikely), we'll report a divergence as usual.
Otherwise, we try to report the root cause from the function that
got an illegal argument or the reject statement.
- Bob
>
> On Thu, Apr 6, 2017 at 12:22 PM, Trung Dung Tran <
trungd...@gmail.com> wrote:
> Thank you so much for an useful explanation and correction!
>
> I was attracted from Stan when I see it is better for ordinal variables when running a ordered logit model. I would continue use it not only because of its performance but also of the help from the team like you.
>
> Tran.
>
> On 6 April 2017 at 21:11, Bob Carpenter <
ca...@alias-i.com> wrote:
>
> > On Apr 6, 2017, at 2:54 PM, Trung Dung Tran <
trungd...@gmail.com> wrote:
> >
> > Hi Bob,
> >
> > Yes, I really want to understand at least to the basic level of the algorithm behind Stan from that I might know the reason why my particular model does not give true values.
>
> You want to check interval coverage, not "values". See the
> Cook, Gelman, and Rubin paper, for example.
>
> > If not then it takes time to guess why a model for a real data set does not work.
> >
> > Before I thought that Stan also has problem at the boundary (with constraints) even (if I understand correctly) Stan do transform from constrained to unconstrained. In that case of boundary problem, Stan will give warning of divergence.
> >
> > For example with a scale parameter sigma we set sigma > 0 and in log-scale it will be -infinity to +infinity.
> >
> > When sigma ->0, log(sigma) -> -infinity and even sigma change a little bit (0.1 -> 0.05), log(sigma) changes a 0.7 unit and it can lead to a large difference for Hamiltonian. In this case I thought Stan also give warnings.
> >
> > Do you think this is a correct understanding of mine?
>
> No. The Hamiltonian is always conserved.
>
> What happens is that we wander off in the unconstrained space, then
> when we transform back (using, e.g., exp()), we get underflow or
> overflow, which then leads to warnings when we plug the values into
> distributions that require finite parameters.
>
> - Bob
>
> --
> You received this message because you are subscribed to a topic in the Google Groups "Stan users mailing list" group.
> To unsubscribe from this topic, visit
https://groups.google.com/d/topic/stan-users/UwuTNEp6X8w/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
stan-users+...@googlegroups.com.
> To unsubscribe from this group and all its topics, send an email to
stan-users+...@googlegroups.com.
> You received this message because you are subscribed to the Google Groups "Stan users mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
stan-users+...@googlegroups.com.