pbf01: Cumulative distribution function of the z-test Bayes factor

pbf01R Documentation

Cumulative distribution function of the z-test Bayes factor

Description

This function computes the probability of obtaining a Bayes factor (bf01) more extreme than a threshold k with a specified sample size.

Usage

pbf01(k, n, usd, null = 0, pm, psd, dpm = pm, dpsd = psd, lower.tail = TRUE)

Arguments

k

Bayes factor threshold

n

Sample size

usd

Unit standard deviation, the (approximate) standard error of the parameter estimate based on \code{n}=1, see details

null

Parameter value under the point null hypothesis. Defaults to 0

pm

Mean of the normal prior assigned to the parameter under the alternative in the analysis

psd

Standard deviation of the normal prior assigned to the parameter under the alternative in the analysis. Set to 0 to obtain a point prior at the prior mean

dpm

Mean of the normal design prior assigned to the parameter. Defaults to the same value as the analysis prior pm

dpsd

Standard deviation of the normal design prior assigned to the parameter. Defaults to the same value as the analysis prior psd

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

Details

It is assumed that the standard error of the future parameter estimate is of the form \code{se} =\code{usd}/\sqrt{\code{n}}. For example, for normally distributed data with known standard deviation sd and two equally sized groups of size n, the standard error of an estimated standardized mean difference is \code{se} = \code{sd}\sqrt{2/n}, so the corresponding unit standard deviation is \code{usd} = \code{sd}\sqrt{2}. See the vignette for more information.

Value

The probability that the Bayes factor is less or greater (depending on the specified lower.tail) than the specified threshold k

Author(s)

Samuel Pawel

See Also

nbf01, powerbf01, bf01

Examples

## point alternative (psd = 0)
pbf01(k = 1/10, n = 200, usd = 2, null = 0, pm = 0.5, psd = 0)

## normal alternative (psd > 0)
pbf01(k = 1/10, n = 100, usd = 2, null = 0, pm = 0.5, psd = 2)

## design prior is the null hypothesis (dpm = 0, dpsd = 0)
pbf01(k = 10, n = 1000, usd = 2, null = 0, pm = 0.3, psd = 2, dpm = 0, dpsd = 0, lower.tail = FALSE)

## draw a power curve
nseq <- round(exp(seq(log(10), log(10000), length.out = 100)))
plot(nseq, pbf01(k = 1/10, n = nseq, usd = 2, null = 0, pm = 0.3, psd = 0), type = "l",
     xlab = "n", ylab = bquote("Pr(BF"["01"] <= 1/10 * ")"), ylim = c(0, 1),
     log = "x", las = 1)

## standardized mean difference (usd = sqrt(2), effective sample size = per group size)
n <- 30
pbf01(k = 1/10, n = n, usd = sqrt(2), null = 0, pm = 0, psd = 1)

## z-transformed correlation (usd = 1, effective sample size = n - 3)
n <- 100
pbf01(k = 1/10, n = n - 3, usd = 1, null = 0, pm = 0.2, psd = 0.5)

## log hazard/odds ratio (usd = 2, effective sample size = total number of events)
nevents <- 100
pbf01(k = 1/10, n = nevents, usd = 2, null = 0, pm = 0, psd = sqrt(0.5))


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