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
another followup to PR #6971 which adds brunner munzel and extensions for P(x1 > x2) + 0.5 P(x1 = x2) for the two sample case.
see also #6523 for more general cases of using rank transform.
meta-analysis and stratified case
The two sample case should extend immediately to the meta-analysis and stratified case. I guess we can just use the functions in meta-analysis directly with the results for prob as effect size measure, var or std is available for it.
oneway anova
we can use ranks directly with Welch anova, (not rank transformation can introduce heteroscedasticity even if underlying random variables are homoscedastic.
compute p_i for comparison of distribution of x_i against the distribution with all samples combined. This avoids problems with transitivity (Condorcet cycles), but has interpretation problems if sample sizes are very unequal, e.g. one sample dominates the combined sample.
pairwise comparison (I haven't looked at details yet)
using only information from the pairs might create cycles again
can we directly use p_i from F_i versus combined distribution
main problem is that using ranks in joined or combined sample introduces correlation, i.e. R_i and R_j are not independent even if x_i and x_j are
reference in german
Brunner, Edgar, and Ullrich Munzel. 2013. Nichtparametrische Datenanalyse: unverbundene Stichproben. 2., überarb. Aufl. Statistik und ihre Anwendungen. Berlin: Springer Spektrum.
I read several section, book has a good combination of basic explanations and defintions and the technical parts and proofs, for when we need the latter.
For multisample variance we need placements, i.e. rank of on sample in another, possibly combined, sample.
scipy rankdata does not do that directly.
In two sample case, we can get placements from combined rank minus internal rank
I haven't tried yet whether this also works or if we need searchsorted.
robustness to heteroscedasticity, distributional assumption of rank based comparisons
Brunner-Munzel analogue
not robust:
Hollander, Wolf, Chicken book:
comment p. 221, and
p. 223 comment 21. for Jonckheere–Terpstra trend test, and
p. 238 comment 28, for Mack–Wolfe test against umbrella alternatives
p. 254 comment 50 for The Treatments-versus-Control
and so on (text search for behrens)
old traditional version corresponds to kruskall wallis (?) Mann–Whitney Wilcoxon assumes identical distributions across samples,
adjustment for heteroscedasticity: fligner version of MW
this is similar to background of brunner-munzel test.
That is, we want the one-way and multiple comparison version of brunner-munzel, not MW or Fligner-Pollicelli
some references found by searching brunner + ...
Brunner, Edgar, Frank Konietschke, Markus Pauly, and Madan L. Puri. 2017. “Rank-Based Procedures in Factorial Designs: Hypotheses about Non-Parametric Treatment Effects.” Journal of the Royal Statistical Society. Series B (Statistical Methodology) 79 (5): 1463–85.
Boos, Duan 2021 p. 416 comment 8 briefly mention this literature, but then ignore it.
AFAICS, the simulations in boos and duan use distributions in the k samples that differ only in some location parameter, otherwise identical including the same variance.
The theoretical part does not say much about distributional assumptions, i.e. I think they have the same problem as MW.
brunner munzel
H0: no stochastic dominance (as defined by midrank)
MW:
F(x1) = F(x2) = ... (identical distributions)
for MW:
If test rejects => evidence that distributions are different (specifically in the direction of stochastic dominance).
If test does not reject, with large enough sample size => evidence that distributions are not different in sense of brunner-munzel MW statistic, i.e. no stochastic dominance. However, test does not reject if there is no stochastic dominance and distributions differ. (I think normal distribution with common mean but different variances fall in this category).
i.e. MW type tests are not consistent for the equal distribution null hypothesis (no power in some directions).
Asymptotically we don't have if and only if, but we get the "correct" answer when we reject.
However,
The asymptotic distribution of the WMW and similar statistics are derived under the identical distribution Null F(x1) = F(x2) = ...
BM pvalue does not assume identical distributions, only that p1 = p2 = ...
def rank_pseudo(x_li):
"""pseudo-ranks from datalist
Parameters
----------
x_li : list
list of 1-d data
Returns
-------
rp : ndarray
Pseudo ranks of concatenated samples.
f : ndarray
Averaged empirical distribution at data points
f_all : ndarray
Placements of all data in each sample.
"""
x = np.concatenate(x_li)
nobsi = [len(xi) for xi in x_li]
nobs = sum(nobsi)
k = len(x_li)
f = 0
f_all = []
for i in range(len(x_li)):
xi = np.sort(x_li[i], kind="mergesort")
fi = (np.searchsorted(xi, x, side='left') + np.searchsorted(xi, x, side='right')) / 2
f = f + fi / nobsi[i]
f_all.append(fi)
f = f / k
rankq = 0.5 + nobs * f
return rankq, f, f_all
from numpy.testing import assert_allclose
def test_pseudo_rank():
# example from p. 60 table 2.10
x_li = [[4.2, 3.7, 1.8], [2.6, 1.8, 3.5, 4.1], [1.8, 4.2]]
rp = np.array([8.25 , 5.75 , 2.125, 4.125, 2.125, 4.875, 6.625, 2.125, 8.25 ])
# check only pseudo-rank, not auxiliary returns
r = rank_pseudo(x_li)[0]
assert_allclose(r, rp, rtol=1e-14)
test_pseudo_rank()
ranks: weight by sample sizes
pseudo-ranks :weight sample distributions uniformly
Instead we could use other weights (easy to add option in current implementation of quasi-ranks) if we have reference or population weights, e.g. if samples are stratified by observable population characteristic.
Ranks would weight correctly for this if sample sizes are determined by (purely) random draws from the population.
i.e. similar to survey weights or weights in prediction, we could use "exogenous" prior weights.
article listed above
Brunner, Edgar, Frank Konietschke, Markus Pauly, and Madan L. Puri. 2017. “Rank-Based Procedures in Factorial Designs: Hypotheses about Non-Parametric Treatment Effects.” Journal of the Royal Statistical Society. Series B (Statistical Methodology) 79 (5): 1463–85.
Has complicated cov for Behrens-Fisher, unequal distribution robust (similar to brunner-munzel for two sample case)
Their book only has asymptotics under equal distribution assumption (as in KW null) with ranks and with quasi-ranks.
related but simpler cov is for brunner-munzel type pairwise comparisons (need cov between all pairs)
Activity
josef-pkt commentedon Aug 25, 2020
For multisample variance we need placements, i.e. rank of on sample in another, possibly combined, sample.
scipy rankdata does not do that directly.
In two sample case, we can get placements from combined rank minus internal rank
I haven't tried yet whether this also works or if we need searchsorted.
josef-pkt commentedon May 16, 2022
recent article (I didn't look at it, besides abstract)
Boos, Dennis D., and Siyu Duan. 2021. “Pairwise Comparisons Using Ranks in the One-Way Model.” The American Statistician 75 (4): 414–23. https://doi.org/10.1080/00031305.2020.1860819.
kruskal nemenyi discussion around
#852 (comment)
josef-pkt commentedon Aug 22, 2022
robustness to heteroscedasticity, distributional assumption of rank based comparisons
Brunner-Munzel analogue
not robust:
Hollander, Wolf, Chicken book:
comment p. 221, and
p. 223 comment 21. for Jonckheere–Terpstra trend test, and
p. 238 comment 28, for Mack–Wolfe test against umbrella alternatives
p. 254 comment 50 for The Treatments-versus-Control
and so on (text search for behrens)
old traditional version corresponds to
kruskall wallis(?) Mann–Whitney Wilcoxon assumes identical distributions across samples,adjustment for heteroscedasticity: fligner version of MW
this is similar to background of brunner-munzel test.
That is, we want the one-way and multiple comparison version of brunner-munzel, not MW or Fligner-Pollicelli
some references found by searching brunner + ...
Brunner, Edgar, Frank Konietschke, Markus Pauly, and Madan L. Puri. 2017. “Rank-Based Procedures in Factorial Designs: Hypotheses about Non-Parametric Treatment Effects.” Journal of the Royal Statistical Society. Series B (Statistical Methodology) 79 (5): 1463–85.
Brunner, Edgar, and Madan L. Puri. 2001. “Nonparametric Methods in Factorial Designs.” Statistical Papers 42 (1): 1–52. https://doi.org/10.1007/s003620000039.
Konietschke, Frank, Ludwig A. Hothorn, and Edgar Brunner. 2012. “Rank-Based Multiple Test Procedures and Simultaneous Confidence Intervals.” Electronic Journal of Statistics 6 (none): 738–59. https://doi.org/10.1214/12-EJS691.
Boos, Duan 2021 p. 416 comment 8 briefly mention this literature, but then ignore it.
AFAICS, the simulations in boos and duan use distributions in the k samples that differ only in some location parameter, otherwise identical including the same variance.
The theoretical part does not say much about distributional assumptions, i.e. I think they have the same problem as MW.
(note I don't remember spelling of author names)
josef-pkt commentedon Aug 22, 2022
Note on null hypothesis for rank comparison
brunner munzel
H0: no stochastic dominance (as defined by midrank)
MW:
F(x1) = F(x2) = ... (identical distributions)
for MW:
If test rejects => evidence that distributions are different (specifically in the direction of stochastic dominance).
If test does not reject, with large enough sample size => evidence that distributions are not different in sense of brunner-munzel MW statistic, i.e. no stochastic dominance. However, test does not reject if there is no stochastic dominance and distributions differ. (I think normal distribution with common mean but different variances fall in this category).
i.e. MW type tests are not consistent for the equal distribution null hypothesis (no power in some directions).
Asymptotically we don't have
if and only if, but we get the "correct" answer when we reject.However,
The asymptotic distribution of the WMW and similar statistics are derived under the identical distribution Null F(x1) = F(x2) = ...
BM pvalue does not assume identical distributions, only that p1 = p2 = ...
josef-pkt commentedon Aug 31, 2022
pseudo rank based on book Rank and Pseudo-Rank ...
Brunner, Edgar, Arne C. Bathke, and Frank Konietschke. 2018. Rank and Pseudo-Rank Procedures for Independent Observations in Factorial Designs: Using R and SAS. Springer Series in Statistics. Cham: Springer International Publishing. https://doi.org/10.1007/978-3-030-02914-2.
They have also R package https://cran.r-project.org/web/packages/rankFD/index.html
They also use some functions of R packages nparcomp and coin
draft for function
josef-pkt commentedon Sep 2, 2022
another note to pseudo-ranks or weighted ranks, population distribution
Zimmermann, Georg, Edgar Brunner, Werner Brannath, Martin Happ, and Arne C. Bathke. 2022. “Pseudo-Ranks: The Better Way of Ranking?” The American Statistician 76 (2): 124–30. https://doi.org/10.1080/00031305.2021.1972836.
section 3.2. The Appropriate Reference Distribution
ranks: weight by sample sizes
pseudo-ranks :weight sample distributions uniformly
Instead we could use other weights (easy to add option in current implementation of quasi-ranks) if we have reference or population weights, e.g. if samples are stratified by observable population characteristic.
Ranks would weight correctly for this if sample sizes are determined by (purely) random draws from the population.
i.e. similar to survey weights or weights in prediction, we could use "exogenous" prior weights.
josef-pkt commentedon Sep 8, 2022
asymptotic cov of relative effects
article listed above
Brunner, Edgar, Frank Konietschke, Markus Pauly, and Madan L. Puri. 2017. “Rank-Based Procedures in Factorial Designs: Hypotheses about Non-Parametric Treatment Effects.” Journal of the Royal Statistical Society. Series B (Statistical Methodology) 79 (5): 1463–85.
Has complicated cov for Behrens-Fisher, unequal distribution robust (similar to brunner-munzel for two sample case)
Their book only has asymptotics under equal distribution assumption (as in KW null) with ranks and with quasi-ranks.
related but simpler cov is for brunner-munzel type pairwise comparisons (need cov between all pairs)
Munzel, Ullrich, and Ludwig A. Hothorn. 2001. “A Unified Approach to Simultaneous Rank Test Procedures in the Unbalanced One-Way Layout.” Biometrical Journal 43 (5): 553–69.
https://doi.org/10.1002/1521-4036(200109)43:5<553::AID-BIMJ553>3.0.CO;2-N.
also related: includes cov for linear combinations (contrasts) or "relative effects" (I didn't check what article covers)
Konietschke, Frank, Ludwig A. Hothorn, and Edgar Brunner. 2012. “Rank-Based Multiple Test Procedures and Simultaneous Confidence Intervals.” Electronic Journal of Statistics 6: 738–59. https://doi.org/10.1214/12-EJS691.
josef-pkt commentedon Jan 29, 2025
to get started
use rank transformation on full data plus Welch or other unequal var anova