# Safe Anytime-Valid Inference

## Documentation for package ‘safestats’ version 0.8.8

- DESCRIPTION file.
- User guides, package vignettes and other documentation.
- Package NEWS.

## Help Pages

A C D E G I L M P R S T Z

## -- A --

addCite | Add a savi reference

## -- C --

ceil | A ceiling function with a tolerance at the 13th digit
checkAndReturnEsMinParameterSide | Checks consistency between the sided of the hypothesis and the minimal clinically relevant effect size or savi test defining parameter. Throws an error if the one-sided hypothesis is incongruent with the
checkAndReturnNPlan | Check consistency between nPlan and the testType for one and two-sample z and t-tests
checkAndReturnsEsMinParameterSide | Checks consistency between the sided of the hypothesis and the minimal clinically relevant effect size or safe test defining parameter. Throws an error if the one-sided hypothesis is incongruent with the
checkDoubleArgumentsDesignObject | Helper function to check whether arguments are specified in a function at a higher level and already provided in the design object.
compute1F1AllVersions | Computes 6 equivalent forms of the confluent hypergeometric function 1f1
computeBetaBatchSafeZ | Helper function: Computes 1-power based on meanDiffTrue and nPlan
computeBetaBatchSaviZ | Helper function: Computes 1-power based on meanDiffTrue and nPlan
computeBetaBootstrapper | Helper function to compute uncertainty regarding nPlan estimates
computeBetaSafeT | Helper function: Computes the power of the saviTTest based on deltaMin and nPlan
computeBetaSafeZ | Helper function: Computes the power based on meanDiffTrue and nPlan
computeBootObj | Computes the bootObj for sequential sampling procedures regarding nPlan, beta, the implied target
computeConfidenceBoundForLogOddsTwoProportions | Estimate an upper or lower bound for a savi confidence sequence on the logarithm of the odds ratio for two proportions.
computeConfidenceBoundsForDifferenceTwoProportions | Estimate Lower and Upper Bounds on the Confidence Sequence (Interval) for the Difference Divergence Measure for Two Proportions
computeConfidenceIntervalT | Helper function: Computes the savi confidence sequence for the mean in a T-test
computeConfidenceIntervalZ | Helper function: Computes the savi confidence sequence for a Z-test
computeConjugateCredibleIntervalTwoSampleT | Computes the credible interval of a two-sample t-test based on conjugate priors
computeLogrankBetaFrom | Helper function: Computes the type II error under optional stopping based on the minimal clinically relevant hazard ratio and the maximum number of nEvents.
computeLogrankNEvents | Helper function: Computes the planned sample size based on the minimal clinical relevant hazard ratio, alpha and beta under optional stopping.
computeLogrankZ | Helper function to computes the logrank statistic for 'Surv' objects of type "right" and "counting" with the hypergeometric variance.
computeMinEsBatchSafeT | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
computeMinEsBatchSafeZ | Computes the meanDiffMin that is detectable with probability "power" for given nPlan
computeMinEsBatchSaviT | Computes the smallest detectable deltaMin with power probability, for the provided sample size
computeMinEsBatchSaviZ | Computes the meanDiffMin that is detectable with probability "power" for given nPlan
computeNEff | Help function to compute the effective sample size based on a length 2 vector of samples
computeNPlanBatchSafeT | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
computeNPlanBatchSafeZ | Helper function: Computes nPlan based on meanDiffTrue, alpha and power.
computeNPlanBatchSaviT | Helper function: Computes the planned sample size for the savi T-test based deltaMin, alpha and power
computeNPlanBatchSaviZ | Helper function: Computes nPlan based on meanDiffTrue, alpha and power.
computeNPlanBootstrapper | Helper function to compute uncertainty regarding nPlan estimates
computeNPlanSafeT | Helper function: Computes nPlan based on deltaMin and power
computeNPlanSafeZ | Helper function: Computes nPlan based on meanDiffTrue, alpha and power
computeNPlanSaviT | Helper function: Computes nPlan based on deltaMin and power
computeNPlanSaviZ | Helper function: Computes nPlan based on meanDiffTrue, alpha and power
computePowerBootstrapper | Helper function to compute uncertainty regarding nPlan estimates
computePowerSaviT | Helper function: Computes the power of the saviTTest based on deltaMin and nPlan
computePowerSaviZ | Helper function: Computes the power based on meanDiffTrue and nPlan
computeStatsForLogrank | Computes the sufficient statistics needed to compute 'logrankSingleZ'
computeZTSumStats | Helper function to compute the relevant summary statistics in z and t-tests
conjugateBfTStat | A "subjective" Bayes factor for the two-sample T-test
conjugateBfTStatOld | A "subjective" Bayes factor for the two-sample T-test
constructSafeDesignObj | Construct a savi design object to be set in the design function
constructSafeTestObj | Construct a savi test object to be set in the savi testing function
constructSampleStoppingTimesList | Construct a list to be set in the sampleStoppingTimes... function
constructSaviDesignObj | Construct a savi design object to be set in the design function
constructSaviTestObj | Construct a savi test object to be set in the savi testing function

## -- D --

defineTTestN | Computes a Sequence of (Effective) Sample Sizes of Z- and T-Tests
designFreqT | Design a Frequentist T-Test
designFreqZ | Design a Frequentist Z-Test
designSafe1aHelper | Helper function that extract the results for the design scenario 1a: Target nPlan
designSafe2Helper | Helper function that extract the results for the design scenario 1a: Target nPlan
designSafeLogrank | Designs a Safe Anytime-Valid Logrank Test Experiment
designSafeLogrank2WantBeta | Helper function to design a savi logrank test (output beta)
designSafeT | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSafeT1aWantNPlan | Helper function to designing a savi T-test (output nPlan)
designSafeT2WantBeta | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSafeT3bWantParameter | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSafeT3WantEsMin | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSafeTwoProportions | Designs a Savi Experiment to Test Two Proportions in Stream Data
designSafeZ | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSafeZ1aWantNPlan | Helper function to designing a savi Z-test (output nPlan)
designSafeZ2WantBeta | Helper function to designing a Z-test (output power)
designSafeZ3bWantParameter | Helper function to designing a Z-test (output meanDiffMin based on the shortest interval at nPlan)
designSafeZ3WantEsMin | Helper function to designing a Z-test (output esMin)
designSavi1aHelper | Helper function that extract the results for the design scenario 1a: Target nPlan
designSavi2Helper | Helper function that extract the results for the design scenario 1a: Target nPlan
designSaviLogrank | Designs a Safe Anytime-Valid Logrank Test Experiment
designSaviLogrank2WantBeta | Helper function to design a savi logrank test (output beta)
designSaviT | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSaviT1aWantNPlan | Helper function to designing a savi T-test (output nPlan)
designSaviT2WantPower | Helper function to designing a savi T-test (output power)
designSaviT3bWantParameter | Helper function to designing a savi T-test (output deltaMin based on the shortest interval at nPlan)
designSaviT3WantEsMin | Helper function to designing a Savi T-test (output esMin)
designSaviTwoProportions | Designs a Savi Experiment to Test Two Proportions in Stream Data
designSaviZ | Design a Safe Anytime-Valid Experiment to Test Means with a Z Test
designSaviZ1aWantNPlan | Helper function to designing a savi Z-test (output nPlan)
designSaviZ2WantPower | Helper function to designing a Z-test (output power)
designSaviZ3bWantParameter | Helper function to designing a Z-test (output meanDiffMin based on the shortest interval at nPlan)
designSaviZ3WantEsMin | Helper function to designing a Z-test (output esMin)

## -- E --

extractNameFromArgs | Helper function: Get all names as entered by the user

## -- G --

generateNormalData | Generates Normally Distributed Data Depending on the Design
generateSurvData | Generate Survival Data which Can Be Analysed With the 'survival' Package
getArgs | Helper function: Get all arguments as entered by the user
getNameAlternative | Gets the Label of the Alternative Hypothesis
getNameTestType | Gets the Label of the Test

## -- I --

isTryError | Checks Whether a Vector of Object Inherits from the Class 'try-error'

## -- L --

lcosh | Logarithmic hyperbolic cosine
logrankSingleEExact | Helper function computes single component of the exact logrank e-value
logrankSingleZ | Helper function computes single component of the logrank statistic

## -- M --

makeRunningIntersection | Helper function to create running intersections
matchAlphaRelevanceWith | Checks and outputs a threshold for a minimal efficacy analysis
matchEParameterWith | Match the parameter of a savi z or t-test
matchEsMinWith | Match the meanDiffMin of a savi z-test
matchPowerWith | Helper function to check whether the power or beta (redundant now) argument is given
matchRelevanceParameterWith | Match the parameter of a minimal efficacy savi z-test

## -- P --

plot.safe2x2Sim | Plots Results of Simulations for Comparing Hyperparameters for Savi Tests of Two Proportions
plot.safeDesign | Plots the saviDesign object for designs with sample paths
plot.safeTest | Plots the saviTest object for sequential analyses
plot.savi2x2Sim | Plots Results of Simulations for Comparing Hyperparameters for Savi Tests of Two Proportions
plot.saviDesign | Plots the saviDesign object for designs with sample paths
plot.saviTest | Plots the saviTest object for sequential analyses
plotConfidenceSequenceTwoProportions | Plot bounds of a savi confidence sequence of the difference or log odds ratio for two proportions against the number of data blocks in two data streams ya and yb.
plotHistogramDistributionStoppingTimes | Plots the Histogram of Stopping Times
print.safe2x2Sim | Prints Results of Simulations for Comparing Hyperparameters for Savi Tests of Two Proportions
print.safeDesign | Print Method for Savi Test Objects
print.safeTest | Print Method for Savi Test Objects
print.savi2x2Sim | Prints Results of Simulations for Comparing Hyperparameters for Savi Tests of Two Proportions
print.saviDesign | Print Method for Savi Test Objects
print.saviTest | Print Method for Savi Test Objects
pValueFromZStat | Computes the p-value for the Z-test
pValueZTest | Computes the p-value for the Z-test

## -- R --

returnOne | Auxiliary function for sampling of the logrank simulations to return the integer 1 event per time.
rLogrank | Randomly samples from a logrank distribution

## -- S --

safe.prop.test | Perform a Savi Test for Two Proportions with Stream Data
safe.t.test | Safe Anytime-Valid Student's T-Test.
safe.z.test | Safe Anytime-Valid Z-Test
safeLogrankTest | Safe Anytime-Valid Logrank Test
safeLogrankTestStat | Safe Anytime-Valid Logrank Test
safeTTest | Safe Anytime-Valid Student's T-Test.
safeTTest.default | Safe Anytime-Valid Student's T-Test.
safeTTest.formula | Safe Anytime-Valid Student's T-Test.
safeTTestStat | Safe Anytime-Valid Student's T-Test.
safeTTestStatNEffNu | Safe Anytime-Valid Student's T-Test.
safeTTestStatNEffNuMom | Safe Anytime-Valid Student's T-Test.
safeTTestStatTDensity | Safe Anytime-Valid Student's T-Test.
safeTwoProportionsTest | Perform a Savi Test for Two Proportions with Stream Data
safeZTest | Safe Anytime-Valid Z-Test
safeZTest.default | Safe Anytime-Valid Z-Test
safeZTest.formula | Safe Anytime-Valid Z-Test
safeZTestStat | Computes E-Values Based on the Z-Statistic
sampleLogrankStoppingTimes | Simulate stopping times for the exact savi logrank test
sampleStoppingTimesSafeT | Simulate stopping times for the savi T-test
sampleStoppingTimesSafeZ | Simulate stopping times for the savi Z-test
sampleStoppingTimesSaviT | Simulate stopping times for the savi T-test
sampleStoppingTimesSaviZ | Simulate stopping times for the savi Z-test
savi.prop.test | Perform a Savi Test for Two Proportions with Stream Data
savi.t.test | Safe Anytime-Valid Student's T-Test.
savi.z.test | Safe Anytime-Valid Z-Test
saviLogrankTest | Safe Anytime-Valid Logrank Test
saviLogrankTestStat | Safe Anytime-Valid Logrank Test
saviRelevanceTStatNEffNu | Computes E-Values Based on the T-Statistic
saviRelevanceZStat | Computes E-Values Based on the Z-Statistic
saviTTest | Safe Anytime-Valid Student's T-Test.
saviTTest.default | Safe Anytime-Valid Student's T-Test.
saviTTest.formula | Safe Anytime-Valid Student's T-Test.
saviTTestStat | Computes E-Values Based on the T-Statistic
saviTTestStatNEffNu | Computes E-Values Based on the T-Statistic
saviTTestStatNEffNuGrow | Computes E-Values Based on the T-Statistic
saviTTestStatNEffNuMom | Computes E-Values Based on the T-Statistic
saviTTestStatTDensity | Computes E-Values Based on the T-Statistic
saviTwoProportionsTest | Perform a Savi Test for Two Proportions with Stream Data
saviZTest | Safe Anytime-Valid Z-Test
saviZTest.default | Safe Anytime-Valid Z-Test
saviZTest.formula | Safe Anytime-Valid Z-Test
saviZTestStat | Computes E-Values Based on the Z-Statistic
selectivelyContinueZOrTTestData | Helper function to demonstrate the selective continuation of paired z-tests
setLowAndHighEsTrueZ | Helper function to determine the lower and upper bound for the search space for standardised meanDiffMin
setSafeStatsPlotOptionsAndReturnOldOnes | Sets 'safestats' Plot Options and Returns the Current Plot Options.
simulateCoverageDifferenceTwoProportions | Simulate the coverage of a savi confidence sequence for differences between proportions for a given distribution and savi design.
simulateIncorrectStoppingTimesFisher | Simulate incorrect optional stopping with fisher's exact test's p-value as the stopping rule.
simulateOptionalStoppingScenarioTwoProportions | Simulate an optional stopping scenario according to a savi design for two proportions
simulateTwoProportions | Compare Different Hyperparameter Settings for Savi Tests of Two Proportions.
subjectiveBfZStat | A subjective Bayes factor for the two-sample Z-test

## -- T --

tryOrFailWithNA | Tries to Evaluate an Expression and Fails with 'NA'
tTestWidthDerivative | Internal function to solve the smallest width of an eGauss t-test

## -- Z --

zMarg | Logarithmic marginal likelihood of the normal with conjugate priors