View source: R/newsafe2x2Test.R
| savi2x2TestStat | R Documentation |
Tests thetaA = thetaB on a stream of 2x2 tables, one per block, with
the e-process chosen by designObj[["eType"]]. Both effects are A
minus B, propDiff = thetaA - thetaB and logOdds = logit(thetaA) - logit(thetaB), so "greater" means group A has the larger proportion,
as in stats::t.test(). Block 1 of every e-process is replaced by the
UMP conditional e-value of savi2x2TestStatUmp() when one exists at
level alpha; otherwise it keeps its plain factor, with a warning.
savi2x2TestStat(
ya,
yb,
designObj = NULL,
wantCi = FALSE,
wantConfidenceSequence = FALSE,
ciValue = NULL
)
ya |
positive observations/ events per data block in group A: a
numeric with integer values between (and including) 0 and |
yb |
positive observations/ events per data block in group B: a
numeric with integer values between (and including) 0 and |
designObj |
an object obtained from |
wantCi |
default |
wantConfidenceSequence |
logical that can be set to true when the
user wants a savi confidence sequence to be estimated, one row per
block; takes precedence over |
ciValue |
numeric representing the confidence level. Default ciValue=NULL yields ciValue = 1 - alpha |
"eBeta" (propDiff): independent Beta posterior means of thetaA
and thetaB from the previous blocks, against the pooled null mean.
"grow" (propDiff or logOdds, whichever minimal effect the design
holds): the alternative restricted to the signed minimal effect;
"twoSided" averages the cumulative e-processes of both signs.
"eGauss" (logOdds): the conditional likelihood of Fisher's
noncentral hypergeometric distribution mixed under the design's Normal
prior on a logOdds grid, against the hypergeometric null. The
mixture may include the current block because it conditions on the
block's total.
Only "eBeta" and "eGauss" give a confidence interval or sequence,
each on its own effect.
Returns an object of class 'saviTest'. An object of class 'saviTest' is a list containing at least the following components:
The realised sample size(s):
c(na = sum(na), nb = sum(nb), nBlocks = length(ya)).
the e-value of the savi test on all blocks; reject when
it is at least 1 / alpha.
the realised e-values after each block, element i
on blocks 1..i.
the block index, used for plotting.
the estimated proportions c(thetaA, thetaB), pooled
over all blocks.
a savi confidence interval for the design's effect at
level ciValue on all blocks; NA when the set is empty, NULL for
"grow" or when no interval was requested.
with wantConfidenceSequence, the savi confidence
sequence as an nBlocks x 2 matrix, row i the interval on blocks
1..i; confSeq is its last row. With runningIntersection the
rows are nested and stay NA after the first empty row.
the confidence level used.
for "eBeta" only, list(betaA1, betaA2, betaB1, betaB2), the Beta prior updated with all blocks.
any of "twoSided", "greater", "less" copied from the design.
the null value copied from the design.
a character string giving the name(s) of the data.
an object of class "saviDesign" described in
designSavi2x2().
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.
Turner, R., & Grünwald, P. D. (2024). Exact anytime-valid confidence intervals for contingency tables and beyond. Statistics and Probability letters, 198, 109835, https://doi.org/10.1016/j.spl.2023.109835.
designObj <- designSavi2x2(na = 10, nb = 10, eType = "eBeta")
ya <- c(8, 7, 9, 6)
yb <- c(4, 5, 3, 5)
savi2x2TestStat(ya, yb, designObj = designObj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.