powertbf01: Power and sample size calculations for t-test Bayes factor

View source: R/powertbf01.R

powertbf01R Documentation

Power and sample size calculations for t-test Bayes factor

Description

Compute probability that t-test Bayes factor is smaller than a specified threshold (the power), or determine sample size to obtain a target power.

Usage

powertbf01(
  n = NULL,
  power = NULL,
  k = 1/10,
  null = 0,
  plocation = 0,
  pscale = 1/sqrt(2),
  pdf = 1,
  type = c("two.sample", "one.sample", "paired"),
  alternative = c("two.sided", "less", "greater"),
  dpm = plocation,
  dpsd = pscale,
  nrange = c(2, 10^4)
)

Arguments

n

Sample size (per group)

power

Target power. Has to be NULL if n is specified. Defaults to NULL

k

Bayes factor threshold. Defaults to 1/10, Jeffreys' threshold for 'strong evidence' against the null hypothesis

null

Standardized mean difference under the point null hypothesis. Defaults to 0

plocation

t prior location. Defaults to 0

pscale

t prior scale. Defaults to 1/sqrt(2)

pdf

t prior degrees of freedom. Defaults to 1 (a Cauchy prior)

type

Type of t-test. Can be "two.sample" (default), "one.sample", or "paired"

alternative

Direction of the test. Can be either "two.sided" (default), "less", or "greater". The latter two truncate the analysis prior to negative and positive effects, respectively. If set to "less" or "greater", the power is only computed based on data with effect estimates in the direction of the alternative

dpm

Mean of the normal design prior assigned to the standardized mean difference. Defaults to the analysis prior location

dpsd

Standard deviation of the normal design prior assigned to the standardized mean difference. Set to 0 to obtain a point prior at the design prior mean. Defaults to the analysis prior scale

nrange

Sample size search range over which numerical search is performed (only taken into account when n is NULL). Defaults to c(2, 10^4)

Details

This function provides a similar interface as stats::power.t.test. For some users, the low-level functions ntbf01 (to directly compute the sample size for a fixed power) and ptbf01 (to directly compute the power for a fixed sample size) may also be useful.

Value

Object of class "power.bftest", a list of the arguments (including the computed one) augmented with method and note elements

Author(s)

Samuel Pawel

See Also

plot.power.bftest, ptbf01, ntbf01, tbf01

Examples

## determine power
powertbf01(n = 146, k = 1/6, dpm = 0.5, dps = 0, alternative = "greater")

## determine sample size
powertbf01(power = 0.95, k = 1/6, dpm = 0.5, dps = 0, alternative = "greater")


bfpwr documentation built on June 8, 2025, 1:40 p.m.