Package: safestats 0.8.7

safestats: Safe Anytime-Valid Inference

Functions to design and apply tests that are anytime valid. The functions can be used to design hypothesis tests in the prospective/randomised control trial setting or in the observational/retrospective setting. The resulting tests remain valid under both optional stopping and optional continuation. The current version includes safe t-tests and safe tests of two proportions. For details on the theory of safe tests, see Grunwald, de Heide and Koolen (2019) "Safe Testing" <arxiv:1906.07801>, for details on safe logrank tests see ter Schure, Perez-Ortiz, Ly and Grunwald (2020) "The Safe Logrank Test: Error Control under Continuous Monitoring with Unlimited Horizon" <arxiv:2011.06931v3> and Turner, Ly and Grunwald (2021) "Safe Tests and Always-Valid Confidence Intervals for contingency tables and beyond" <arxiv:2106.02693> for details on safe contingency table tests.

Authors:Rosanne Turner [aut], Alexander Ly [cre, aut], Muriel Felipe Perez-Ortiz [ctb], Judith ter Schure [ctb], Peter Grunwald [ctb]

safestats_0.8.7.tar.gz
safestats_0.8.7.zip(r-4.5)safestats_0.8.7.zip(r-4.4)safestats_0.8.7.zip(r-4.3)
safestats_0.8.7.tgz(r-4.4-any)safestats_0.8.7.tgz(r-4.3-any)
safestats_0.8.7.tar.gz(r-4.5-noble)safestats_0.8.7.tar.gz(r-4.4-noble)
safestats_0.8.7.tgz(r-4.4-emscripten)safestats_0.8.7.tgz(r-4.3-emscripten)
safestats.pdf |safestats.html
safestats/json (API)
NEWS

# Install 'safestats' in R:
install.packages('safestats', repos = c('https://alexanderlynl.r-universe.dev', 'https://cloud.r-project.org'))

Peer review:

Bug tracker:https://github.com/alexanderlynl/safestats/issues

On CRAN:

evalueshacktoberfestsafe-testingstatistics

53 exports 5 stars 1.26 score 27 dependencies 12 scripts 248 downloads

Last updated 2 years agofrom:67b00855fe. Checks:OK: 7. Indexed: yes.

TargetResultDate
Doc / VignettesOKSep 06 2024
R-4.5-winOKSep 06 2024
R-4.5-linuxOKSep 06 2024
R-4.4-winOKSep 06 2024
R-4.4-macOKSep 06 2024
R-4.3-winOKSep 06 2024
R-4.3-macOKSep 06 2024

Exports:checkDoubleArgumentsDesignObjectcomputeBetaSafeTcomputeBetaSafeZcomputeBootObjcomputeConfidenceBoundForLogOddsTwoProportionscomputeConfidenceBoundsForDifferenceTwoProportionscomputeConfidenceIntervalTcomputeConfidenceIntervalZcomputeLogrankBetaFromcomputeLogrankNEventscomputeLogrankZcomputeNPlanSafeTcomputeNPlanSafeZcomputeStatsForLogrankdesignFreqTdesignFreqZdesignPilotSafeTdesignPilotSafeZdesignSafeLogrankdesignSafeTdesignSafeTwoProportionsdesignSafeZgenerateNormalDatagenerateSurvDataisTryErrorlogrankSingleEExactlogrankSingleZplotConfidenceSequenceTwoProportionsplotHistogramDistributionStoppingTimesplotSafeTDesignSampleSizeProfilereplicateTTestsreturnOnerLogranksafe.prop.testsafe.t.testsafe.z.testsafeLogrankTestsafeLogrankTestStatsafeTTestsafeTTestStatsafeTwoProportionsTestsafeZ10InversesafeZTestsafeZTestStatsampleLogrankStoppingTimessampleStoppingTimesSafeTsampleStoppingTimesSafeZselectivelyContinueTTestCombineDatasetSafeStatsPlotOptionsAndReturnOldOnessimulateCoverageDifferenceTwoProportionssimulateIncorrectStoppingTimesFishersimulateOptionalStoppingScenarioTwoProportionssimulateTwoProportions

Dependencies:BiasedUrnbootclicontfracdeSolvedplyrellipticfansigenericsgluehypergeolatticelifecyclemagrittrMASSMatrixpillarpkgconfigpurrrR6rlangsurvivaltibbletidyselectutf8vctrswithr

Safe Tests and Confidence Intervals for Tests of Two Proportions: Practical Scenarios

Rendered fromcontingency-tables-vignette.Rmdusingknitr::rmarkdownon Sep 06 2024.

Last update: 2022-11-23
Started: 2022-01-06

Safe Flexible Hypothesis Tests for Practical Scenarios

Rendered fromsafestats-vignette.Rmdusingknitr::rmarkdownon Sep 06 2024.

Last update: 2022-11-23
Started: 2020-02-07

Readme and manuals

Help Manual

Help pageTopics
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 thecheckAndReturnsEsMinParameterSide
Check consistency between nPlan and the testType for one and two-sample z and t-testscheckAndReturnsNPlan
Helper function to check whether arguments are specified in a function at a higher level and already provided in the design object.checkDoubleArgumentsDesignObject
Helper function: Computes the type II error based on the minimal clinically relevant effect size and sample size.computeBetaBatchSafeZ
Helper function: Computes the type II error of the safeTTest based on the minimal clinically relevant standardised mean difference and nPlan.computeBetaSafeT
Helper function: Computes the type II error based on the minimal clinically relevant mean difference and nPlancomputeBetaSafeZ
Computes the bootObj for sequential sampling procedures regarding nPlan, beta, the implied targetcomputeBootObj
Estimate an upper or lower bound for a safe confidence sequence on the logarithm of the odds ratio for two proportions.computeConfidenceBoundForLogOddsTwoProportions
Estimate Lower and Upper Bounds on the Confidence Sequence (Interval) for the Difference Divergence Measure for Two ProportionscomputeConfidenceBoundsForDifferenceTwoProportions
Helper function: Computes the safe confidence sequence for the mean in a t-testcomputeConfidenceIntervalT
Helper function: Computes the safe confidence sequence for a z-testcomputeConfidenceIntervalZ
Helper function: Computes the minimal clinically relevant standardised mean difference for the safe t-test nPlan and beta.computeEsMinSafeT
Helper function: Computes the type II error under optional stopping based on the minimal clinically relevant hazard ratio and the maximum number of nEvents.computeLogrankBetaFrom
Helper function: Computes the planned sample size based on the minimal clinical relevant hazard ratio, alpha and beta under optional stopping.computeLogrankNEvents
Helper function to computes the logrank statistic for 'Surv' objects of type "right" and "counting" with the hypergeometric variance.computeLogrankZ
Computes the smallest mean difference that is detectable with chance 1-beta, for the provided sample sizecomputeMinEsBatchSafeZ
Help function to compute the effective sample size based on a length 2 vector of samplescomputeNEff
Helper function: Computes the planned sample size for the safe t-test based on the minimal clinically relevant standardised effect size, alpha and beta.computeNPlanBatchSafeT
Helper function: Computes the planned sample size based on the minimal clinical relevant mean difference, alpha and beta.computeNPlanBatchSafeZ
Helper function: Computes the planned sample size of the safe t-test based on the minimal clinical relevant standardised mean difference.computeNPlanSafeT
Helper function: Computes the planned sample size based on the minimal clinical relevant mean difference, alpha and betacomputeNPlanSafeZ
Computes the sufficient statistics needed to compute 'logrankSingleZ'computeStatsForLogrank
Computes a Sequence of (Effective) Sample SizesdefineTTestN
Design a Frequentist T-TestdesignFreqT
Design a Frequentist Z-TestdesignFreqZ
Designs a Safe T-Test Based on Planned Samples nPlandesignPilotSafeT
Designs a Safe Z-Test Based on Planned Samples nPlandesignPilotSafeZ
Designs a Safe Logrank Test ExperimentdesignSafeLogrank
Designs a Safe Experiment to Test Means with a T TestdesignSafeT
Designs a Safe Experiment to Test Two Proportions in Stream DatadesignSafeTwoProportions
Designs a Safe Z ExperimentdesignSafeZ
Helper function: Get all names as entered by the userextractNameFromArgs
Generates Normally Distributed Data Depending on the DesigngenerateNormalData
Generate Survival Data which Can Be Analysed With the `survival` PackagegenerateSurvData
Helper function: Get all arguments as entered by the usergetArgs
Gets the Label of the Alternative HypothesisgetNameAlternative
Gets the Label of the TestgetNameTestType
Checks Whether a Vector of Object Inherits from the Class 'try-error'isTryError
Helper function computes single component of the exact logrank e-valuelogrankSingleEExact
Helper function computes single component of the logrank statisticlogrankSingleZ
Plots Results of Simulations for Comparing Hyperparameters for Safe Tests of Two Proportionsplot.safe2x2Sim
Plots a 'safeTSim' Objectplot.safeTSim
Plot bounds of a safe 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.plotConfidenceSequenceTwoProportions
Plots the Histogram of Stopping TimesplotHistogramDistributionStoppingTimes
Plots the Sample Sizes Necessary for a Tolerable Alpha and Beta as a Function of deltaMinplotSafeTDesignSampleSizeProfile
Prints Results of Simulations for Comparing Hyperparameters for Safe Tests of Two Proportionsprint.safe2x2Sim
Print Method for Safe Testsprint.safeDesign
Print Method for Safe Testsprint.safeTest
Prints a safeTSim Objectprint.safeTSim
Simulate Early Stopping ExperimentsreplicateTTests
Auxiliary function for sampling of the logrank simulations to return the integer 1 event per time.returnOne
Randomly samples from a logrank distributionrLogrank
Safe Logrank TestsafeLogrankTest safeLogrankTestStat
Safe Student's T-Test.safe.t.test safeTTest
Computes E-Values Based on the T-StatisticsafeTTestStat
safeTTestStat() Subtracted with 1/alpha.safeTTestStatAlpha
safeTTestStat() based on t-densitiessafeTTestStatTDensity
Perform a Safe Test for Two Proportions with Stream Datasafe.prop.test safeTwoProportionsTest
Computes the Inverse of the Two-Sided Safe Z-TestsafeZ10Inverse
Safe Z-Testsafe.z.test safeZTest
Computes E-Values Based on the Z-StatisticsafeZTestStat
Simulate stopping times for the exact safe logrank testsampleLogrankStoppingTimes
Simulate stopping times for the safe z-testsampleStoppingTimesSafeT
Simulate stopping times for the safe z-testsampleStoppingTimesSafeZ
Selectively Continue Experiments that Did Not Lead to a Null Rejection for a (Safe) T-TestselectivelyContinueTTestCombineData
Sets 'safestats' Plot Options and Returns the Current Plot Options.setSafeStatsPlotOptionsAndReturnOldOnes
Simulate Early Stopping Experiments for the T Testsimulate.safeDesign
Simulate the coverage of a safe confidence sequence for differences between proportions for a given distribution and safe design.simulateCoverageDifferenceTwoProportions
Simulate incorrect optional stopping with fisher's exact test's p-value as the stopping rule.simulateIncorrectStoppingTimesFisher
Simulate an optional stopping scenario according to a safe design for two proportionssimulateOptionalStoppingScenarioTwoProportions
Compare Different Hyperparameter Settings for Safe Tests of Two Proportions.simulateTwoProportions
Tries to Evaluate an Expression and Fails with 'NA'tryOrFailWithNA