power.two.grp.random.a0: Power/type I error calculation for two groups (treatment and...

Description Usage Arguments Details Value References See Also Examples

View source: R/main_func.R

Description

Power/type I error calculation using normalized power priors for two groups (treatment and control group, no covariates) with random a_0

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
power.two.grp.random.a0(
  data.type,
  n.t,
  n.c,
  historical,
  samp.prior.mu.t,
  samp.prior.mu.c,
  samp.prior.var.t = 0,
  samp.prior.var.c = 0,
  prior.mu.t.shape1 = 1,
  prior.mu.t.shape2 = 1,
  prior.mu.c.shape1 = 1,
  prior.mu.c.shape2 = 1,
  prior.a0.shape1 = 1,
  prior.a0.shape2 = 1,
  lower.limits = rep(0, 10),
  upper.limits = rep(1, 10),
  slice.widths = rep(0.1, 10),
  delta = 0,
  gamma = 0.95,
  nMC = 10000,
  nBI = 250,
  N = 10000
)

Arguments

data.type

Character string specifying the type of response. The options are "Normal", "Bernoulli", "Poisson" and "Exponential".

n.t

Sample size of the treatment group for the simulated datasets.

n.c

Sample size of the control group for the simulated datasets.

historical

Matrix of historical dataset(s). If data.type is "Normal", historical is a matrix with three columns:

  • The first column contains the sum of responses for the control group.

  • The second column contains the sample size of the control group.

  • The third column contains the sample variance of responses for the control group.

For all other data types, historical is a matrix with two columns:

  • The first column contains the sum of responses for the control group.

  • The second column contains the sample size of the control group.

Each row represents a historical dataset.

samp.prior.mu.t

Vector of possible values of μ_t to sample (with replacement) from. The vector contains realizations from the sampling prior (e.g. normal distribution) for μ_t.

samp.prior.mu.c

Vector of possible values of μ_c to sample (with replacement) from. The vector contains realizations from the sampling prior (e.g. normal distribution) for μ_c.

samp.prior.var.t

Vector of possible values of σ^2_t to sample (with replacement) from. Only applies if data.type is "Normal". The vector contains realizations from the sampling prior (e.g. inverse-gamma distribution) for σ^2_t.

samp.prior.var.c

Vector of possible values of σ^2_c to sample (with replacement) from. Only applies if data.type is "Normal". The vector contains realizations from the sampling prior (e.g. inverse-gamma distribution) for σ^2_c

prior.mu.t.shape1

First hyperparameter of the initial prior for μ_t. The default is 1. Does not apply if data.type is "Normal".

prior.mu.t.shape2

Second hyperparameter of the initial prior for μ_t. The default is 1. Does not apply if data.type is "Normal".

prior.mu.c.shape1

First hyperparameter of the initial prior for μ_c. The default is 1. Does not apply if data.type is "Normal".

prior.mu.c.shape2

Second hyperparameter of the initial prior for μ_c. The default is 1. Does not apply if data.type is "Normal".

prior.a0.shape1

First shape parameter of the beta prior for a_0. The default is 1.

prior.a0.shape2

Second shape parameter of the beta prior for a_0. The default is 1.

lower.limits

Vector of lower limits for parameters to be used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 0 for all parameters (may not be appropriate for all situations).

upper.limits

Vector of upper limits for parameters to be used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 1 for all parameters (may not be appropriate for all situations).

slice.widths

Vector of initial slice widths used by the slice sampler. The length of the vector should be equal to the number of historical datasets. The default is 0.1 for all parameter (may not be appropriate for all situations).

delta

Prespecified constant that defines the boundary of the null hypothesis. The default is zero.

gamma

Posterior probability threshold for rejecting the null. The null hypothesis is rejected if posterior probability is greater gamma. The default is 0.95.

nMC

Number of iterations (excluding burn-in samples) for the slice sampler or Gibbs sampler. The default is 10,000.

nBI

Number of burn-in samples for the slice sampler or Gibbs sampler. The default is 250.

N

Number of simulated datasets to generate. The default is 10,000.

Details

If data.type is "Bernoulli", "Poisson" or "Exponential", a single response from the treatment group is assumed to follow Bern(μ_t), Pois(μ_t) or Exp(rate=μ_t), respectively, where μ_t is the mean of responses for the treatment group. If data.type is "Normal", a single response from the treatment group is assumed to follow N(μ_t, τ^{-1}) where τ is the precision parameter. The distributional assumptions for the control group data are analogous.

samp.prior.mu.t and samp.prior.mu.c can be generated using the sampling priors (see example).

If data.type is "Bernoulli", the initial prior for μ_t is beta(prior.mu.t.shape1, prior.mu.t.shape2). If data.type is "Poisson", the initial prior for μ_t is Gamma(prior.mu.t.shape1, rate=prior.mu.t.shape2). If data.type is "Exponential", the initial prior for μ_t is Gamma(prior.mu.t.shape1, rate=prior.mu.t.shape2). The initial priors used for the control group data are analogous.

If data.type is "Normal", historical datasets are assumed to have the same precision parameter as the current dataset for computational simplicity. The initial prior for τ is the Jeffery's prior, τ^{-1}. The initial prior for the μ_c is the uniform improper prior. Posterior samples of μ_c and τ are obtained through Gibbs sampling.

Posterior samples of a_0 are obtained through slice sampling. The default lower limits for the parameters are 0. The default upper limits for the parameters are 1. The default slice widths for the parameters are 0.1. The defaults may not be appropriate for all situations, and the user can specify the appropriate limits and slice width for each parameter.

If a sampling prior with support in the null space is used, the value returned is a Bayesian type I error rate. If a sampling prior with support in the alternative space is used, the value returned is a Bayesian power.

Value

Power or type I error is returned, depending on the sampling prior used. If data.type is "Normal", average posterior means of μ_t, μ_c, τ and a_0 are also returned. For all other data types, average posterior means of μ_t, μ_c and a_0 are also returned.

References

Chen, Ming-Hui, et al. "Bayesian design of noninferiority trials for medical devices using historical data." Biometrics 67.3 (2011): 1163-1170.

Neal, Radford M. Slice sampling. Ann. Statist. 31 (2003), no. 3, 705–767.

See Also

two.grp.random.a0

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
data.type <- "Bernoulli"
n.t <- 100
n.c <- 100

# Simulate three historical datasets
historical <- matrix(0, ncol=2, nrow=3)
historical[1,] <- c(70, 100)
historical[2,] <- c(60, 100)
historical[3,] <- c(50, 100)

# Generate sampling priors
set.seed(1)
b_st1 <- b_st2 <- 1
b_sc1 <- b_sc2 <- 1
samp.prior.mu.t <- rbeta(50000, b_st1, b_st2)
samp.prior.mu.c <- rbeta(50000, b_st1, b_st2)
# The null hypothesis here is H0: mu_t - mu_c >= 0. To calculate power,
# we can provide samples of mu.t and mu.c such that the mass of mu_t - mu_c < 0.
# To calculate type I error, we can provide samples of mu.t and mu.c such that
# the mass of mu_t - mu_c >= 0.
sub_ind <- which(samp.prior.mu.t < samp.prior.mu.c)
# Here, mass is put on the alternative region, so power is calculated.
samp.prior.mu.t <- samp.prior.mu.t[sub_ind]
samp.prior.mu.c <- samp.prior.mu.c[sub_ind]

N <- 10 # N should be larger in practice
result <- power.two.grp.random.a0(data.type=data.type, n.t=n.t, n.c=n.c, historical=historical,
                                  samp.prior.mu.t=samp.prior.mu.t, samp.prior.mu.c=samp.prior.mu.c,
                                  delta=0, nMC=10000, nBI=250, N=N)

BayesPPD documentation built on Sept. 8, 2021, 5:06 p.m.