Skip to main content

A Python port of the WRS2 R package for robust statistical methods.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wrs2_py-0.1.0.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wrs2_py-0.1.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file wrs2_py-0.1.0.tar.gz.

File metadata

  • Download URL: wrs2_py-0.1.0.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wrs2_py-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b8fa58978c32d3d638dbade8776ad371f552548e02c0a4d5145bc3bb53988788
MD5 35658167eac3e8e5c9fa601256d6c718
BLAKE2b-256 7c2509f788320d3447419472e09bf7ce83996b0b161c30a9e9c3dac5a55740a4

See more details on using hashes here.

File details

Details for the file wrs2_py-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wrs2_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for wrs2_py-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6410e8286d54bfc9ae01e75ecf0172b49f239f4a0c33060b794c884ca91a809a
MD5 14e971888685202fd01d1964647685a2
BLAKE2b-256 3a75b3eda077d528f015daaa999073b3cf940302fe6f4a428b5c721be7faf8db

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page