wrs2-py
A Python port of the R package WRS2, which provides robust statistical methods.
Features
This package currently implements the following methods from WRS2:
- Location Estimators:
trim_mean: Trimmed mean.winmean: Winsorized mean.winvar: Winsorized variance.winval: Winsorized values.winvarN: Rescaled Winsorized variance (for standard normal).pbos: One-step percentage bend measure of location.trimse: Standard error of the trimmed mean.
- Correlation:
wincor: Winsorized correlation.winall: Winsorized correlation/covariance matrix.pbcor: Percentage bend correlation.
- ANOVA (Trimmed Means):
t1way: Heteroscedastic one-way ANOVA.t2way: Two-way ANOVA.rmanova: One-way repeated measures ANOVA.bwtrim: Between-within subjects (split-plot) ANOVA.
- Group Comparison:
yuen: Yuen's test for independent groups.yuenbt: Bootstrap Yuen's test for independent groups.
Implementation Equivalence Validation
The implementation has been comprehensively verified against the original R package using simulation data. The following table summarizes the equivalence tests:
| Feature | Method | Validation Status | Accuracy (Tolerance) |
|---|---|---|---|
| Location | winvar, winmean, winval, winvarN, trim_mean, pbos, trimse |
✅ Passed | $10^{-7}$ |
| Correlation | wincor (correlation, covariance) |
✅ Passed | $10^{-7}$ |
| Correlation | pbcor (correlation, test-stat, p-value) |
✅ Passed | $10^{-7}$ |
| ANOVA | t1way (test-stat, df1, df2, p-value, effsize) |
✅ Passed | $10^{-7}$ (effsize $\pm 0.1$) |
| ANOVA | t2way (Qa, Qb, Qab, p-values) |
✅ Passed | $10^{-7}$ (p-value $\pm 10^{-3}$) |
| ANOVA | rmanova (test-stat, df1, df2, p-value) |
✅ Passed | $10^{-7}$ |
| ANOVA | bwtrim (Qa, Qb, Qab, p-values) |
✅ Passed | $10^{-7}$ (p-value $\pm 10^{-5}$) |
| Comparison | yuen (test-stat, p-value, df, diff, effsize) |
✅ Passed | $10^{-7}$ (effsize $\pm 0.1$) |
| Comparison | yuenbt (test-stat, diff, p-value*) |
✅ Passed | $10^{-7}$ (p-value $\pm 0.05$) |
*Note: Bootstrap results (effsize, yuenbt p-value) may vary slightly due to random sampling, but are statistically consistent with the R implementation.
Installation
pip install .
Usage
import numpy as np
from wrs2_py import t1way, yuen
# Sample data
g1 = np.random.normal(0, 1, 30)
g2 = np.random.normal(0.5, 1, 30)
g3 = np.random.normal(1, 1, 30)
# One-way ANOVA
res_anova = t1way([g1, g2, g3])
print(res_anova)
# Yuen's test
res_yuen = yuen(g1, g2)
print(res_yuen)
References
- Wilcox, R. R. (2017). Introduction to Robust Estimation and Hypothesis Testing. Academic Press.
- Mair, P., & Wilcox, R. (2020). Robust Statistical Methods in R Using the WRS2 Package. Behavior Research Methods.
Metadata
Release files for wrs2-py 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| wrs2_py-0.1.0.tar.gz | 10.6 kB | Without provenance | Details for wrs2_py-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| wrs2_py-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for wrs2_py-0.1.0-py3-none-any.whl |
Total release size: 20.4 kB
Release files / wrs2_py-0.1.0.tar.gz
| Download URL | wrs2_py-0.1.0.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b8fa58978c32d3d638dbade8776ad371f552548e02c0a4d5145bc3bb53988788
|
|
BLAKE2b-256 checksum How to use checksums |
7c2509f788320d3447419472e09bf7ce83996b0b161c30a9e9c3dac5a55740a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Release files / wrs2_py-0.1.0-py3-none-any.whl
| Download URL | wrs2_py-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6410e8286d54bfc9ae01e75ecf0172b49f239f4a0c33060b794c884ca91a809a
|
|
BLAKE2b-256 checksum How to use checksums |
3a75b3eda077d528f015daaa999073b3cf940302fe6f4a428b5c721be7faf8db
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.3
|
Security for wrs2-py 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.