bayesplay: The Bayesian playground

R-CMD-check CRAN downloads codecov

The goal of bayesplay is to provide an interface for calculating Bayes factors for simple models. It does this in a way that makes the calculations more transparent and it is therefore useful as a teaching tools.


bayesplay is now on CRAN. You can install it with:


Or if you want to live on the edge, you can install the development version from GitHub with:

# install.packages("devtools")

Basic usage

The bayesplay package comes with three basic functions for computing Bayes factors.

  1. The likelihood() function for specifying likelihoods

  2. The prior() function for specifying priors

  3. And the integral() function

Currently the following distributions are supported for likelihoods and priors


  1. Normal distribution (normal)

  2. Uniform distribution (uniform)

  3. Scaled and shifted t distribution (student_t)

  4. Cauchy distributions (cauchy)

  5. Beta distribution (beta)


  1. Normal distribution (normal)

  2. Scaled and shifted t distribution (student_t)

  3. Binomial distribution (binomial)

  4. Various noncentral t distributions, including:

Worked examples

For worked examples of the basic usage see basic usage. Or for basic plot functionality see basic plotting


Breaking changes for < v0.9.0

distribution parameter for specifying likelihoods and priors has been renamed family

noncentral_d and noncentral_d2 are now parametrised in terms of sample size rather than df