View source: R/newsafe2x2Test.R
| designSavi2x2 | R Documentation |
A designed experiment requires (1) a number of data blocks nBlocksPlan
to plan for, and (2) a savi test defining parameter: eType and, with
it, the effect measure. Both effects are A minus B and anchored on
thetaB: propDiff = thetaA - thetaB and logOdds = logit(thetaA) - logit(thetaB), so "greater" means group A has the larger proportion,
as x - y > 0 does in stats::t.test().
designSavi2x2(
na,
nb,
nBlocksPlan = NULL,
propDiffMin = NULL,
logOddsMin = NULL,
alpha = 0.05,
power = NULL,
h0 = 0,
alternative = c("twoSided", "greater", "less"),
eType = c("eBeta", "grow", "eGauss"),
betaParameter = NULL,
gaussParameter = NULL,
runningIntersection = NULL,
nSim = 1000L,
nBoot = 1000L,
nMax = 10000L,
seed = NULL,
wantSamplePaths = FALSE,
pb = TRUE
)
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. |
nBlocksPlan |
planned number of data blocks collected, see scenario 2 and 3 above. |
propDiffMin |
numeric in (-1, 1) that defines the minimal relevant
difference in proportions |
logOddsMin |
numeric that defines the minimal relevant log odds
ratio |
alpha |
numeric in (0, 1) that specifies the tolerable type I error and the null rejection rule e >= 1/alpha. |
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. |
h0 |
numeric, representing the null value, default h0=0. Only
|
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 |
character one of "eBeta", "grow", and "eGauss". "eBeta" is default and uses a Beta prior on each proportion, "grow" uses a point prior at the minimal effect, "eGauss" a normal prior on the log odds ratio. |
betaParameter |
|
gaussParameter |
|
runningIntersection |
logical, if |
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 |
pb |
logical, if |
"eBeta" (propDiff) and "eGauss" (logOdds) are unrestricted: a
minimal effect is an error, a power is dropped with a warning, and
nBlocksPlan is kept as the planned block count. Each reads one
prior, betaParameter or gaussParameter; NULL keeps the default,
which savi2x2TestStat() fills in. A one-sided alternative acts in
the UMP first block, and for "eGauss" also restricts the prior to
that side.
"grow" plugs in exactly one of propDiffMin, logOddsMin as the
fixed alternative and reads no prior. As in designSaviZ(), a value
whose sign contradicts a one-sided alternative is flipped with a
warning; "twoSided" uses the magnitude. Zero is an error.
For "grow" on propDiff the design involves alpha and the three
quantities: (1) nBlocksPlan, (2) power, and (3) a minimal relevant
difference in proportions propDiffMin, simulated at the worst-case
baseline of sampleStoppingTimesSavi2x2().
Goal: "nBlocksPlan" and optimal E-variable. Given: propDiffMin and power.
Goal: "power" and optimal E-variable. Given: propDiffMin and nBlocksPlan.
Goal: "propDiffMin" and optimal E-variable. Given: power and nBlocksPlan.
A minimal effect alone designs without simulation. Any other
combination is an error, except that logOddsMin drops a power with
a warning. Per-block size vectors supply nBlocksPlan when it is NULL.
Other arguments are taken as given; only alpha and power in
(0, 1), equal lengths of na and nb, at most one minimal effect,
and the minimal effects' ranges are checked.
Returns a saviDesign object that includes:
the planned sample size(s): list(na, nb), with
nBlocksPlan when given or planned.
for "eBeta" and "eGauss", the prior as one named
string, or "default" when NULL; absent for "grow", whose minimal
effect is esMin.
the minimal relevant effect size provided by the user, or
found in scenario 3, signed and named propDiff or logOdds; NULL
for "eBeta" and "eGauss".
the tolerable type I error provided by the user.
the desired power provided by the user, or the worst-case power found in scenario 2.
any of "twoSided", "greater", "less" provided by the user.
any of "eBeta", "grow", "eGauss" provided by the user.
the null value, 0.
for "eBeta" and "grow" on propDiff, the Beta prior
given, NULL for the default.
for "eGauss", the Normal prior given, NULL for
the default.
logical, as provided by the user.
"1a", "2" or "3" when planned.
scenario 1a: the bootstrap summaries of the planned block count and of the mean stopping time.
scenario 2: the bootstrap summaries of the power.
scenarios 1a and 2: the worst baseline and its simulated paths.
here 2x2
"Two Proportions".
the expression with which this function is called.
Grünwald, P. D., de Heide, R., & Koolen, W. (2024). Safe testing. Journal of the Royal Statistical Society. Series B (Methodological), 86(5), 1091-1128. (With discussions), https://doi.org/10.1093/jrsssb/qkae011.
Turner, R., Ly, A., & Grünwald, P. D. (2024). Generic e-variables for exact sequential k-sample tests that allow for optional stopping. Journal of Statistical Planning and inference 230, 106116, https://doi.org/10.1016/j.jspi.2023.106116.
# Unrestricted test on propDiff with the default Beta prior
designSavi2x2(na = 10, nb = 10, eType = "eBeta")
# Grow on a minimal difference, no planning
designSavi2x2(na = 10, nb = 10, propDiffMin = 0.2, eType = "grow")
# Scenario 2: worst-case power at a planned block count
designSavi2x2(na = 10, nb = 10, propDiffMin = 0.3, nBlocksPlan = 8,
eType = "grow", nSim = 50, pb = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.