Behavior Research Methods

, Volume 46, Issue 1, pp 15–28 | Cite as

Extending JAGS: A tutorial on adding custom distributions to JAGS (with a diffusion model example)

  • Dominik Wabersich
  • Joachim VandekerckhoveEmail author


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


Custom distributions JAGS Bayesian Diffusion model HDM 


Author note

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.


  1. De Boeck, P. (2008). Random item IRT models. Psychometrika, 73, 533–559.CrossRefGoogle Scholar
  2. Gelman, A., Carlin, J., Stern, H., & Rubin, D. (2004). Bayesian data analysis. New York, NY: Chapman & Hall/CRC Press.Google Scholar
  3. Gelman, A., & Hill, J. (2007). Data analysis using regression and multilevel/hierarchical models. Cambridge, UK: Cambridge University Press.Google Scholar
  4. 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
  5. Lunn, D., Thomas, A., Best, N., & Spiegelhalter, D. (2000). WinBUGS—A Bayesian modelling framework: Concepts, structure, and extensibility. Statistics and Computing, 10, 325–337.CrossRefGoogle Scholar
  6. Plummer, M. (2003). JAGS: A program for analysis of Bayesian graphical models using Gibbs sampling.Google Scholar
  7. Thomas, A., Spiegelhalter, D., & Gilks, W. (1992). BUGS: A program to perform Bayesian inference using Gibbs sampling. Bayesian Statistics, 4, 837–842.Google Scholar
  8. Vandekerckhove, J. (2009). Extensions and applications of the diffusion model for two-choice response times. Unpublished doctoral dissertation, University of Leuven.Google Scholar
  9. Vandekerckhove, J., Panis, S., & Wagemans, J. (2007). The concavity effect is a compound of local and global effects. Perception & Psychophysics, 69, 1253–1260.CrossRefGoogle Scholar
  10. Vandekerckhove, J., & Tuerlinckx, F. (2007). Fitting the Ratcliff diffusion model to experimental data. Psychonomic Bulletin & Review, 14, 1011–1026. doi: 10.3758/BF03193087 CrossRefGoogle Scholar
  11. Vandekerckhove, J., & Tuerlinckx, F. (2008). Diffusion model analysis with MATLAB: A DMAT primer. Behavior Research Methods, 40, 61–72. doi: 10.37858/BRM.40.1.61 PubMedCrossRefGoogle Scholar
  12. Vandekerckhove, J., Tuerlinckx, F., & Lee, M. D. (2011). Hierarchical diffusion models for two-choice response times. Psychological Methods, 16, 44–62. doi: 10.1037/a0021765 PubMedCrossRefGoogle Scholar
  13. Voss, A., & Voss, J. (2007). Fast-dm: A free program for efficient diffusion model analysis. Behavior Research Methods, 39, 767–775. doi: 10.37858/BF03192967 PubMedCrossRefGoogle Scholar
  14. Wagenmakers, E.-J. (2009). Methodological and empirical developments for the Ratcliff diffusion model of response times and accuracy. European Journal of Cognitive Psychology, 21, 641–671. doi: 10.1080/09541440802205067 CrossRefGoogle Scholar
  15. Wagenmakers, E.-J., van der Maas, H. L. J., & Grasman, R. P. P. P. (2007). An EZ-diffusion model for response time and accuracy. Psychonomic Bulletin & Review, 14, 3–22. doi: 10.3758/BF03194023 CrossRefGoogle Scholar
  16. 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.

Copyright information

© Psychonomic Society, Inc. 2013

Authors and Affiliations

  1. 1.Department of Cognitive SciencesUniversity of CaliforniaIrvineUSA
  2. 2.Department of PsychologyUniversity of TübingenTübingenGermany

Personalised recommendations