Access acceptance rate parameter for AdvancedMH in Turing

I have a Bayesian model set up using Turing.jl and I am currently using AdvancedMH random walk proposals in the sampler. I would like to check on the acceptance rate (number of accepted proposals/number of proposals) so that I can fine tune these random walks manually (essentially I want to make sure the jump sizes are decent). I saw that an “accepted” argument has been added to the Transitions object in AdvancedMH but I am relatively new to Turing models (and Julia programming in general) so I am not sure the best way to access the accepted argument. Is this something I can access from the resulting Chains object?

Sorry to say this, but it’s best not to use Metropolis-Hastings unless you absolutely have to. Do you really need to use it?

What should one use instead?

If the target is differentiable, NUTS should be the default. If not, slice sampling should work much better than Metropolis-Hastings.

1 Like

Can you tell me a little bit more about why Metropolis-Hastings shouldn’t be used? I understand that it will likely be a little slower, but speed isn’t really a concern for me. My target is differentiable but NUTS doesn’t work well in my case because of the shape of the likelihood surface. But the model has very few parameters, should be relatively simple to fit, so MH seemed like a good choice even if it is slow.

There are a few reasons that make slice sampling much more superior to Metropolis-Hastings. First, MH is very sensitive and hard to tune. SS, on the other hand, barely requires tuning. Also, MH does not handle multimodality and heavy tails very well, whereas SS is quite effective even for multimodal and heavy tailed posteriors. In fact, the theory says that slice sampling achieve good performance in pretty much all theoretical settings of practical interest. The only downside is that univariate slice samplers need to be augmented in certain ways to work for multiple dimensions (Gibbs sampling, hit and run, and such), whereas MH can make multivariate steps out of the box. But MH need careful tuning and preconditioning to work in multiple dimensions anyways.