BFpack (version 0.2.1)

BF: Bayes factors for Bayesian exploratory and confirmatory hypothesis testing

Description

The BF function can be used for hypothesis testing and model selection using the Bayes factor. By default exploratory hypothesis tests are performed of whether each model parameter equals zero, is negative, or is positive. Confirmatory hypothesis tests can be executed by specifying hypotheses with equality and/or order constraints on the parameters of interest.

Usage

BF(x, hypothesis, prior, complement, ...)

Arguments

x

An R object containing the outcome of a statistical analysis.

hypothesis

A character string containing the informative hypotheses to evaluate. The default is NULL, which will result in an exploratory analysis.

prior

A vector specifying the prior probabilities of the hypotheses. The default is NULL which will specify equal prior probabilities.

complement

a logical specifying whether the complement should be added to the tested hypothesis under hypothesis.

...

Parameters passed to and from other functions.

Value

The output is an object of class BF. The object has elements: BFtu_exploratory, PHP_exploratory, BFtu_confirmatory, PHP_confirmatory, BFmatrix_confirmatory, BFtable_confirmatory, BFtu_main, PHP_main, BFtu_interaction, PHP_interaction, prior, hypotheses, estimates, model, call.

Details

The function requires a fitted modeling object. Current analyses that are supported: t_test, bartlett_test, aov, manova, lm, mlm, glm, hetcor, lmer, coxph, survreg, zeroinfl, and polr.

For testing means and regression coefficients of model classes t_test, aov, manova, lm, mlm, adjusted fractional Bayes factors are computed. For testing group variances using bartlett_test, adjusted fractional Bayes factors are computed. For testing measures of association (e.g., correlations) under model class mlm and for testing intraclass correlations under model class lmerMod, default Bayes factors based on uniform priors are computed. For all other model classes an approximate Bayes factor is computed using a Gaussian approximation of the posterior, similar as a classical Wald test.

References

Mulder, J., Gu, X., A. Tomarken, F. B<U+00F6>ing-Messing, J.A.O.C. Olsson-Collentine, Marlyne Meyerink, D.R. Williams, J. Menke, J.-P. Fox, Y. Rosseel, E.J. Wagenmakers, H. Hoijtink., and van Lissa, C. (submitted). BFpack: Flexible Bayes Factor Testing of Scientific Theories in R.

Examples

Run this code
# NOT RUN {
# EXAMPLE 1. One-sample t test
ttest1 <- bain::t_test(therapeutic,mu=5)
print(ttest1)
# confirmatory Bayesian one sample t test
BF1 <- BF(ttest1,"mu=5")
summary(BF1)
# exploratory Bayesian one sample t test
BF(ttest1)


# EXAMPLE 2. ANOVA
aov1 <- aov(price ~ anchor*motivation,data=tvprices)
# check the names of the model parameters
names(aov1$coefficients)
BF1 <- BF(aov1,hypothesis="anchorrounded=motivationlow;
                           anchorrounded<motivationlow;
                           anchorrounded>motivationlow")
summary(BF1)


# EXAMPLE 3. Logistic regression
fit <- glm(sent ~ ztrust + zfWHR + zAfro + glasses + attract + maturity +
   tattoos, family = binomial(), data = wilson)
BF1 <- BF(fit, hypothesis = "ztrust > (zfWHR, zAfro) > 0;
                             ztrust > 0 & zfWHR=zAfro= 0")
summary(BF1)

# EXAMPLE 4. Correlation analysis
set.seed(123)
cor1 <- cor_test(memory[1:20,1:3])
BF1 <- BF(cor1)
summary(BF1)
BF2 <- BF(cor1,hypothesis="Wmn_with_Im > Wmn_with_Del > 0;
                          Wmn_with_Im = Wmn_with_Del = 0")
summary(BF2)
# }

Run the code above in your browser using DataLab