This package provides tools to simplify the implementation of simulation based calibration using rank statistics (Talts, Betancourt, Simpson, Vehtari, and Gelman, arXiv:1804.06788). It implements a very similar validation procedure to that in rstan::sbc but using a different workflow. In rstan::sbc, the Stan model must be modified by the user to generate rank statistics during sampling. In this package, the Stan model is left unmodified, and the code needed to calculate the rank statistics is written in R. This provides a potentially faster development workflow (Stan recompiles are not needed). It also allows SBC to be used in cases where generating parameters from their prior distributions, or the modeled data from the likelihood function, would be too complicated if written in Stan.


You can install the development version from GitHub with:

To build the package vignettes, install the package using:

devtools::install_github("jasonmtroos/sbcrs", build_vignettes = TRUE)

The package vignettes are a useful starting point for understanding what this package does:

  • intro-to-sbc provides an overview to simulation-based calibration, and the features of the SBC package

  • funnel shows how SBC identified sampling problems in Neal’s funnel

  • comparison-to-rstan-sbc implements the example from rstan::sbc using this package, shows the rank statistics are the same, and provides a basis for understanding the different design philosophies behind the two approaches.

It is also useful to understand why this package does what it does. For that, see: Validating Bayesian Inference Algorithms with Simulation-Based Calibration, arXiv:1804.06788.


Please note that the ‘sbcrs’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.