Description Usage Arguments Details Value References See Also Examples
Power/type I error calculation for generalized linear models with fixed a_0 using power priors
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 
data.type 
Character string specifying the type of response. The options are "Normal", "Bernoulli", "Binomial", "Poisson" and "Exponential". 
data.link 
Character string specifying the link function. The options are "Logistic", "Probit", "Log", "IdentityPositive", "IdentityProbability" and "Complementary LogLog". Does not apply if 
data.size 
Sample size of the simulated datasets. 
n 
(For binomial data only) vector of integers specifying the number of subjects who have a particular value of the covariate vector. If the data is binary and all covariates are discrete, collapsing Bernoulli data into a binomial structure can make the slice sampler much faster. 
historical 
(Optional) list of historical dataset(s). East historical dataset is stored in a list which contains three named elements:
For binomial data, an additional element

x.samples 
Matrix of possible values of covariates from which covariate vectors are sampled with replacement. Only applies when there is no historical dataset. The matrix should not include the treatment indicator. 
samp.prior.beta 
Matrix of possible values of β to sample (with replacement) from. Each row is a possible β vector (a realization from the sampling prior for β), where the first element is the coefficient for the intercept and the second element is the coefficient for the treatment indicator.
The length of the vector should be equal to the total number of parameters, i.e. P+2 where P is the number of columns of 
samp.prior.var 
Vector of possible values of σ^2 to sample (with replacement) from. Only applies if 
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 total number of parameters, i.e. P+1 where P is the number of covariates. The default is 100 for all parameters (may not be appropriate for all situations). Does not apply if 
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 total number of parameters, i.e. P+1 where P is the number of covariates. The default is 100 for all parameters (may not be appropriate for all situations). Does not apply if 
slice.widths 
Vector of initial slice widths for parameters to be used by the slice sampler. The length of the vector should be equal to the total number of parameters, i.e. P+1 where P is the number of covariates. The default is 1 for all parameter (may not be appropriate for all situations). Does not apply if 
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 burnin samples) for the slice sampler or Gibbs sampler. The default is 10,000. 
nBI 
Number of burnin 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 historical datasets are provided, the algorithm samples with replacement from the historical covariates to construct the simulated datasets.
Otherwise, the algorithm samples with replacement from x.samples
. One of the arguments historical
and x.samples
must be provided.
samp.prior.beta
can be generated using the sampling priors (see example).
samp.prior.var
is necessary for generating normally distributed data.
If data.type
is "Normal", the response y_i is assumed to follow N(x_i'β, τ^{1}) where x_i is the vector of covariates for subject i.
Each historical dataset D_{0k} is assumed to have a different precision parameter τ_k.
The initial prior for τ is the Jeffery's prior, τ^{1}, and the initial prior for τ_k is τ_k^{1}.
The initial prior for β is the uniform improper prior. Posterior samples are obtained through Gibbs sampling.
For all other data types, posterior samples are obtained through slice sampling. The initial prior for β is the uniform improper prior. The default lower limits for the parameters are 100. The default upper limits for the parameters are 100. The default slice widths for the parameters are 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.
Power or type I error is returned, depending on the sampling prior used. If data.type
is "Normal", average posterior means of β, τ and τ_k's (if historical data is given) are also returned.
For all other data types, the average posterior mean of β is also returned. The first column of β contains posterior samples of the intercept. The second column contains posterior samples of β_1, the parameter for the treatment indicator.
Chen, MingHui, et al. "Bayesian design of noninferiority trials for medical devices using historical data." Biometrics 67.3 (2011): 11631170.
Neal, Radford M. Slice sampling. Ann. Statist. 31 (2003), no. 3, 705–767.
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  data.type < "Bernoulli"
data.link < "Logistic"
data.size < 100
# Simulate two historical datasets
p < 3
historical < list(list(y0=rbinom(data.size,size=1,prob=0.2),
x0=matrix(rnorm(p*data.size),ncol=p,nrow=data.size), a0=0.2),
list(y0=rbinom(data.size, size=1, prob=0.5),
x0=matrix(rnorm(p*data.size),ncol=p,nrow=data.size), a0=0.3))
# Generate sampling priors
# The null hypothesis here is H0: beta_1 >= 0. To calculate power,
# we can provide samples of beta_1 such that the mass of beta_1 < 0.
# To calculate type I error, we can provide samples of beta_1 such that
# the mass of beta_1 >= 0.
samp.prior.beta1 < rnorm(100, mean=3, sd=1)
# Here, mass is put on the alternative region, so power is calculated.
samp.prior.beta < cbind(rnorm(100), samp.prior.beta1, matrix(rnorm(100*p), 100, p))
nMC < 100 # nMC should be larger in practice
nBI < 50
N < 5 # N should be larger in practice
result < power.glm.fixed.a0(data.type=data.type, data.link=data.link,
data.size=data.size, historical=historical,
samp.prior.beta=samp.prior.beta,
delta=0, nMC=nMC, nBI=nBI, N=N)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.