ritest
Overview
ritest provides fast randomization inference (RI) tools for linear models and arbitrary statistics. It supports weights (WLS) as well as stratified and clustered designs.
📑 Documentation: https://tabarecapitan.com/projects/ritest.
Features
- Linear-model RI with efficient computation.
- Generic RI for arbitrary scalar statistics via
stat_fn. - Stratified, clustered, and stratified-clustered designs.
- Weighted least squares (WLS) support.
- Deterministic seeding, reproducible permutations.
- Configurable p-value and ultra-fast coefficient bounds and bands.
Installation
From PyPI:
pip install ritest-python
Optional extras:
pip install ritest-python[plot] # plotting support
pip install ritest-python[numba] # Numba acceleration
Quickstart
Linear model (formula interface)
import pandas as pd
from ritest import ritest
df = pd.DataFrame({
"y": [1, 2, 3, 4],
"treat": [0, 1, 0, 1],
"x": [5, 6, 7, 8],
})
res = ritest(
df=df,
permute_var="treat",
formula="y ~ treat + x",
stat="treat",
reps=1000,
)
print(res.summary())
Custom statistic (stat_fn)
def my_stat(df):
return df["y"].corr(df["treat"])
res = ritest(
df=df,
permute_var="treat",
stat_fn=my_stat,
reps=1000,
)
print(res.pvalue)
Citation
A software citation entry will be provided once the package reaches its first stable release and the accompanying paper/notes are finalized. For now, cite the GitHub repository:
Tabaré Capitán (2025). ritest: Randomization inference in Python.
https://github.com/tabareCapitan/ritest
Disclaimer
Use this software at your own risk. I make no guarantees of correctness or fitness for any purpose. I use it in my own work, but you should review the code to ensure it meets your needs. If you find an issue, please report it.
Contributing and issues
Bug reports and feature requests can be filed at:
https://github.com/tabareCapitan/ritest/issues
Pull requests should be focused and include tests for new behavior.
License
MIT License.
See the LICENSE file for full terms.
Metadata
Release files for ritest-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ritest_python-0.1.1.tar.gz | 54.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ritest_python-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 88.9 kB
Release files / ritest_python-0.1.1.tar.gz
| Download URL | ritest_python-0.1.1.tar.gz |
|---|---|
| Size | 54.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a32695bbc6ce29be75b34f171649241beeba7fb3dd5eecc8e6fbda44936bf43d
|
|
BLAKE2b-256 checksum How to use checksums |
4c706b7a703c60c5ac24ff4415684e3a87cf2c6472e257e03ca181910152cb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / ritest_python-0.1.1-py3-none-any.whl
| Download URL | ritest_python-0.1.1-py3-none-any.whl |
|---|---|
| Size | 34.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f4d667bb7099e15a67894f578d40a05ff0e57c33ee799c7fce043f02ec331c1
|
|
BLAKE2b-256 checksum How to use checksums |
870ce9b4ac709b81770d14643db41007dcc138d5d99083bf83bce94bcaa704e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|