simulate.safeDesign {safestats} | R Documentation |
Simulate Early Stopping Experiments for the T Test
Description
Applied to a 'safeDesign' object this function empirically shows the performance of safe experiments under optional stopping.
Usage
## S3 method for class 'safeDesign'
simulate(
object,
nsim = nSim,
seed = NULL,
deltaTrue = NULL,
muGlobal = 0,
sigmaTrue = 1,
lowN = 3,
safeOptioStop = TRUE,
freqOptioStop = FALSE,
nPlanFreq = NULL,
logging = TRUE,
pb = TRUE,
nSim = 1,
...
)
Arguments
object |
A safeDesign obtained obtained from |
nsim |
integer, formally the number of iterations, but by default nsim=nSim |
seed |
integer, seed number. |
deltaTrue |
numeric, if NULL, then the minimally clinically relevant standardised effect size is used as the true data generating effect size deltaTrue. |
muGlobal |
numeric, the true global mean of a paired or two-sample t-test. Its value should not matter for the test. This parameter is treated as a nuisance. |
sigmaTrue |
numeric > 0,the true standard deviation of the data. Its value should not matter for the test.This parameter treated is treated as a nuisance. |
lowN |
integer that defines the smallest n of our search space for n. |
safeOptioStop |
logical, |
freqOptioStop |
logical, |
nPlanFreq |
the frequentist sample size(s) to plan for. Acquired from |
logging |
logical, if |
pb |
logical, if |
nSim |
integer, number of iterations. |
... |
further arguments to be passed to or from methods. |
Value
Returns an object of class "safeTSim". An object of class "safeTSim" is a list containing at least the following components:
- nPlan
the planned sample size(s).
- deltaTrue
the value of the true standardised effect size (test-relevant parameter) provided by the user.
- muGlobal
the true global mean of a paired or two-sample t-test (nuisance parameter) provided by the user.
- paired
if
TRUE
then paired t-test.- alternative
any of "twoSided", "greater", "less" provided by the user.
- lowN
the smallest number of samples (first group) at which monitoring of the tests begins.
- nSim
the number of replications of the experiment.
- alpha
the tolerable type I error provided by the user.
- beta
the tolerable type II error provided by the user.
- testType
any of "oneSample", "paired", "twoSample" provided by the user.
- parameter
the parameter (point prior) used in the safe test derived from the design. Acquired from
designSafeT()
.- nPlanFreq
the frequentist planned sample size(s). Acquired from
designFreqT
()- safeSim
list with the simulation results of the safe test under optional stopping.
- freqSim
list with the simulation results of the frequentist test under optional stopping.
Examples
# Design safe test
alpha <- 0.05
beta <- 0.20
deltaMin <- 1
designObj <- designSafeT(deltaMin, alpha=alpha, beta=beta, nSim=100)
# Design frequentist test
freqObj <- designFreqT(deltaMin, alpha=alpha, beta=beta)
# Simulate based on deltaTrue=deltaMin
simResultsDeltaTrueIsDeltaMin <- simulate(object=designObj, nSim=100)
# Simulate based on deltaTrue > deltaMin
simResultsDeltaTrueIsLargerThanDeltaMin <- simulate(
object=designObj, nSim=100, deltaTrue=2)
# Simulate under the null deltaTrue = 0
simResultsDeltaTrueIsNull <- simulate(
object=designObj, nSim=100, deltaTrue=0)
simulate(object=designObj, deltraTrue=0, nSim=100, freqOptioStop=TRUE,
nPlanFreq=freqObj$nPlan)