You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: stats based on (fixed percent) trimmed samples #6459
trimming obsevations like 20% on both tails makes t-test and similar more robust to outliers and to some extend to non-normality of distributions.
popularized (mainly in Psychology) by Randy Wilcox, articles and text book
scipy has some functions for it
Yuen's t-test ttest_trimmed open PR scipy/scipy#9678
Brown-Forsythe trimmed anova for equality of variances/dispersion
I found an old script #866 (comment)
it also includes a one-sample class, similar to the one in weightstats
class TrimmedMean(object):
'''class for trimmed and winsorized one sample statistics'''
For k-sample comparison, the version would be a yuen anova or yuen-welsh anova
They argue against using trimming, Yuen-Welsh, or endog transformation like log or Box-Cox when data is heteroscedastic and skewed, in favor of GLM. #2791 for what we can do if we log transform, but I don't see a FAQ issue with the econ literature on using GLM/Poisson instead of log-transforming endog, partially in #4276
anova, Welch, Yuen, Yuen- Welch anova for mean and their counterparts for variance/dispersion like Levene, Brown-Forsythe, share the same underlying anova computation, equivalent to a model like OLS or GLM with one categorical exog.
inference, distribution for test statistics might differ, if we don't want just generic asymptotic chisquare.
related: rank based methods.
Without ties using rank transformed data in generic anova or t-test should be equivalent to their nonparametric counterparts.
I'm not sure about tie handling in the generic case.
I think I remember why I gave up in 2013 scipy.stats.levene includes the dispersion version, including median and trimmed mean as center, and allows for k-sample comparison.
Brown-Forsythe is just levene with mean replaced by median,
center : {‘mean’, ‘median’, ‘trimmed’}, optional
Which function of the data to use in the test. The default is ‘median’.
proportiontocut : float, optional
When center is ‘trimmed’, this gives the proportion of data points to cut from each end. (See scipy.stats.trim_mean.) Default is 0.05.
I guess I will resurrect this so we can also add equivalence tests #6444 both for mean comparisons and for variance comparisons, and possibly for adding effect size measures and more power/sample size functions.
One possibility is to add anova style methods to a stats\_oneway.py (or not private) that could include one-way anova style methods for both mean and variances together.
Related module would be multicomp for the pairwise multiple comparisons, and k-sample tests by type of variable, continuous, proportion, rates/count.
Activity
josef-pkt commentedon Jan 22, 2020
and "Don't log-transform - use GLM" for psychologists
Ng, Victoria K. Y., and Robert A. Cribbie. 2019. “The Gamma Generalized Linear Model, Log Transformation, and the Robust Yuen-Welch Test for Analyzing Group Means with Skewed and Heteroscedastic Data.” Communications in Statistics - Simulation and Computation 48 (8): 2269–86. https://doi.org/10.1080/03610918.2018.1440301.
They argue against using trimming, Yuen-Welsh, or endog transformation like log or Box-Cox when data is heteroscedastic and skewed, in favor of GLM.
#2791 for what we can do if we log transform, but I don't see a FAQ issue with the econ literature on using GLM/Poisson instead of log-transforming endog, partially in #4276
josef-pkt commentedon Jan 22, 2020
one point for implementation
anova, Welch, Yuen, Yuen- Welch anova for mean and their counterparts for variance/dispersion like Levene, Brown-Forsythe, share the same underlying anova computation, equivalent to a model like OLS or GLM with one categorical exog.
inference, distribution for test statistics might differ, if we don't want just generic asymptotic chisquare.
josef-pkt commentedon Jan 22, 2020
related: rank based methods.
Without ties using rank transformed data in generic anova or t-test should be equivalent to their nonparametric counterparts.
I'm not sure about tie handling in the generic case.
Where do we put these functions and what API?
josef-pkt commentedon Jan 22, 2020
pushed my 2013 branch, not rebased and updated yet
master...josef-pkt:stats_robust
josef-pkt commentedon Jan 22, 2020
I think I remember why I gave up in 2013
scipy.stats.leveneincludes the dispersion version, including median and trimmed mean as center, and allows for k-sample comparison.Brown-Forsythe is just levene with mean replaced by median,
josef-pkt commentedon Feb 14, 2020
I guess I will resurrect this so we can also add equivalence tests #6444 both for mean comparisons and for variance comparisons, and possibly for adding effect size measures and more power/sample size functions.
One possibility is to add anova style methods to a
stats\_oneway.py(or not private) that could include one-way anova style methods for both mean and variances together.Related module would be
multicompfor the pairwise multiple comparisons, and k-sample tests by type of variable, continuous, proportion, rates/count.josef-pkt commentedon Feb 18, 2020
scipy.stats and statsmodels don't have Welch Anova (at least I don't find them searching for "Welch")
josef-pkt commentedon Feb 26, 2020
another one
https://www.rdocumentation.org/packages/equivalence/versions/0.7.2/topics/rtost
TOST two sample t-test based on trimmed sample, ie yuen t-tost or tostt
(I don't have two sample tests in #6526 yet)