bayes_min_n: Calculate minimum sample size for one-stage Bayesian test

View source: R/bayes_min_n.R

bayes_min_nR Documentation

Calculate minimum sample size for one-stage Bayesian test

Description

This function searches over the range specified by min_n to max_n for the smallest sample size that achieves a desired power (e.g. .8). If desired power is not reached, function defaults to returning the maximum allowable sample size.

Usage

bayes_min_n(
  req_p = 0.995,
  true_p = 0.995,
  gamma = 0.8,
  power = 0.8,
  alpha = 0.05,
  prior_alpha = 0.5,
  prior_beta = 0.5,
  min_n = 500,
  max_n = 1800,
  step_size = 10
)

Arguments

req_p

observed count

true_p

total count

gamma

posterior probability threshold needed to reject, defaults to .8

power

Desired power, defaults to .8

prior_alpha

alpha parameter of beta prior, defaults to .5 (Jeffrey's prior)

prior_beta

beta parameter of beta prior, defaults to .5 (Jeffrey's prior)

min_n

smallest n to search

max_n

maximum possible n to search

n1

first stage sample size, defaults to 200

n2

second stage sample size, defaults to 800

Value

list containing minimum selected sample size and associated probability of rejection

Examples

bayes_min_n(true_p = .994,
            gamma = .6)

njjms/nicks documentation built on May 4, 2022, 8:10 a.m.