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 Ly, A, Boehm, Grunwald, Ramdas and van Ravenzwaaij (2024). "Safe Anytime-Valid Inference: Practical maximally flexible sampling designs for experiments based on e-values" (<doi:10.31234/osf.io/h5vae>) and Grunwald, de Heide and Koolen (2024) "Safe Testing" (<doi:10.1093/jrsssb/qkae011>), for details on safe logrank tests see ter Schure, Perez-Ortiz, Ly and Grunwald (2024) "The Anytime-Valid Logrank Test: Error Control under Continuous Monitoring with Unlimited Horizon" (<doi:10.51387/24-NEJSDS65>), and Turner, Ly and Grunwald (2024) "Generic E-variables for exact sequential k-sample tests that allow for optional stopping" (<doi:10.1016/j.jspi.2023.106116>) for details on safe contingency table tests.

Package details

AuthorAlexander Ly [cre, aut], Rosanne Turner [aut], Yongqi Wang [aut], Muriel Felipe Perez-Ortiz [ctb], Udo Boehm [ctb], Judith ter Schure [ctb], Peter Grunwald [ctb]
MaintainerAlexander Ly <alexander.ly.nl@gmail.com>
LicenseLGPL (>= 3)
Version0.8.8
Package repositoryView on CRAN
Installation Install the latest version of this package by entering the following in R:
install.packages("safestats")

Try the safestats package in your browser

Any scripts or data that you put into this service are public.

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