-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Description
I have 2 (or more) non-normal groups of varying sizes, and so I looked at the Kruskal-Wallis test (when len(groups)>2) and the Mann-Whitney rank test (when len(groups)==2).
I know from the Mann-Whitney rank test docs [1] the the p-value returned is single-sided by default. However, I am unable to find documentation whether the returned p-value in Kruskal-Wallis test is two-sided or not. See docs here [2] and source code [3].
When comparing both tests head to head for len(group)==2, my experiments show that the Kruskal-Wallis p-value may be two-sided, one example here:
from scipy import stats
x = np.arange(1,41,1)
y = np.arange(2,42,2)
print ( stats.kruskal(x, y) )
print ( stats.mannwhitneyu(x, y) )
KruskalResult(statistic=0.02460383653043551, pvalue=0.8753582575468357)
MannwhitneyuResult(statistic=390.0, pvalue=0.4407715705950445)
While I understand they are different tests, the relationship between the p-values (Mann-Whitney p-value * 2 is almost equal to Kruskal-Wallis p-value) is very close and difficult to ignore. Any help would be much appreciated!
[1] https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.mannwhitneyu.html
[2] https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.kruskal.html
[3] https://github.com/scipy/scipy/blob/v1.4.1/scipy/stats/stats.py#L6484-L6601