Pre-data recovery tests for planned study designs: simulate whether a planned design-analysis pair can recover its target estimand, with PASS/RISK/FAIL verdicts under versioned threshold profiles.
Project description
recoverlite (Python)
Pre-data recovery tests for planned study designs — the Python mirror of the R package.
A planned study can be unable to support its intended inferential claim
even when the researcher's substantive assumptions are correct.
recoverlite simulates a declared design–analysis pair over a crossed
scenario grid — null and target effects, each under declared and
pessimistically perturbed nuisance assumptions — and converts the
diagnosands into a PASS / RISK / FAIL verdict under a pre-specified,
versioned threshold profile.
Mirror contract
This package is protocol-identical to the R implementation: same
declaration API, same scenario grid, same diagnosands (including the
exact decomposition target bias = estimator bias + estimand drift),
same threshold profiles (shared version string
recoverlite-thresholds-0.2), same verdict rule, same report structure.
Simulated numbers agree within Monte Carlo error, not byte-identically
— R and Python cannot share RNG streams. The test suite enforces the
contract by reproducing the R package's archived worked-example
diagnosands within 4× combined MCSE.
| R package | Python mirror | |
|---|---|---|
| Two-arm trial (baseline, additive measurement error, MAR/MCAR attrition, noncompliance) | ✅ | ✅ |
| Complete-case linear model | ✅ | ✅ |
| MI baseline-adjusted estimator (Rubin + Barnard-Rubin) | ✅ | ✅ |
| Cluster trial, LMM (Wald-z / Satterthwaite / Kenward–Roger) | ✅ lme4 + lmerTest + pbkrtest | ✅ internal exact REML fitter |
| Cluster-level t-test | ✅ | ✅ |
| Fragility curves (effect + nuisance) | ✅ | ✅ |
The mixed-model machinery is self-contained (numpy/scipy only — no
statsmodels): a closed-form REML fitter for the random-intercept model
with Satterthwaite df (observed REML Hessian, the lmerTest algorithm)
and Kenward–Roger adjusted covariance + df (expected REML information,
the pbkrtest algorithm). Because these methods are deterministic given
data, they are validated against lmerTest/pbkrtest to numerical
precision (rel. ≤ 1e-4) on shared fixture datasets — balanced,
unbalanced, near-boundary, and null — in
tests/data/, a stronger contract than the MCSE-level
simulation cross-checks.
Install
pip install recoverlite # numpy + scipy only
Not yet on PyPI? Install from source:
pip install git+https://github.com/heidihelena/recoverlite-py.
The workflow in one block
import recoverlite as rl
design = rl.declare_recovery(
target=rl.target_estimand(
estimand="ITT mean difference at 12 weeks",
scale="latent-outcome standardized mean difference",
sesoi=0.40,
),
data_strategy=rl.two_arm_trial(n_per_arm=115),
measurement=rl.measured_outcome(reliability=0.70),
missingness=rl.attrition_model(rate=0.15, mechanism="differential"),
answer_strategy=rl.planned_analysis(
estimator="linear_model",
formula="y_observed ~ treatment",
),
)
result = rl.recovery_test(design, sims=2000,
scenarios="confirmatory_grid", seed=1)
print(rl.verdict(result)) # PASS / RISK / FAIL (+ strict/lenient recompute)
rl.report(result) # the standalone report always travels with it
Cluster designs use cluster_trial() with
planned_analysis("lmm_random_intercept", "y_observed ~ treatment + (1 | cluster)")
(Wald-z) or "cluster_mean_ttest". Fragility curves —
effect_fragility(), nuisance_fragility() — are deliberately outside
the verdict.
Citation
Andersen, H. H. (2026). Recovery before data: pre-data simulation diagnosis of planned study designs. Working paper; preprint forthcoming. https://github.com/heidihelena/recoverlite
A PASS is evidence about the instrument, not about the world.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file recoverlite-0.2.0.tar.gz.
File metadata
- Download URL: recoverlite-0.2.0.tar.gz
- Upload date:
- Size: 43.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed4f683df7a78ecef2997a4e542f6b6c87ba206129322379bf7b721caf9a01ce
|
|
| MD5 |
e421e3c214f84d2daf0a984903d37c0f
|
|
| BLAKE2b-256 |
1be0e32bd2ee52c6085479ccc2df80b1716a5942943c3192c6e7e06d97e3307e
|
Provenance
The following attestation bundles were made for recoverlite-0.2.0.tar.gz:
Publisher:
publish.yml on heidihelena/recoverlite-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recoverlite-0.2.0.tar.gz -
Subject digest:
ed4f683df7a78ecef2997a4e542f6b6c87ba206129322379bf7b721caf9a01ce - Sigstore transparency entry: 2082210507
- Sigstore integration time:
-
Permalink:
heidihelena/recoverlite-py@65cd12cd7796f4d4b847cbfdae5e83bf35036c6e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/heidihelena
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@65cd12cd7796f4d4b847cbfdae5e83bf35036c6e -
Trigger Event:
release
-
Statement type:
File details
Details for the file recoverlite-0.2.0-py3-none-any.whl.
File metadata
- Download URL: recoverlite-0.2.0-py3-none-any.whl
- Upload date:
- Size: 40.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7779fe8657692251438d4332d09d889b378df432696b73d001679aa8e082fc08
|
|
| MD5 |
342f1866eaa06989f2c4d06803af991d
|
|
| BLAKE2b-256 |
0c836407c52b2556c306ce8ed0a6607322d65199623d69979c50d59b5041e226
|
Provenance
The following attestation bundles were made for recoverlite-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on heidihelena/recoverlite-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
recoverlite-0.2.0-py3-none-any.whl -
Subject digest:
7779fe8657692251438d4332d09d889b378df432696b73d001679aa8e082fc08 - Sigstore transparency entry: 2082210516
- Sigstore integration time:
-
Permalink:
heidihelena/recoverlite-py@65cd12cd7796f4d4b847cbfdae5e83bf35036c6e -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/heidihelena
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@65cd12cd7796f4d4b847cbfdae5e83bf35036c6e -
Trigger Event:
release
-
Statement type: