tbf01: t-test Bayes factor

tbf01R Documentation

t-test Bayes factor

Description

This function computes the Bayes factor that forms the basis of the informed Bayesian t-test from Gronau et al. (2020). The Bayes factor quantifies the evidence that the data provide for the null hypothesis that the standardized mean difference (SMD) is zero against the alternative that the SMD is non-zero. A location-scale t-distribution is assumed for the SMD under the alternative hypothesis. The Jeffreys-Zellner-Siow (JZS) Bayes factor (Rouder et al., 2009) is obtained as a special case by setting the location of the prior to zero and the prior degrees of freedom to one, which is the default.

The data are summarized by t-statistics and sample sizes. The following types of t-statistics are accepted:

  • Two-sample t-test where the SMD represents the standardized mean difference between two group means (assuming equal variances in both groups)

  • One-sample t-test where the SMD represents the standardized mean difference to the null value

  • Paired t-test where the SMD represents the standardized mean change score

Usage

tbf01(
  t,
  n,
  n1 = n,
  n2 = n,
  plocation = 0,
  pscale = 1/sqrt(2),
  pdf = 1,
  type = c("two.sample", "one.sample", "paired"),
  alternative = c("two.sided", "less", "greater"),
  log = FALSE,
  ...
)

Arguments

t

t-statistic

n

Sample size (per group)

n1

Sample size in group 1 (only required for two-sample t-test with unequal group sizes)

n2

Sample size in group 2 (only required for two-sample t-test with unequal group sizes)

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.

log

Logical indicating whether the natural logarithm of the Bayes factor should be returned. Defaults to FALSE

...

Additional arguments passed to stats::integrate

Details

The Bayes factor is implemented as in equation (5) in Gronau et al. (2020), and using suitable truncation in case of one-sided alternatives. Integration is performed numerically with stats::integrate.

Value

Bayes factor in favor of the null hypothesis over the alternative (\text{BF}_{01} > 1 indicates evidence for the null hypothesis, whereas \text{BF}_{01} < 1 indicates evidence for the alternative)

Author(s)

Samuel Pawel

References

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. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3758/PBR.16.2.225")}

Gronau, Q. F., Ly., A., Wagenmakers, E.J. (2020). Informed Bayesian t-Tests. The American Statistician, 74(2):137-143. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00031305.2018.1562983")}

See Also

powertbf01, ptbf01, ntbf01

Examples

## analyses from Rouder et al. (2009):
## values from Table 1
tbf01(t = c(0.69, 3.20), n = 100, pscale = 1, type = "one.sample")
## examples from p. 232
tbf01(t = c(2.24, 2.03), n = 80, pscale = 1, type = "one.sample")

## analyses from Gronau et al. (2020) section 3.2:
## informed prior
tbf01(t = -0.90, n1 = 53, n2 = 57, plocation = 0.350, pscale = 0.102, pdf = 3,
      alternative = "greater", type = "two.sample")
## default (one-sided) prior
tbf01(t = -0.90, n1 = 53, n2 = 57, plocation = 0, pscale = 1/sqrt(2), pdf = 1,
      alternative = "greater", type = "two.sample")


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