-
Notifications
You must be signed in to change notification settings - Fork 21
Description
I hope I am not abusing this channel with a very specific question. I am trying to use HMC to perform Bayesian inference in an astrophysical simulation. Unfortunately, I cannot provide here the log-posterior I am using, since it is the result of a calculation involving several thousands lines of code.
My test posterior distribution is defined on a 6-dimensional parameter space. I studied the same problem with a variety of MCMC tools, and the "good" results are summarized in this pair plot:
With HMC, I recover this result only occasionally. Since the priors for many parameters do not have the entire real axis as support, I am doing a re-parametrization of the problem using the following transformation:
y = StatsFuns.norminvcdf.(Distributions.cdf.(prior, x))where prior is the vector of prior distributions for each component of x. With this mapping, each element of the new parameter space y has a normal prior distribution with vanishing mean and unity variance. The log posterior in the new variables also takes a simple form, as it can be written as
logposterior(y) = loglilekelihood(x(y)) + sum(StatsFuns.normlogpdf, y)where x(y) is the inverse of the transformation written above.
My problem is that when I try to use HMC the warmup phase seems to fail very often. As mentioned, occasionally I obtain results that are consistent with the ones I have verified with independent MCMC techniques, but more often the chain returned is completely off. I tried to diagnose the reasons, but I have failed so far. Also, all the diagnostic I have checked are actually apparently good for HMC, in spite of the wrong results: Rhat is very close to unity and EBFMI is quite large (around 0.8-1.2). Also the trace plots do not reveal anything strange, and the summarize_tree_statistics returns something that to me looks OK (although perhaps the depth is too high?):
Hamiltonian Monte Carlo sample of length 10000
acceptance rate mean: 0.94, 5/25/50/75/95%: 0.77 0.92 0.98 0.99 1.0
termination: divergence => 0%, max_depth => 0%, turning => 100%
depth: 0 => 0%, 1 => 0%, 2 => 1%, 3 => 3%, 4 => 7%, 5 => 21%, 6 => 34%, 7 => 33%, 8 => 0%
In other words, it looks like the warmup phase is completely failing to converge to the typical set. I tried to change the warmup_stages, using for example default_warmup_stages(; middle_steps=50, doubling_stages=7), but with no luck; also a change to a symmetric mass matrix did not help.
I feel I am missing something fundamental here, since I would expect HMC to easily sample this relatively-low dimensional space, unimodal distribution. Any helpp would be really appreciated!