bfpwr R Package for Bayes-Factor Functions
- The bfpwr R package is a tool that computes Bayes-factor functions, offering a parameterized, graphical alternative to fixed-threshold p-value methods.
- It implements closed-form formulas for common test statistics (z, t, χ², F), eliminating arbitrary prior scaling and the need for numerical integrations.
- The package maps standardized effect sizes to prior parameters, enabling reproducible evidence curves and facilitating meta-analytic aggregation in hypothesis testing.
Bayes-factor functions (BFFs) provide a parameterized, graphical approach for reporting the results of hypothesis tests, supplanting fixed-threshold p-value procedures. The bfpwr R package implements BFF methodology for the four most common inferential test statistics (z, t, χ², F), enabling closed-form computation of Bayes factors as a function of standardized effect size. This systematic approach eliminates the arbitrariness of prior scaling in classical Bayes-factor analyses and delivers interpretable evidence curves without numerical integration. The bfpwr package thus operationalizes the rigorous reporting of statistical evidence across scientific domains, as detailed by the BFF framework (Johnson et al., 2022).
1. Theoretical Basis of Bayes-Factor Functions
Traditional Bayes factors are ratios of marginal likelihoods under competing hypotheses: , with each reflecting a prior-averaged probability of the data. These factors depend on prior specification, notably the scale parameter for the alternative hypothesis. BFFs generalize this by producing —a function of a single scalar (typically standardized effect size )—by setting the prior's mode on the noncentrality parameter to coincide with , a function of design and sample size. This creates a curve of over meaningful values, displaying the full spectrum of evidentiary support for versus and circumventing arbitrary prior choices.
2. Closed-Form Formulas for Common Test Statistics
For each test statistic, the BFF method assigns the null-model density as the central distribution and averages the corresponding noncentral distribution under over a prior for :
- z-test: under , under ; , normal-moment prior.
- t-test ( d.f.): under , under ; . Let , , .
- -test ( d.f.): under , under ; rate .
- F-test ( d.f.): under , under ; rate . Let .
3. Mapping Effect Size to Prior Parameters
Prior modes are aligned with standardized effect size via design-specific formulas, ensuring that the calculation of reflects the scientific context:
- z or one-sample t:
- two-sample z or t (, ):
- on d.f.:
- F in ANOVA ( groups, total):
This systematic mapping, detailed in Table 1 of the source paper, standardizes prior settings across hypothesis tests, facilitating meta-analytic aggregation and cross-study comparison (Johnson et al., 2022).
4. Computational Workflow and Package Usage
The bfpwr package operationalizes BFF calculation through distinct functions for each test statistic:
| Test Statistic | Function Name | Key Arguments |
|---|---|---|
| z | bff_z |
z, n, omega |
| t | bff_t |
t, nu, n, omega |
| χ² | bff_chisq |
h, df, n, omega |
| F | bff_f |
f, k, m, n, omega |
Workflow:
- Compute for each effect size
- Plug observed statistic (z, t, h, f) and into closed-form formula
- Record pairs
- Plot BF versus (typically log-scale), visualizing regions by effect magnitude
No numerical integration is required; all formulas are algebraic. Plotting functions provide color-coded regions for effect magnitude and user-adjustable BF threshold lines (e.g., BF=1, 3, 10).
5. Interpretation, Reporting, and Meta-Analysis
BFF curves allow immediate visualization of support for across effect sizes, avoiding reliance on binary p-value thresholds. Key interpretive features include:
- The peak of the BFF curve indicates the effect size most compatible with
- The crossing at BF=1 demarcates regions favoring (to the left) or (to the right)
- The maximum BF and corresponding succinctly summarize evidentiary strength
For meta-analysis, BFFs from multiple studies can be multiplied at common grid points to form a "meta-BFF". This aggregation transparently displays collective evidence consistency and effect-size ranges supported across studies.
6. Practical Implementation and Guidance
The bfpwr R package recommends eschewing "p<0.05" as the sole summary. Instead, users are directed to:
- Compute and plot over the effect-size grid
- Report the maximum BF and corresponding
- Interpret the curve to exclude unsupported effect sizes (e.g., regions where BF)
- Aggregate BFFs for meta-analytic inference using multiplicative combination
Example reporting language: “We observed t(28)=2.5. The maximum Bayes factor in favor of the alternative was 4.2 at . Moreover, our BFF curve indicates that any standardized effect larger than is disfavored (BF1). Hence, we can exclude large effects while acknowledging evidence for a moderate effect.”
BFF methodology as implemented by bfpwr delivers transparent, replicable, and scientifically interpretable visual evidence for hypothesis testing results, advancing beyond conventional significance paradigms (Johnson et al., 2022).