computeConfidenceIntervalZ: Helper function: Computes the savi confidence sequence for a...

View source: R/zTest.R

computeConfidenceIntervalZR Documentation

Helper function: Computes the savi confidence sequence for a Z-test

Description

Helper function: Computes the savi confidence sequence for a Z-test

Usage

computeConfidenceIntervalZ(
  nEff,
  meanObs,
  parameter,
  sigma = 1,
  ciValue = 0.95,
  alternative = "twoSided",
  a = NULL,
  g = NULL,
  eType = c("mom", "eGauss", "imom", "eCauchy", "grow", "freq", "credibleInterval"),
  maxRoot = 20
)

Arguments

nEff

numeric > 0, the effective sample size.

meanObs

numeric, the observed mean. For two sample tests this is difference of the means.

parameter

numeric > 0, the savi test defining parameter, see matchEParameterWith for details.

sigma

numeric > 0 representing the assumed population standard deviation used to scale the data.

ciValue

numeric representing the confidence level. Default ciValue=NULL yields ciValue = 1 - alpha

alternative

a character string specifying the alternative hypothesis. Must be one of "twoSided" (default), "greater" or "less".

a

numeric, only used for eType="credibleInterval". a specifies the centre of the Gaussian prior on population mean.

g

numeric > 0, only used for eType="credibleInterval". g specifies the variance of the Gaussian prior on population mean.

eType

character string, one of "eCauchy", "eGauss", "grow", "freq", "credibleInterval". This is somewhat a misnomer as "freq" and "credibleInterval" do not correspond to e-value tests. "eCauchy" yields an anytime-valid confidence interval based on a Cauchy mixture, whereas "eGauss" yields an anytime-valid confidence interval based on a Gaussian mixture. "grow" yields an anytime-valid confidence interval based on a mixture of point masses at the minimal clinically relevant mean difference. This confidence interval unfortunately does not shrink as the sample size tends to infinity. "freq" yields the standard unsafe frequentist confidence interval, which is not safe. "credibleInterval" yields the Bayesian credible interval based on a conjugate prior as is usual in Bayesian analysis. This interval is also not safe.

maxRoot

Used to bound the candidate set of width of the confidence interval, whenever eType="eCauchy"

Value

numeric vector that contains the upper and lower bound of the savi confidence sequence

References

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. Ly, A, Boehm, Grünwald, P. D., Ramdas, A., & van Ravenzwaaij, D. (2024). Safe Anytime-Valid Inference: Practical maximally flexible sampling designs for experiments based on e-values. PsyArXiv Preprint, https://doi.org/10.31234/osf.io/h5vae.

Examples

computeConfidenceIntervalZ(nEff=15, meanObs=0.3, parameter=0.2)

safestats documentation built on Sept. 6, 2026, 1:06 a.m.