Skip to main content

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)

Source distribution for wrs2-py 0.1.0
File Size Uploaded
wrs2_py-0.1.0.tar.gz 10.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for wrs2-py 0.1.0
File Interpreter ABI Platform
wrs2_py-0.1.0-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page