ntbf01: Sample size calculations for t-test Bayes factor

ntbf01R Documentation

Sample size calculations for t-test Bayes factor

Description

This function computes the required sample size to obtain a t-test Bayes factor (tbf01) more extreme than a threshold k with a specified target power.

Usage

ntbf01(
  k,
  power,
  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,
  lower.tail = TRUE,
  integer = TRUE,
  nrange = c(2, 10^4),
  ...
)

Arguments

k

Bayes factor threshold

power

Target power

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

lower.tail

Logical indicating whether Pr(\mathrm{BF}_{01} \leq k) (TRUE) or Pr(\mathrm{BF}_{01} > k) (FALSE) should be computed. Defaults to TRUE

integer

Logical indicating whether only integer valued sample sizes should be returned. If TRUE the required sample size is rounded to the next larger integer. Defaults to TRUE

nrange

Sample size search range over which numerical search is performed. Defaults to c(2, 10^4)

...

Other arguments passed to stats::uniroot

Value

The required sample size to achieve the specified power

Author(s)

Samuel Pawel

See Also

ptbf01, powertbf01, tbf01

Examples

 ## example from Schönbrodt and Wagenmakers (2018, p.135)
 ntbf01(k = 1/6, power = 0.95, dpm = 0.5, dpsd = 0, alternative = "greater")
 ntbf01(k = 1/6, power = 0.95, dpm = 0.5, dpsd = 0.1, alternative = "greater")
 ntbf01(k = 6, power = 0.95, dpm = 0, dpsd = 0, alternative = "greater",
        lower.tail = FALSE, nrange = c(2, 10000))


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