1,820
Views
12
CrossRef citations to date
0
Altmetric
Statistical Computing and Graphics

Learning Hamiltonian Monte Carlo in R

& ORCID Icon
Pages 403-413 | Received 29 Jun 2020, Accepted 12 Dec 2020, Published online: 31 Jan 2021
 

Abstract

Hamiltonian Monte Carlo (HMC) is a powerful tool for Bayesian computation. In comparison with the traditional Metropolis–Hastings algorithm, HMC offers greater computational efficiency, especially in higher dimensional or more complex modeling situations. To most statisticians, however, the idea of HMC comes from a less familiar origin, one that is based on the theory of classical mechanics. Its implementation, either through Stan or one of its derivative programs, can appear opaque to beginners. A lack of understanding of the inner working of HMC, in our opinion, has hindered its application to a broader range of statistical problems. In this article, we review the basic concepts of HMC in a language that is more familiar to statisticians, and we describe an HMC implementation in R, one of the most frequently used statistical software environments. We also present hmclearn, an R package for learning HMC. This package contains a general-purpose HMC function for data analysis. We illustrate the use of this package in common statistical models. In doing so, we hope to promote this powerful computational tool for wider use. Example code for common statistical models is presented as supplementary material for online publication.

Supplementary Materials

Appendix:R code for HMC examples. (pdf file type)

R-package for learning HMC:R-package hmclearn contains a general-purpose function as well as utility functions for the model fitting methods described in the article. Example datasets and code are also made available in the package. The package hmclearn can be accessed at https://cran.r-project.org/web/packages/hmclearn/index.html.

Acknowledgments

The authors thank the Editor, Associate Editor, and two reviewers for their many insightful comments.

Additional information

Funding

This work is partially supported by National Institutes of Health grants R01AA025208 and U24 AA026969.

Log in via your institution

Log in to Taylor & Francis Online

PDF download + Online access

  • 48 hours access to article PDF & online version
  • Article PDF can be downloaded
  • Article PDF can be printed
USD 61.00 Add to cart

Issue Purchase

  • 30 days online access to complete issue
  • Article PDFs can be downloaded
  • Article PDFs can be printed
USD 106.00 Add to cart

* Local tax will be added as applicable

Related Research

People also read lists articles that other readers of this article have read.

Recommended articles lists articles that we recommend and is powered by our AI driven recommendation engine.

Cited by lists all citing articles based on Crossref citations.
Articles with the Crossref icon will open in a new tab.