c212.BB {c212} | R Documentation |
Implementation of the Berry and Berry Three-Level Hierarchical Model.
Description
Implementaion of Berry and Berry model (2004), also model 1b from Xia et al (2011).
Usage
c212.BB(trial.data, burnin = 20000, iter = 60000, nchains = 3,
theta_algorithm = "MH", sim_type = "SLICE",
global.sim.params = data.frame(type = c("MH", "MH", "MH", "MH",
"SLICE", "SLICE", "SLICE"),
param = c("sigma_MH_alpha", "sigma_MH_beta", "sigma_MH_gamma",
"sigma_MH_theta", "w_alpha", "w_beta", "w_gamma"),
value = c(3, 3, 0.2, 0.2, 1, 1, 1), control = c(0, 0, 0, 0, 6, 6, 6),
stringsAsFactors = FALSE),
sim.params = NULL,
initial_values = NULL,
hyper_params = list(mu.gamma.0.0 = 0,
tau2.gamma.0.0 = 10, mu.theta.0.0 = 0, tau2.theta.0.0 = 10,
alpha.gamma.0.0 = 3, beta.gamma.0.0 = 1, alpha.theta.0.0 = 3,
beta.theta.0.0 = 1, alpha.gamma = 3,
beta.gamma = 1, alpha.theta = 3, beta.theta = 1,
lambda.alpha = 1.0, lambda.beta = 1.0),
global.pm.weight = 0.5,
pm.weights = NULL,
adapt_params = data.frame(min_w = 0.25, chains = 3, burnin = 20000,
iter = 40000),
adapt_phase=0)
Arguments
trial.data |
A file or data frame containing the trial data. It must contain must contain the columns B (body-system), AE (adverse event), Group (1 - control, 2 treatment), Count (total number of events), Total (total number of participants). |
burnin |
The burnin period for the monte-carlo simulation. These are discarded from the returned samples. |
iter |
The total number of iterations for which the monte-carlo simulation is run. This includes the burnin period. The total number of samples returned is iter - burnin |
nchains |
The number of independent chains to run. |
theta_algorithm |
MCMC algorithm used to sample the theta variables. "MH" is the only currently supported stable algorithm. |
sim_type |
The type of MCMC method to use for simulating from non-standard distributions apart from theta. Allowed values are "MH" and "SLICE" for Metropolis_Hastings and Slice sampling respectively. |
global.sim.params |
A data frame containing the parameters for the simulation type sim_type. For "MH" the parameter is the variance of the normal distribution used to simulate the next candidate value centred on the current value. For "SLICE" the parameters are the estimated width of the slice and a value limiting the search for the next sample. |
sim.params |
A dataframe containing simulation parameters which override the global simulation parameters (global.sim.params) for particular model parameters. sim.params must contain the following columns: type: the simulation type ("MH" or "SLICE"); variable: the model parameter for which the simulation parameters are being overridden; B: the body-system (if applicable); AE: the adverse event (if applicable); param: the simulation parameter; value: the overridden value; control: the overridden control value. The function c212.sim.control.params generates a template for sim.params which can be edited by the user. |
initial_values |
The initial values for starting the chains. If NULL (the default) is passed the function generates the initial values for the chains. initial_values is a list with the following format: list(gamma, theta, mu.gamma, mu.theta, sigma2.gamma, sigma2.theta, pi, mu.gamma.0, mu.theta.0, tau2.gamma.0, tau2.theta.0, alpha.pi, beta.pi) The function c212.gen.initial.values can be used to generate a template for the list which can be updated by the user if required. The formats of the list elements are as follows: gamma, theta: dataframe with columns B, AE, chain, value mu.gamma, mu.theta, sigma2.gamma, sigma2.theta, pi: dataframe with columns B, chain, value mu.gamma.0, mu.theta.0, tau2.gamma.0, tau2.theta.0, alpha.pi, beta.pi: array of size chain. |
hyper_params |
The hyperparameters for the model. The default hyperparameters are those given in Berry and Berry 2004. |
global.pm.weight |
A global weighting for the proposal distribution used to sample theta. |
pm.weights |
Override global.pm.weight for specific adverse events. |
adapt_params |
Unused parameter. |
adapt_phase |
Unused parameter. |
Details
The model is fitted by a Gibbs sampler. The details of the complete conditional densities are given in Berry and Berry (2004).
Value
The output from the simulation including all the sampled values is as follows:
list(id, theta_alg, sim_type, chains, nBodySys, maxAEs, nAE, AE, B, burnin, iter, mu.gamma.0, mu.theta.0, tau2.gamma.0, tau2.theta.0, mu.gamma, mu.theta, sigma2.gamma, sigma2.theta, pi, alpha.pi, beta.pi, alpha.pi_acc, beta.pi_acc, gamma, theta, gamma_acc, theta_acc, theta_zero_prop, theta_zero_acc)
where
id - a string identifying the version of the function
theta_alg - an string identifying the algorithm used to sample theta
sim_type - an string identifying the sampling method used for non-standard distributions, either "MH" or "SLICE"
chains - the number of chains for which the simulation was run
nBodySys - the number of body-systems
maxAEs - the maximum number of AEs in a body-system
nAE - an array. The number of AEs in each body-system.
AE - an array of dimension nBodySys, maxAEs. The Adverse Events.
B - an array. The body-systems.
mu.gamma.0 - array of samples of dimension chains, iter - burnin
mu.theta.0 - array of samples of dimension chains, iter - burnin
tau2.gamma.0 - array of samples of dimension chains, iter - burnin
tau2.theta.0 - array of samples of dimension chains, iter - burnin
mu.gamma - array of samples of dimension chains, nBodySys iter - burnin
mu.theta - array of samples of dimension chains, nBodySys iter - burnin
sigma2.gamma - array of samples of dimension chains, nBodySys iter - burnin
sigma2.theta - array of samples of dimension chains, nBodySys iter - burnin
pi - array of samples of dimension chains, nBodySys iter - burnin alpha.pi - array of samples of dimension chains, iter - burnin beta.pi - array of samples of dimension chains, iter - burnin
alpha.pi_acc - the acceptance rate for the alpha.pi samples if a Metropolis-Hastings method is used. An array of dimension chains, maxAEs
beta.pi_acc - the acceptance rate for the beta.pi samples if a Metropolis-Hastings method is used. An array of dimension chains, maxAEs
gamma - array of samples of dimension chains, nBodySys, maxAEs, iter - burnin
theta - array of samples of dimension chains, nBodySys, maxAEs, iter - burnin
gamma_acc - the acceptance rate for the gamma samples if a Metropolis-Hastings method is used. An array of dimension chains, nBodySys, maxAEs
theta_acc - the acceptance rate for the theta samples. An array of dimension chains, nBodySys, maxAEs
theta_zero_prop - the number of zeros proposed in theta sampling. An array of dimension chains, nBodySys, maxAEs theta_zero_acc - the acceptance rate for zeros for the theta samples. An array of dimension chains, nBodySys, maxAEs
Note
The function performs the simulation and returns the raw output. No checks for convergence are performed.
Author(s)
R. Carragher
References
S. M. Berry and D. A. Berry (2004). Accounting for multiplicities in assessing drug safety: a three- level hierarchical mixture model. Biometrics, 60(2):418-26.
H. Amy Xia, Haijun Ma, and Bradley P. Carlin (2011). Bayesian hierarchical modelling for detecting safety signals in clinical trials. Journal of Biopharmaceutical Statistics, 21(5):1006– 1029.
Scott M. Berry, Bradley P. Carlin, J. Jack Lee, and Peter M¨ller (2010). Bayesian adaptive methods for clinical trials. CRC Press.
Examples
data(c212.trial.data)
raw = c212.BB(c212.trial.data, burnin = 100, iter = 200)
## Not run:
data(c212.trial.data)
raw = c212.BB(c212.trial.data)
raw$B
[1] "Bdy-sys_1" "Bdy-sys_2" "Bdy-sys_3" "Bdy-sys_4" "Bdy-sys_5" "Bdy-sys_6"
[7] "Bdy-sys_7" "Bdy-sys_8"
mean(raw$theta[2, 1,1,])
[1] 0.1088401
median(raw$theta[2, 1,1,])
[1] 0
## End(Not run)