computeNPlanSavi2x2: Helper function: Computes nBlocksPlan based on propDiffMin,...

View source: R/newsafe2x2Test.R

computeNPlanSavi2x2R Documentation

Helper function: Computes nBlocksPlan based on propDiffMin, alpha and power

Description

Runs sampleStoppingTimesSavi2x2() and reports its nPlan, the power quantile of the stopping time at the hardest baseline, with a bootstrap SE and the mean stopping time of paths capped at nPlan, both at that baseline.

Usage

computeNPlanSavi2x2(
  propDiffMin,
  na,
  nb,
  power = 0.8,
  alpha = 0.05,
  alternative = c("twoSided", "less", "greater"),
  nSim = 1000L,
  nBoot = nSim,
  nMax = 10000L,
  seed = NULL,
  wantSamplePaths = FALSE,
  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.

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.

nBoot

integer > 0 representing the number of bootstrap samples to assess the accuracy of the approximations of the power, or the number of blocks for the savi 2x2 test under continuous monitoring.

nMax

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

seed

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

wantSamplePaths

logical, if TRUE then also outputs the sample paths.

pb

logical, if TRUE, then show progress bar.

Value

a list which contains at least nPlan (the worst-case block count, Inf with a warning when the worst baseline crossed too rarely) and adapted bootObjects bootObjNPlan and bootObjNMean of class boot::boot() on the worst baseline (NULL when nPlan is Inf); further nPlanVec (the quantile per curve), nMean, worstCaseThetaA, worstCaseThetaB, and the sampler's thetaA, thetaB, stoppingTimes, breakVector, eValuesStopped, samplePaths, n1Vector.


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