Package: bain 0.2.11

Caspar J van Lissa

bain: Bayes Factors for Informative Hypotheses

Computes approximated adjusted fractional Bayes factors for equality, inequality, and about equality constrained hypotheses. For a tutorial on this method, see Hoijtink, Mulder, van Lissa, & Gu, (2019) <doi:10.1037/met0000201>. For applications in structural equation modeling, see: Van Lissa, Gu, Mulder, Rosseel, Van Zundert, & Hoijtink, (2021) <doi:10.1080/10705511.2020.1745644>. For the statistical underpinnings, see Gu, Mulder, and Hoijtink (2018) <doi:10.1111/bmsp.12110>; Hoijtink, Gu, & Mulder, J. (2019) <doi:10.1111/bmsp.12145>; Hoijtink, Gu, Mulder, & Rosseel, (2019) <doi:10.31234/osf.io/q6h5w>.

Authors:Xin Gu [aut], Herbert Hoijtink [aut], Joris Mulder [aut], Caspar J van Lissa [aut, cre], Van Zundert Camiel [ctb], Jeff Jones [ctb], Niels Waller [ctb]

bain_0.2.11.tar.gz
bain_0.2.11.tar.gz(r-4.5-noble)bain_0.2.11.tar.gz(r-4.4-noble)
bain_0.2.11.tgz(r-4.4-emscripten)bain_0.2.11.tgz(r-4.3-emscripten)
bain.pdf |bain.html
bain/json (API)

# Install 'bain' in R:
install.packages('bain', repos = 'https://cloud.r-project.org')

Bug tracker:https://github.com/cjvanlissa/bain/issues11 issues

Uses libs:
  • fortran– Runtime library for GNU Fortran applications
Datasets:
  • kuiper2013 - The Effect of Prior Interaction on Trust
  • sesamesim - Simulated Sesame Street Data
  • synthetic_dk - Simulated data about morality and politics in Denmark
  • synthetic_nl - Simulated data about morality and politics in The Netherlands
  • synthetic_us - Simulated data about morality and politics in the USA

On CRAN:

Conda:r-bain-0.2.11(2025-03-25)

fortran

4.54 score 8 packages 2.9k downloads 6 exports 6 dependencies

Last updated 10 months agofrom:8e4db29070. Checks:3 OK. Indexed: no.

TargetResultLatest binary
Doc / VignettesOKMar 10 2025
R-4.5-linux-x86_64OKMar 10 2025
R-4.4-linux-x86_64OKMar 10 2025

Exports:bainbain_sensitivityget_estimatespbfseBetat_test

Dependencies:lavaanMASSmnormtnumDerivpbivnormquadprog

Introduction to bain

Rendered fromIntroduction_to_bain.Rmdusingknitr::rmarkdownon Mar 10 2025.

Last update: 2023-09-27
Started: 2019-02-06

Citation

To cite package ‘bain’ in publications use:

Gu X, Hoijtink H, Mulder J, van Lissa CJ (2024). bain: Bayes Factors for Informative Hypotheses. R package version 0.2.11, https://CRAN.R-project.org/package=bain.

Corresponding BibTeX entry:

  @Manual{,
    title = {bain: Bayes Factors for Informative Hypotheses},
    author = {Xin Gu and Herbert Hoijtink and Joris Mulder and Caspar J
      {van Lissa}},
    year = {2024},
    note = {R package version 0.2.11},
    url = {https://CRAN.R-project.org/package=bain},
  }

Readme and manuals

bain

Bain stands for Bayesian informative hypothesis evaluation. It computes Bayes factors for informative hypotheses in a wide variety of statistical models. Just run your analysis as usual, and then apply bain to the output. A tutorial is available at DOI:10.1037/met0000201. A sequel with the focus on Structural Equation Models is available at https://doi.org/10.1080/10705511.2020.1745644.

Installation

Install the latest release version of bain from CRAN:

install.packages("bain")

You can also install the latest development version of bain from GitHub. This requires a working toolchain, to compile the Fortran source code. Step 3 in this tutorial explains how to set up the toolchain. Then, run:

install.packages("devtools")
devtools::install_github("cjvanlissa/bain")

Workflow

Add bain to your existing R workflow, and obtain Bayes factors for your familiar R analyses! Bain is compatible with the pipe operator. Here is an example for testing an informative hypothesis about mean differences in an ANOVA:

# Load bain
library(bain)
# dplyr to access the %>% operator
library(dplyr)
# Iris as example data
iris %>%
  # Select outcome and predictor variables
  select(Sepal.Length, Species) %>%      
  # Add -1 to the formula to estimate group means, as in ANOVA
  lm(Sepal.Length ~ -1 + Species, .) %>% 
  bain("Speciessetosa < Speciesversicolor = Speciesvirginica;
       Speciessetosa < Speciesversicolor < Speciesvirginica")
#> Bayesian informative hypothesis testing for an object of class lm (ANOVA):
#> 
#>    Fit   Com   BF.u  BF.c             PMPa  PMPb  PMPc 
#> H1 0.000 0.224 0.000 0.000            0.000 0.000 0.000
#> H2 1.000 0.166 6.027 502986932347.232 1.000 0.858 1.000
#> Hu                                          0.142      
#> Hc 0.000 0.834 0.000                              0.000
#> 
#> Hypotheses:
#>   H1: Speciessetosa<Speciesversicolor=Speciesvirginica
#>   H2: Speciessetosa<Speciesversicolor<Speciesvirginica
#> 
#> Note: BF.u denotes the Bayes factor of the hypothesis at hand versus the unconstrained hypothesis Hu. BF.c denotes the Bayes factor of the hypothesis at hand versus its complement. PMPa contains the posterior model probabilities of the hypotheses specified. PMPb adds Hu, the unconstrained hypothesis. PMPc adds Hc, the complement of the union of the hypotheses specified.

Documentation

Every user-facing function in the package is documented, and the documentation can be accessed by running ?function_name in the R console, e.g., ?bain.

Moreover, you can read the Introduction to bain vignette by running vignette("Introduction_to_bain", package = "bain")

Citing bain

You can cite the R-package with the following citation:

Gu, X., Hoijtink, H., Mulder, J., & van Lissa, C. (2019). bain: Bayes factors for informative hypotheses. (Version 0.2.3) [R package]. https://CRAN.R-project.org/package=bain

Contributing and Contact Information

If you have ideas, please get involved. You can contribute by opening an issue on GitHub, or sending a pull request with proposed features. Contributions in code must adhere to the tidyverse style guide.

  • File a GitHub issue here
  • Make a pull request here

By participating in this project, you agree to abide by the Contributor Code of Conduct v2.0.