sampleStoppingTimesSavi2x2: Simulate stopping times for the savi 2x2 test

View source: R/newsafe2x2Test.R

sampleStoppingTimesSavi2x2R Documentation

Simulate stopping times for the savi 2x2 test

Description

Draws nSim streams of tables on the curve ⁠thetaA = thetaB + |propDiffMin|⁠ for "greater", ⁠thetaA = thetaB - |propDiffMin|⁠ for "less", and on both curves for "twoSided", at the worst-case baseline of each curve from solveWorstCaseTheta2x2PropDiff(), and records when the plain grow e-process first crosses 1 / alpha. nPlan is the worst power quantile of the stopping time over the curves; with power = NULL it is skipped. There is no planning on logOdds.

Usage

sampleStoppingTimesSavi2x2(
  propDiffMin,
  na,
  nb,
  power = NULL,
  alpha = 0.05,
  alternative = c("twoSided", "less", "greater"),
  eType = c("grow"),
  nSim = 1000L,
  nMax = 10000L,
  nBoot = 10000L,
  seed = NULL,
  wantEValuesAtNMax = FALSE,
  wantSamplePaths = FALSE,
  wantSimData = TRUE,
  pb = TRUE
)

Arguments

propDiffMin

numeric in (-1, 1) that defines the minimal relevant difference in proportions thetaA - thetaB, the smallest difference that we would like to detect (with sufficient power).

na

number of observations in group A per data block, one value or one per block.

nb

number of observations in group B per data block, one value or one per block.

power

numeric in (0, 1) that specifies the desired power, that is, the targetted chance to stop in favour of the alternative over the null hypothesis, when the alternative holds true.

alpha

numeric in (0, 1) that specifies the tolerable type I error and the null rejection rule e >= 1/alpha.

alternative

a character string specifying the alternative hypothesis. Must be one of "twoSided" (default), "greater" or "less", where "greater" means that group A has the larger proportion.

eType

"grow", the only e-variable with planning.

nSim

integer > 0, the number of simulations needed to compute power or the number of samples paths for the savi 2x2 test under continuous monitoring.

nMax

integer > 0, maximum number of data blocks in each sample path.

nBoot

integer > 0, the number of bootstrap samples; not used by the sampler itself, see computePowerSavi2x2() and computeNPlanSavi2x2().

seed

integer, seed number. Default seed=NULL yields seed=2026.

wantEValuesAtNMax

logical. If TRUE, then compute eValues at nMax. Default FALSE. Not yet implemented.

wantSamplePaths

logical, if TRUE then also outputs the sample paths.

wantSimData

logical. If TRUE, then output the simulated data. Not yet implemented.

pb

logical, if TRUE, then show progress bar.

Value

a list with thetaA, thetaB (one per curve) and, one row per curve, stoppingTimes and breakVector. Entries of breakVector are 0, 1. A 1 represents stopping due to exceeding nMax, which implies that the corresponding stopping time is Inf, and 0 due to 1/alpha threshold crossing. Further eValuesStopped, samplePaths (a list of ⁠nSim x nMax⁠ sparse matrices, or NULL), n1Vector (the block index), nPlan, and the baseline it was taken at, worstCaseThetaA, worstCaseThetaB.


safestats documentation built on Oct. 5, 2026, 9:07 a.m.