View source: R/two_grp_fixed.R
power.two.grp.fixed.a0 | R Documentation |
Power/type I error calculation for data with two groups (treatment and control group, no covariates) with fixed a_0
using power priors
power.two.grp.fixed.a0(
data.type,
n.t,
n.c,
historical = matrix(0, 1, 4),
nullspace.ineq = ">",
samp.prior.mu.t,
samp.prior.mu.c,
samp.prior.var.t,
samp.prior.var.c,
prior.mu.t.shape1 = 1,
prior.mu.t.shape2 = 1,
prior.mu.c.shape1 = 1,
prior.mu.c.shape2 = 1,
delta = 0,
gamma = 0.95,
nMC = 10000,
nBI = 250,
N = 10000
)
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 |
(Optional) matrix of historical dataset(s). If
For all other data types,
Each row represents a historical dataset. |
nullspace.ineq |
Character string specifying the inequality of the null hypothesis. The options are ">" and "<". If ">" is specified, the null hypothesis (for non-exponential data) is |
samp.prior.mu.t |
Vector of possible values of |
samp.prior.mu.c |
Vector of possible values of |
samp.prior.var.t |
Vector of possible values of |
samp.prior.var.c |
Vector of possible values of |
prior.mu.t.shape1 |
First hyperparameter of the initial prior for |
prior.mu.t.shape2 |
Second hyperparameter of the initial prior for |
prior.mu.c.shape1 |
First hyperparameter of the initial prior for |
prior.mu.c.shape2 |
Second hyperparameter of the initial prior for |
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 |
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. |
If data.type
is "Bernoulli", "Poisson" or "Exponential", a single response from the treatment group is assumed to follow Bern(\mu_t
), Pois(\mu_t
) or Exp(rate=\mu_t
), respectively,
where \mu_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(\mu_t, \tau^{-1})
where \tau
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 \mu_t
is
beta(prior.mu.t.shape1
, prior.mu.t.shape2
).
If data.type
is "Poisson", the initial prior for \mu_t
is
Gamma(prior.mu.t.shape1
, rate=prior.mu.t.shape2
).
If data.type
is "Exponential", the initial prior for \mu_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", each historical dataset D_{0k}
is assumed to have a different precision parameter \tau_k
.
The initial prior for \tau
is the Jeffery's prior, \tau^{-1}
, and the initial prior for \tau_k
is \tau_k^{-1}
.
The initial prior for the \mu_c
is the uniform improper prior.
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.
If data.type
is "Normal", Gibbs sampling is used for model fitting. For all other data types,
numerical integration is used for modeling fitting.
The function returns a S3 object with a summary
method. Power or type I error is returned, depending on the sampling prior used.
The posterior probabilities of the alternative hypothesis are returned.
Average posterior means of \mu_t
and \mu_c
and their corresponding biases are returned.
If data.type
is "Normal", average posterior means of \tau
and \tau_k
's (if historical data is given) are also returned.
Yixuan Qiu, Sreekumar Balan, Matt Beall, Mark Sauder, Naoaki Okazaki and Thomas Hahn (2019). RcppNumerical: 'Rcpp' Integration for Numerical Computing Libraries. R package version 0.4-0. https://CRAN.R-project.org/package=RcppNumerical
Chen, Ming-Hui, et al. "Bayesian design of noninferiority trials for medical devices using historical data." Biometrics 67.3 (2011): 1163-1170.
two.grp.fixed.a0
data.type <- "Bernoulli"
n.t <- 100
n.c <- 100
# Simulate three historical datasets
historical <- matrix(0, ncol=3, nrow=3)
historical[1,] <- c(70, 100, 0.3)
historical[2,] <- c(60, 100, 0.5)
historical[3,] <- c(50, 100, 0.7)
# 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 <- 1000 # N should be larger in practice
result <- power.two.grp.fixed.a0(data.type=data.type, n.t=n.t, n.c=n.t, historical=historical,
samp.prior.mu.t=samp.prior.mu.t, samp.prior.mu.c=samp.prior.mu.c,
delta=0, N=N)
summary(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.