Extending JAGS: A tutorial on adding custom distributions to JAGS (with a diffusion model example)
- 895 Downloads
We demonstrate how to add a custom distribution into the general-purpose, open-source, cross-platform graphical modeling package JAGS (“Just Another Gibbs Sampler”). JAGS is intended to be modular and extensible, and modules written in the way laid out here can be loaded at runtime as needed and do not interfere with regular JAGS functionality when not loaded. Writing custom extensions requires knowledge of C++, but installing a new module can be highly automatic, depending on the operating system. As a basic example, we implement a Bernoulli distribution in JAGS. We further present our implementation of the Wiener diffusion first-passage time distribution, which is freely available at https://sourceforge.net/projects/jags-wiener/.
KeywordsCustom distributions JAGS Bayesian Diffusion model HDM
This project was partially supported by grant 1230118 from the National Science Foundation’s Measurement, Methods, and Statistics panel to J.V., and by a travel grant from the German Academic Exchange Service (PROMOS) to D.W. We are indebted to Martyn Plummer for helpful comments on the manuscript and for helping us with compiling issues. We also thank two anonymous reviewers and the action editor for constructive comments on an earlier draft of this article.
- Gelman, A., Carlin, J., Stern, H., & Rubin, D. (2004). Bayesian data analysis. New York, NY: Chapman & Hall/CRC Press.Google Scholar
- Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge, UK: Cambridge University Press.Google Scholar
- Lunn, D., Jackson, C., Best, N., Thomas, A., & Spiegelhalter, D. (2012). The BUGS Book: A practical introduction to Bayesian analysis. New York, NY: CRC Press.Google Scholar
- Plummer, M. (2003). JAGS: A program for analysis of Bayesian graphical models using Gibbs sampling.Google Scholar
- Thomas, A., Spiegelhalter, D., & Gilks, W. (1992). BUGS: A program to perform Bayesian inference using Gibbs sampling. Bayesian Statistics, 4, 837–842.Google Scholar
- Vandekerckhove, J. (2009). Extensions and applications of the diffusion model for two-choice response times. Unpublished doctoral dissertation, University of Leuven.Google Scholar
- Wiecki, T. V., Sofer, I., & Frank, M. J. (2013). HDDM: hierarchical bayesian estimation of the drift-diffusion model in python. Frontiers in Neuroinformatics, 7, 14. http://www.frontiersin.org/Neuroinformatics/10.3389/fninf.2013.00014/abstract