pwr_curve {bayesassurance}R Documentation

Plotting Power and Assurance Curves Simultaneously

Description

Constructs a single plot based on the combined set of inputs used to compute the frequentist power and Bayesian assurance. The plot includes three curves that include the power curve, the assurance curve obtained under a closed-form solution, and optionally, the assurance curve obtained under a simulation setting.

Usage

pwr_curve(
  n,
  n_a,
  n_d,
  theta_0,
  theta_1,
  sigsq,
  alt = "greater",
  alpha,
  bayes_sim = FALSE,
  mc_iter = NULL
)

Arguments

n

sample size (either a scalar or vector)

n_a

sample size at analysis stage (setting n_a close to 0 corresponds to a weak analysis prior)

n_d

sample size at design stage

theta_0

parameter value that is known a priori (typically provided by the client)

theta_1

alternative parameter value that will be tested in comparison to theta_0. See alt for specification options.

sigsq

known variance \sigma^2

alt

specifies alternative test case, where alt = "greater" tests if theta_1 > theta_0, "less" tests if theta_1 < theta_0, and "two.sided" performs a two-sided test. alt = "greater" by default.

alpha

significance level

bayes_sim

when set to "TRUE", this indicates that the user wants to include simulated assurance results in the outputted plot. Default setting is "FALSE".

mc_iter

number of MC samples provided that bayes_sim = TRUE

Value

plot of overlayed power and assurance curves produced using ggplot2

a list of objects corresponding to the power/assurance curves

See Also

ggplot2, pwr_freq for frequentist power function and bayes_sim for the Bayesian assurance function

Examples


## Case 1: Weak Analysis Prior (n_a set to be small) + Strong Design Prior
## (n_d set to be large) that results in the Bayesian assurance and 
## frequentist curve perfectly overlapping one another.

n <- seq(10, 200, 10)
n_a <- 1e-8
n_d <- 1e+8
theta_0 <- 0.15
theta_1 <- 0.25
sigsq <- 0.104
alpha <- 0.05

## outputs all three plots
out <- bayesassurance::pwr_curve(n = n, n_a = n_a, n_d = n_d, 
theta_0 = theta_0, theta_1 = theta_1, sigsq = sigsq, alt = "greater", 
alpha = alpha, bayes_sim = TRUE, mc_iter = 5000)

## only outputs the closed-form solution power and assurance curves
pwr_curve(n = n, n_a = n_a, n_d = n_d, theta_0 = theta_0, theta_1 = theta_1,
sigsq = sigsq, alt = "greater", alpha = alpha, bayes_sim = FALSE)



## Case 2: Weak Analysis Prior (n_a set to be small) + Weak Design Prior
## (n_d set to be small) that results in a assurance curve,
## which illustrates the noninformative prior setting.
n <- seq(10, 200, 10)
n_a <- 1e-8
n_d <- 1e-8
theta_0 <- 0.15
theta_1 <- 0.25
sigsq <- 0.104
alpha <- 0.05

bayesassurance::pwr_curve(n = n, n_a = n_a, n_d = n_d, theta_0 = theta_0,
theta_1 = theta_1, sigsq = sigsq, alt = "greater", alpha = alpha, 
bayes_sim = TRUE, mc_iter = 1000)


[Package bayesassurance version 0.1.0 Index]