predictive_probability: Bayesian predictive probability calculations

View source: R/predictive_probability.R

predictive_probabilityR Documentation

Bayesian predictive probability calculations

Description

Implementation of a modified version of Zhong & Koopmeiners (2013) sample size reestimation approach. The original paper details a design which compares two proportions and has an accompanying specification for the reestimation procedure based on a z-statistic to save computational time. In the case of one proportion, we can use beta-binomial distribution directly.

Usage

predictive_probability(m, alpha, beta, eta = 0.8, requirement = 0.995)

Arguments

m

second stage sample size

alpha

alpha parameter of beta prior

beta

beta parameter of beta prior

eta

posterior probability threshold needed to reject, defaults to .8

requirement

Requiremnet from PRD, defaults to .995

Details

Calculation consists of two steps: 1. given a prior identify all possible outcomes in second stage where posterior probability is greater than some threshold and 2. add beta-binomial derived probabilities for these outcomes together. The predictive probability is used to determine a second stage sample size e.g. try a range of values for m to see which will return a sufficiently high predictive probability.

Value

a 2-element list containing df of all possible second stage outcomes and final predictive probability

Examples

x <- 1:1300
y <- sapply(x, FUN = function(x) predictive_probability(m = x,
                                                        alpha= 800.5,
                                                        beta = 2.5)$predictive_probability)
plot(x, y, type = 'l', xlab = "Second stage sample size", ylab = "predictive probability")
abline(h = .8, col="red")
mmax <- 1300
for (m_try in 1:mmax) {
  boop<- predictive_probability(m = m_try,
                                alpha = 180.5,
                                beta = .5)
  if (boop$predictive_probability >= .9) {
    print(paste0("Lowest m is to have predictive probability over 80%:", m_try))
    break
  }
}
print("Default to mmax.")

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