Code covered by the BSD License  

Highlights from
Mann-Whitney-Wilcoxon test

5.0

5.0 | 1 rating Rate this file 25 Downloads (last 30 days) File Size: 3.05 KB File ID: #25830

Mann-Whitney-Wilcoxon test

by Giuseppe Cardillo

 

13 Nov 2009 (Updated 23 Dec 2009)

Mann-Whitney-Wilcoxon non parametric test for two unpaired groups.

| Watch this File

File Information
Description

This file executes the non parametric Mann-Whitney-Wilcoxon test to evaluate the difference between unpaired samples. If the number of combinations is less than 20000, the algorithm calculate the exact ranks distribution; else it uses a normal distribution approximation. The result is not different from
RANKSUM MatLab function, but there are more output informations. There is an alternative formulation of this test that yields a statistic commonly denoted by U. Also the U statistic is computed.

Syntax: STATS=MWWTEST(X1,X2)

Inputs:
X1 and X2 - data vectors.
Outputs:
- T and U values and p-value when exact ranks distribution is used.
- T and U values, mean, standard deviation, Z value, and p-value when normal distribution is used.
If STATS nargout was specified the results will be stored in the STATS struct.

Example:

X1=[181 183 170 173 174 179 172 175 178 176 158 179 180 172 177];

X2=[168 165 163 175 176 166 163 174 175 173 179 180 176 167 176];

Calling on Matlab the function: mwwtest(X1,X2)

Answer is:

MANN-WHITNEY-WILCOXON TEST
--------------------------------------------------------------------------------
Sample size is good enough to use the normal distribution approximation

T U mT sT zT p-value (1-tailed)
--------------------------------------------------------------------------------
270.0000 150.0000 232.5000 24.1071 1.5348 0.0624
--------------------------------------------------------------------------------

You can visit my homepage http://home.tele2.it/cardillo
My profile on XING http://www.xing.com/go/invita/13675097
My profile on LinkedIN http://it.linkedin.com/in/giuseppecardillo

Required Products Statistics Toolbox
MATLAB release MATLAB 7.6 (R2008a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (3)
19 Mar 2010 Arsen Arakelyan

Thanks, very nice

13 Apr 2011 nuntinee

i'm trying to use your suggested matlab code; mwwtest(x1,x2). But my 2010a matlab version doesn't recognize this code. How is this possible? or is it possible that mwwtest code was deleted since the result is equivalent to ranksum(x1,x2) code?

If that is the case, can i replace mwwtest with ranksum? What is the difference between Mann-whitney u test and wilcoxon ranksum test? My advisor is convinced that Mann-whitney tests the difference btw mean while ranksum tests difference of median or distribution rank.

My final question is if i change to perform ranksum code instead of your suggested mwwtest, ranksum doesn't support 1-tailed test. Is this true? How can I test 1-tailed of ranksum or mwwtest in matlab. I see there are possible way to test 1-tailed in ALGLIB (http://www.alglib.net/hypothesistesting/mannwhitneyu.php).

thank you so much in advance for your reply.

nuntinee

14 Apr 2011 Giuseppe Cardillo

A) i'm trying to use your suggested matlab code; mwwtest(x1,x2). But my 2010a matlab version doesn't recognize this code. How is this possible?
R) I use the same version of MatLab (even if I use the Linux version) and mwwtest properly works. Please, check if your data are correct (see help).

A) Or is it possible that mwwtest code was deleted since the result is equivalent to ranksum(x1,x2) code?
B) If you are writing this comment, it means that mwwtest wasn't deleted. A question: did you download mwwtest from this page before using it?

A) If that is the case, can i replace mwwtest with ranksum?
R) You can use ranksum because, as I wrote in Description, the results are the same.

A)What is the difference between Mann-whitney u test and wilcoxon ranksum test?
R) There is no difference: they are two sides of the same coin. Infact, mwwtest compute both T and U.

A) My advisor is convinced that Mann-whitney tests the difference btw mean while ranksum tests difference of median or distribution rank.
R) Your advisor is wrong. Non parametric tests test differences between medians while parametric tests between means.

A)My final question is if i change to perform ranksum code instead of your suggested mwwtest, ranksum doesn't support 1-tailed test. Is this true? How can I test 1-tailed of ranksum or mwwtest in matlab.
R)Ranksum gives you a 2-tailed p. If you want 1-tailed p simply divide 2-tailed p by 2.

Please login to add a comment or rating.
Updates
16 Nov 2009

change in the help section

25 Nov 2009

bug fixed in T computation when n2<n1

23 Dec 2009

Changes in description

Tag Activity for this File
Tag Applied By Date/Time
statistics Giuseppe Cardillo 13 Nov 2009 12:15:35
non parametric test Giuseppe Cardillo 13 Nov 2009 12:15:35
mann whitney wilcoxon Giuseppe Cardillo 13 Nov 2009 12:15:35

Contact us at files@mathworks.com