EconPapers    
Economics at your fingertips  
 

Demystifying Monte Carlo methods in R: A guide from Metropolis–Hastings to Hamiltonian Monte Carlo with biological growth equation examples

Dipali Vasudev Mestry and Amiya Ranjan Bhowmick

Ecological Modelling, 2025, vol. 501, issue C

Abstract: Hamiltonian Monte Carlo (HMC) has emerged as a cutting-edge and versatile Markov Chain Monte Carlo (MCMC) method, widely adopted across various disciplines due to its superior computational efficiency compared to other MCMC techniques. Over the past few decades, HMC has gained significant traction. However, its implementation can pose challenges for practitioners, as it relies on concepts rooted in Hamiltonian dynamics from classical mechanics. Despite the development of modern Bayesian computation tools like Stan, which facilitate the application of HMC, the underlying mechanics may remain opaque to beginners. This article seeks to provide a clear and accessible introduction to HMC. We begin by reviewing the Metropolis–Hastings (MH) algorithm and its limitations, illustrated with simulated data. We then methodically explain the HMC algorithm through step-by-step simulation examples, showcasing its implementation in R software. Finally, we present a series of ecological case studies spanning a broad range of applications, including both single-species and multispecies dynamics. These studies demonstrate the implementation of HMC using the rstan package in R, applied to both simulated and real-world data. By adopting this pedagogical approach, we aim to help newcomers better understand and apply HMC to their research domains with confidence.

Keywords: rstan; Hamiltonian dynamics; Leapfrog Integration; Logistic-growth model; Multi-species dynamics (search for similar items in EconPapers)
Date: 2025
References: Add references at CitEc
Citations:

Downloads: (external link)
http://www.sciencedirect.com/science/article/pii/S0304380024003107
Full text for ScienceDirect subscribers only

Related works:
This item may be available elsewhere in EconPapers: Search for items with the same title.

Export reference: BibTeX RIS (EndNote, ProCite, RefMan) HTML/Text

Persistent link: https://EconPapers.repec.org/RePEc:eee:ecomod:v:501:y:2025:i:c:s0304380024003107

DOI: 10.1016/j.ecolmodel.2024.110922

Access Statistics for this article

Ecological Modelling is currently edited by Brian D. Fath

More articles in Ecological Modelling from Elsevier
Bibliographic data for series maintained by Catherine Liu ().

 
Page updated 2025-03-19
Handle: RePEc:eee:ecomod:v:501:y:2025:i:c:s0304380024003107