Performs a two-step simulation.
Calibration Step: It first runs a simulation under the null hypothesis
(using *.calib parameters) to determine the posterior probability
thresholds (quantiles) needed to control the Type I Error Rate at the
specified typeIER.cal level.
Main Simulation Step: It then uses these calibrated thresholds to run
the main simulation (using parameters nc, nt, pc, pt) to evaluate
final operating characteristics (e.g., Type I Error or Power) and bias.
runCalibratedSAM(
nsim = 1000,
pch,
delta_threshold,
nche.c,
nc.calib,
nt.calib,
pc.calib,
xt.cal = NULL,
xc.cal = NULL,
typeIER.cal = 0.1,
nche,
nc,
nt,
pc,
pt,
xt = NULL,
xc = NULL,
nf.prior = RBesT::mixbeta(c(1, 0.001, 0.001)),
seed.hist = 1000,
seed.gMAP = 2000,
seed.SAM = 3000,
seed.cal = 4000
)A list with the following components:
A numeric vector (length 3) with the final simulation result (Type I Error or Power) for the "SAMprior", "MAP", and "Noninfo" methods.
Posterior Mean Difference (Bias) for the three methods.
Posterior SD of the Difference (Bias) for the three methods.
A matrix (3 x nsim) of posterior means for the control
rate for each simulation iteration.
A matrix (1x3) containing the decision thresholds (quantiles) determined during the calibration step for the SAM, rMAP, and Non-info methods.
The total number of simulation trials to run for both the calibration and main simulation steps.
Historical control response rate (used to generate HistData
for the RBesT::gMAP() prior).
The CSD (Clinically Significant Difference) threshold
used for the SAM prior in runSAM().
Sample size for the historical control data (HistData).
Control group sample size for the calibration step.
Treatment group sample size for the calibration step.
Control response rate for the calibration step. This is also used as the treatment response rate in this step to simulate the null hypothesis.
(Optional) A vector of pre-simulated treatment outcomes for the
calibration step. If NULL, data is simulated internally.
(Optional) A vector of pre-simulated control outcomes for the
calibration step. If NULL, data is simulated internally.
The target Type I Error rate to control for during the calibration step. Defaults to 0.1.
Historical control sample size. (Note: This parameter is defined
in the function signature but not explicitly used in the function body;
nche.c is used for calibration data generation.)
Control group sample size for the main simulation step.
Treatment group sample size for the main simulation step.
Control response rate for the main simulation step.
Treatment response rate for the main simulation step. (Note:
Set pt = pc for Type I Error, or pt > pc for Power).
(Optional) A vector of pre-simulated treatment outcomes for the
main simulation. If NULL, data is simulated internally.
(Optional) A vector of pre-simulated control outcomes for the
main simulation. Examples use RBesT::mixbeta(). If NULL, data is simulated internally.
The non-informative prior to use. Defaults to
RBesT::mixbeta(c(1, 0.001, 0.001)).
Seed for generating historical data.
Seed for the RBesT::gMAP() function.
Seed for the main runSAM simulation call.
Seed for the calibration runSAM call.
This function wraps the core runSAM() function by adding a calibration layer.
It derives historical data priors using RBesT::gMAP() and RBesT::automixfit()
based on nche.c and pch.
The calibration step (runSAM with ...calib parameters) finds the
(1 - typeIER.cal) quantiles for the posterior distributions (SAM, rMAP, Non-info)
under the null.
The main simulation step (runSAM with main parameters) then calculates the
proportion of simulations where the posterior probability exceeds these
calibrated thresholds. This proportion represents the final Type I Error or Power.
runSAM, gMAP,
automixfit, mixbeta,
decision2S
# \donttest{
# Example uses functions from the RBesT package
library(RBesT)
sim_power_pc30 <- runCalibratedSAM(
nsim = 100,
pch = 0.30,
delta_threshold = 0.1,
nche.c = 180,
nc.calib = 45,
nt.calib = 45,
pc.calib = 0.3,
typeIER.cal = 0.10,
nche = 180,
nc = 45,
nt = 45,
pc = 0.30,
pt = 0.50
)
print(sim_power_pc30$Sim_Result)
# }
Run the code above in your browser using DataLab