nimbleHMC: An R package for Hamiltonian Monte Carlo sampling in nimble
Daniel Turek, Perry de Valpine, Christopher J. Paciorek · The Journal of Open Source Software · 2024
Markov chain Monte Carlo (MCMC) algorithms are widely used for fitting hierarchical models to data.MCMC is the predominant tool used in Bayesian analyses to generate samples from the posterior distribution of model parameters conditional on observed data.MCMC is not a single algorithm, but rather a framework in which various sampling methods (samplers) are assigned to operate on subsets of unobserved parameters.There exists a vast set of valid samplers to draw upon, which differ in complexity, autocorrelation of samples produced, and applicability.Hamiltonian Monte Carlo [HMC; Radford M. Neal (2011)] sampling is one such technique, applicable to continuous-valued parameters, which uses gradients to generate large transitions in parameter space.The resulting samples have low autocorrelation, and therefore have high information content, relative for example to an equal-length sequence of highly autocorrelated samples.The No-U-Turn (NUTS) variety of HMC sampling [HMC-NUTS; Hoffman & Gelman (2014)] greatly increases the usability of HMC by introducing a recursive tree of numerical integration steps that makes it unnecessary to pre-specify a fixed number of steps.Hoffman & Gelman (2014) also introduce a self-tuning scheme for the step size, resulting in a fully automated HMC sampler with no need for manual tuning.Many software packages offer implementations of MCMC, such as nimble (de Valpine et al., 2017), WinBUGS (Lunn et al., 2000), JAGS (Plummer, 2003), PyMC (Fonnesbeck et al., 2015), NumPyro (Phan et al., 2019), TensorFlow Probability (Pang et al., 2020), and Stan (Carpenter et al., 2017), among others.These packages differ, however, in their approaches to sampler assignments.As sampling techniques vary in computation and quality of the samples, the effectiveness of the MCMC algorithms will vary depending on the software and model.