An R package for hierarchical Bayesian modeling of RLDM tasks.
Clone or download


Project Status: Active – The project has reached a stable, usable state and is being actively developed. Build Status CRAN Latest Release Downloads

hBayesDM (hierarchical Bayesian modeling of Decision-Making tasks) is a user-friendly R package that offers hierarchical Bayesian analysis of various computational models on an array of decision-making tasks. hBayesDM uses Stan for Bayesian inference.

Getting Started


To install hBayesDM, RStan should be properly installed before you proceed. For detailed instructions, please go to this link:

For the moment, RStan requires you to specify that the C++14 standard should be used to compile Stan programs (based on this link):

Sys.setenv(USE_CXX14 = 1)
library("rstan") # observe startup messages


hBayesDM can be installed from CRAN by running the following command in R:

install.packages('hBayesDM')  # Install hBayesDM from CRAN

We strongly recommend users to install hBayesDM from GitHub. All models in this GitHub version are precompiled, which saves time for compiling Stan models. However, it may cause some memory allocation issues on a Windows machine.

You can install the latest version from GitHub with:

# `devtools` is required to install hBayesDM from GitHub
if (!require(devtools)) install.packages("devtools")

Quick Links


If you used hBayesDM or some of its codes for your research, please cite this paper:

Ahn, W.-Y., Haines, N., & Zhang, L. (2017). Revealing neuro-computational mechanisms of reinforcement learning and decision-making with the hBayesDM package. Computational Psychiatry, 1, 24-57.

or for BibTeX:

  title = {Revealing Neurocomputational Mechanisms of Reinforcement Learning and Decision-Making With the {hBayesDM} Package},
  author = {Ahn, Woo-Young and Haines, Nathaniel and Zhang, Lei},
  journal = {Computational Psychiatry},
  year = {2017},
  volume = {1},
  pages = {24--57},
  publisher = {MIT Press},
  url = {},