bain | R Documentation |
bain
is an acronym for "Bayesian informative hypotheses evaluation".
It uses the Bayes factor to evaluate hypotheses specified using equality and
inequality constraints among (linear combinations of) parameters in a wide
range of statistical models. A tutorial by Hoijtink, Mulder, van Lissa,
and Gu (2018), was published in Psychological Methods.
The preprint of that tutorial is available on PsyArxiv
(\Sexpr[results=rd]{tools:::Rd_expr_doi("10.31234/osf.io/v3shc")}) or on the bain
website at
https://informative-hypotheses.sites.uu.nl/software/bain/
Users are
advised to read the tutorial AND the vignette that is provided
with this package before using bain
.
bain(x, hypothesis, fraction = 1, ...)
x |
An R object containing the outcome of a statistical analysis.
Currently, the following objects can be processed: |
hypothesis |
A character string containing the informative hypotheses to evaluate. See the vignette for elaborations. |
fraction |
A number representing the fraction of information in the data used to construct the prior distribution. The default value 1 denotes the minimal fraction, 2 denotes twice the minimal fraction, etc. See the vignette for elaborations. |
... |
Additional arguments. See the vignette for elaborations. |
The main output resulting from analyses with bain
are
Bayes factors and posterior model probabilities associated with the
hypotheses that are evaluated. See the tutorial and the
vignette for further elaborations.
The main authors of the bain package are Xin Gu, Caspar van Lissa, Herbert Hoijtink and Joris Mulder with smaller contributions by Marlyne Bosman, Camiel van Zundert, and Fayette Klaassen. Contact information can be found on the bain website at https://informative-hypotheses.sites.uu.nl/software/bain/
For a tutorial on this method, see:
Hoijtink, H., Mulder, J., van Lissa, C., & Gu, X. (2019). A tutorial on testing hypotheses using the Bayes factor. Psychological methods, 24(5), 539. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.31234/osf.io/v3shc")}
For applications in structural equation modeling, see:
Van Lissa, C. J., Gu, X., Mulder, J., Rosseel, Y., Van Zundert, C., & Hoijtink, H. (2021). Teacher’s corner: Evaluating informative hypotheses using the Bayes factor in structural equation models. Structural Equation Modeling: A Multidisciplinary Journal, 28(2), 292-301. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/10705511.2020.1745644")}.
For the statistical underpinnings, see:
Gu, Mulder, and Hoijtink (2018). Approximated adjusted fractional Bayes factors: A general method for testing informative hypotheses. British Journal of Mathematical and Statistical Psychology, 71(2), 229-261. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/bmsp.12110")}.
Hoijtink, H., Gu, X., & Mulder, J. (2019). Bayesian evaluation of informative hypotheses for multiple populations. British Journal of Mathematical and Statistical Psychology, 72(2), 219-243. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1111/bmsp.12145")}.
Hoijtink, H., Gu, X., Mulder, J., & Rosseel, Y. (2019). Computing Bayes factors from data with missing values. Psychological Methods, 24(2), 253. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.31234/osf.io/q6h5w")}
# Evaluation of informative hypotheses for an ANOVA
# make a factor of variable site
sesamesim$site <- as.factor(sesamesim$site)
# execute an analysis of variance using lm() which, due to the -1, returns
# estimates of the means of postnumb per group
anov <- lm(postnumb~site-1,sesamesim)
# take a look at the estimated means and their names
coef(anov)
# set a seed value
set.seed(100)
# use the names to formulate and test hypotheses with bain
results <- bain(anov, "site1=site2=site3=site4=site5; site2>site5>site1>
site3>site4")
#
# SEE THE TUTORIAL AND VIGNETTE FOR MANY ADDITIONAL EXAMPLES
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.