bf_distribution: Simulate the distribution of the t-test Bayes factor

View source: R/Power.R

bf_distributionR Documentation

Simulate the distribution of the t-test Bayes factor

Description

Uses the default Bayes factor employed in the BayesFactor package.

Usage

bf_distribution(effect_size, sample_sizes, n_bayes_factors,
  rscale = sqrt(2)/2)

Arguments

effect_size

The assumed effect size d.

sample_sizes

A vector of sample sizes to be used in the simulation. Means the total sample sizes, i.e., the sample sizes across the two groups in the t test.

n_bayes_factors

How many Bayes factor should be computed. Is replicated for each of the elements in the vector 'sample_sizes'.

rscale

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

Value

A data.frame in long format where each row represents the simulation of a t test. Each row has four columns: 'logBF' - the natural logarithm of the Bayes factor; 'N' - the total sample size in the t test; 'eff_size' - the effect size; 'rscale' - the scaling parameter of the prior distribution.

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

bfs <- bf_distribution(effect_size = 0.5, sample_sizes = seq(50, 350, by = 50), n_bayes_factors = 300)

## Use `exp` to obtain the "normal" BF (not logarithm of the Bayes factor)
tapply(exp(bfs$logBF), bfs$N, median)



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