power_bf: Compute "power" for the default t-test Bayes factor

View source: R/Power.R

power_bfR Documentation

Compute "power" for the default t-test Bayes factor

Description

For a given N, this function returns the Bayes factor that will be exceeded with a specified probability in a t-test. Transfers the frequentist concept of statistical power to Bayes factors. Uses the default Bayesian t test implemented in the package 'BayesFactor'.

Usage

power_bf(N, effect_size, nsim = 1000, rscale = sqrt(2)/2,
  probability = 0.8, say_result = TRUE)

Arguments

N

The total sample size over both groups in the independent groups t test.

effect_size

The assumed effect size d.

nsim

The number of simulations that are conducted to determine the "power" of the t test. Increase this number to obtain a more precise estimate.

rscale

The scaling parameter in the Cauchy prior used in the Bayes factor computation. Defaults to 'sqrt(2) / 2'.

probability

A scalar indicating the "power". See 'Details'.

say_result

Boolean. Print a verbal description of the computation when it is finished?

Details

For Bayes factors, there is no concept of statistical power. However, for a given N and effect size, we can investigate the distribution of Bayes factors. Here, "power" then means the probability that an observed Bayes factor is at least as high as a particular value. We specify this "power" using the parameter 'probability'. In case of a null-effect, "power" is the probability that an observed Bayes factor is smaller than a particular value. The function does not analytically determine "power", but uses simulation to generate the distribution of Bayes factors.

References

Morey, R. D., & Rouder, J. N. (2015). BayesFactor: Computation of Bayes factors for common designs. Retrieved from https://CRAN.R-project.org/package=BayesFactor

Rouder, J. N., Speckman, P. L., Sun, D., Morey, R. D., & Iverson, G. (2009). Bayesian t tests for accepting and rejecting the null hypothesis. Psychonomic Bulletin & Review, 16(2), 225–237.

Examples

## N is the total sample size across two groups
power_bf(N = 200, effect_size = 0.4)
## Null effect:
power_bf(N = 1000, effect_size = 0)
## Small effect size:
power_bf(N = 1000, effect_size = 0.2)
## Vary width of the prior distribution for the alternative hypothesis:
power_bf(N = 1000, effect_size = 0.2, rscale = 0.2)


m-Py/bayesEd documentation built on Feb. 25, 2023, 5:35 p.m.