This file execute the non parametric Wilcoxon test to evaluate the difference between paired (dependent) samples. If the number of difference is less than 15, the algorithm calculate the exact ranks distribution; else it uses a normal distribution approximation.
Now, the MatLab function SIGNRANK returns the same p-value. Anyway, this Wilcoxon function gives a more detailed output (that is necessary for publications...)
The table of critical values in my statistic book is derive from this book: Some rapid approximate statistictical procedures. New York: American Cyanamid Company, p.13. I can't find it but in wikipedia.org, I find this table is the same with my book. The website is http://users.sussex.ac.uk/~grahamh/RM1web/WilcoxonTable2005.pdf
Thank you for your reply! when I change the script TC=[0 0 0 0 0 0 2 3 5 8 10 13 17 21 25 29 34 40 46 52 58 65 73 81 89] and n<25, The results are same with the SPSS calculate. The book is a Chinese book and now I am looking for some paper.
Hi, I have a quistion about this script.In this script, if the number of difference is less than 15, the algorithm calculate the exact ranks distribution. I think it should change ‘if the number of difference is less than 25’. Because in my statistic book, it's 25 and the TC (line 117) also should change as TC=[0 0 0 0 0 0 2 3 5 8 10 13 17 21 25 29 34 40 46 52 58 65 73 81 89].
Madi, I wrote Wilcoxon to manage two vectors and not a matrix.
nu is the number of inputs that you give to the function. If you change nu...I don't know what are you doing...
Thank you very much for the references. Just for the future reference, I would like to emphasize the following points:
1. According to Stanton Glantz's book (Chapter 10), "When there are tied ranks, and we use the normal distribution to compute the
P value, sigma_w needs to be reduced by a factor that depends on the number of ties". You have used this formula in your function.
2. The correction for continuity has been implemented based on the second reference mentioned above (http://faculty.vassar.edu/lowry/ch12a.html)
Please correct any false statement mentioned above.
A. So, do you mean that "0.5" in Line 123 (zW=(abs(W)-0.5)/sW) is the correction for continuity; however the real mean of the distribution of W is 0?
R. Yes 0.5 is the Yates'es Correction for continuity. If you have a great number of subjects W distribution can be approximated with a normal distribution that has mean=0 and a computed standard deviation.
A. I read a little about the concept of "continuity correction"; however, it seems that those methods including Yates' Correction have not been designed for the normal distribution. I really appreciate if you send me your reference on this particular case (i.e. for the normal distribution)
R. Yates'es correction can be applied in every case in which a discrete distribution is approximated by a continue distribution. If you read well you can find this in Stanton Glantz book, chapter 10. Anyway another (and clear) reference is http://faculty.vassar.edu/lowry/ch12a.html
So, do you mean that "0.5" in Line 123 (zW=(abs(W)-0.5)/sW) is the correction for continuity; however the real mean of the distribution of W is 0?
I read a little about the concept of "continuity correction"; however, it seems that those methods including Yates' Correction have not been designed for the normal distribution. I really appreciate if you send me your reference on this particular case (i.e. for the normal distribution)
Dear Shabnam,
first of all you compute W from your data. If the null hypothesisi is true, the signed rank will distribute equally between groups and so W->0. To check if W is not different from 0 you can use the normal approximation. A normal distribution has two parameters: a mean, that in this case is set to 0, and a standard deviation that is computed. Another one point: normal istribution is a continue distribution, but W is discrete. To check W against this normal distribution, it must be normalized: you will compute z=|W|/std. To include the Yates'es correction for continuity: (|W|-0.5)/std.
As you can see zW is not 0.5
Regards
According to Chapter 10 of the book by Stanton A. Glantz (Primer of Biostatistics) and as you mentioned above, mu_w=0 (mu_w is the mean of the distribution of W). My question is why line 123 of your code shows that mean = 0.5 :
zW=(abs(W)-0.5)/sW;
Is this test is also called Wilcoxon Signed Rank Test and also Wilcoxon matched pairs?
If the p-value is less than 0.05 can I say that there is a difference between X1 and X2? Like in the example?
Comment only
07 Mar 2008
Antonio Trujillo-Ortiz
Only to correct and clarify my previous comment, and to recall to all that, with respect to the non parametric tests between two samples, two classes exist: (1) Independent, that can be both of the same size or not, being been able to utilize the Mann-Whitneys test or the Wilcoxon ranks test; and (2) Dependent, that necessarily them should be of the same size, since is the same sample observed in two different circumstances or times, where applies the Wilcoxon signs and ranks test.
Also, I should clarify that in the personal thing I do not use the term unpaired to assign independent samples, since unpaired is synonym of unbalanced; neither paired for assign dependent, since paired is synonym of balanced. This by the fundamental reason that the concepts of independent or dependent arise for the itself nature of the data, and not because they are unpaired or paired.
The m-file here developed by Giuseppe it is a Wilcoxons test for two dependent samples for it is correct his comment that the data vectors must have the same length, and, if it is not, delete those uncoupled data. There isn't any other solutions.
So, my previous review comment is obsolete and should be ignored.
Thanks,
Prof. Antonio Trujillo-Ortiz
Comment only
05 Mar 2008
Antonio Trujillo-Ortiz
Hi Giuseppe,
You are wrong. According to the non-parametric statistics theoretic fundamentals, there are a two Wilcoxon tests:(1)Wilcoxon Rank Test for two unpaired samples, and(2) Wilcoxon Sign-Rank Test for two paired samples. You must to review them.
Yours,
Prof. Antonio Trujillo-Ortiz
Comment only
12 Jun 2007
Giuseppe Cardillo
The Wilcoxon's test is a paired test. Infact it test if the differences observed in a group after an event (in exemplum drug subministration) are caused by the event or by chance. If your vectors differ in length you must delete the uncoupled data. I think there isn't any other solutions.
Comment only
08 Jun 2007
James Cai
If my vectors, X and Y, are different in length, can I use wilcoxon(X,Y)? If not, what's the solution? Thanks.
Comment only
25 Oct 2006
Giuseppe Cardillo
You have right. I fixed the bug and uploaded the new file.
ERRATA CORRIGE: the TIEADJ value computed by TIEDRANK is quite different from correction reported in several books. The same for z-value because W is approximated with a normal distribution with mean=0 and std.dev=1. In this algorithm the tie correction is computed as reported in Stanton A. Glantz book and the normal distribution has mean=0 and a calculated std.dev (depending on tie correction).
Comment only
20 Oct 2006
Giuseppe Cardillo
RANKSUM and SIGNRANK don't compute the correction for the ties.
Comment only
20 Oct 2006
Jos x@y.z
As this requires the statistics toolbox, the function RANKSUM and SIGNRANK are available to the users. What does this function adds to those two?
Comment only
Updates
23 Oct 2006
m-lint and errors handling improvement
23 Oct 2006
fix in errors messages
23 Oct 2006
improvement
25 Oct 2006
fix bug
30 Oct 2006
Error handling and calculation improvements
10 Mar 2008
Change in DEscription according to Antonio Trujillo-Ortiz comment
12 Nov 2008
1.1
Changes in help section
23 Mar 2009
1.2
Little correction in help section to allow a correct copy and paste of the example. Correction in exitus subroutine.
06 Nov 2009
1.3
bug correction
11 Nov 2009
1.4
The output and the error handling were changed
13 Nov 2009
1.5
the STATS struct nargout was added
16 Nov 2009
1.6
Changes in help and description sections
23 Dec 2009
1.7
Changes in description
23 Mar 2010
1.8
I added the plts flag to choose to show the plots
12 Jan 2012
1.9
the Hodges-Lehmann estimator of median of differences was added