Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python wilcoxon: unequal N

Rs wilcox.test can take different length vectors, but the wilcoxon from scipy.stats cannot: I get an unequal N error message.

from scipy.stats import wilcoxon
wilcoxon(range(10), range(12))

Is there a way to get Rs behavior in Python?

like image 990
The Unfun Cat Avatar asked Nov 24 '15 09:11

The Unfun Cat


People also ask

Does Wilcoxon assume normality?

Unlike the t-test, the Wilcoxon test doesn't assume normality, which is nice. In fact, they don't make any assumptions about what kind of distribution is involved: in statistical jargon, this makes them nonparametric tests.

Is Wilcoxon normally distributed?

Since the Wilcoxon test is a nonparametric test, the data need not be normally distributed. However, to calculate a Wilcoxon test, the samples must be dependent. Dependent samples are present, for example, when data is obtained from repeated measurements or when so-called natural pairs are involved.

What is the difference between Wilcoxon and Mann Whitney?

The main difference is that the Mann-Whitney U-test tests two independent samples, whereas the Wilcox sign test tests two dependent samples. The Wilcoxon Sign test is a test of dependency. All dependence tests assume that the variables in the analysis can be split into independent and dependent variables.

What does the Z value mean in Wilcoxon test?

The rank mean of one group is compared to the overall rank mean to determine a test statistic called a z-score. If the groups are evenly distributed, then the z-score will be closer to 0. In this case, the z-score is 3.81, which is equal to a p-value < 0.001.


1 Answers

According to the R docs:

Performs one- and two-sample Wilcoxon tests on vectors of data; the latter is also known as ‘Mann-Whitney’ test.

So just use

from scipy.stats import mannwhitneyu
mannwhitneyu(range(10), range(12))
# (50.0, 0.26494055917435472)
like image 199
The Unfun Cat Avatar answered Sep 19 '22 18:09

The Unfun Cat