The Wilcoxon signed-rank test is a non-parametric rank test for statistical hypothesis testing used either to test the location of a population based on a sample of data, or to compare the locations of two populations using two matched samples.[1] The one-sample version serves a purpose similar to that of the one-sample Student's t-test.[2] For two matched samples, it is a paired difference test like the paired Student's t-test (also known as the "t-test for matched pairs" or "t-test for dependent samples"). The Wilcoxon test is a good alternative to the t-test when the normal distribution of the differences between paired individuals cannot be assumed. Instead, it assumes a weaker hypothesis that the distribution of this difference is symmetric around a central value and it aims to test whether this center value differs significantly from zero. The Wilcoxon test is a more powerful alternative to the sign test because it considers the magnitude of the differences, but it requires this moderately strong assumption of symmetry.
History
[edit]The test is named after Frank Wilcoxon (1892–1965) who, in a single paper, proposed both it and the rank-sum test for two independent samples.[3] The test was popularized by Sidney Siegel (1956) in his influential textbook on non-parametric statistics.[4] Siegel used the symbol T for the test statistic, and consequently, the test is sometimes referred to as the Wilcoxon T-test.
Test procedure
[edit]There are two variants of the signed-rank test. From a theoretical point of view, the one-sample test is more fundamental because the paired sample test is performed by converting the data to the situation of the one-sample test. However, most practical applications of the signed-rank test arise from paired data.
For a paired sample test, the data consists of samples . Each sample is a pair of measurements. In the simplest case, the measurements are on an interval scale. Then they may be converted to real numbers, and the paired sample test is converted to a one-sample test by replacing each pair of numbers by its difference .[5] In general, it must be possible to rank the differences between the pairs. This requires that the data be on an ordered metric scale, a type of scale that carries more information than an ordinal scale but may have less than an interval scale.[6]
The data for a one-sample test is a set of real number samples . Assume for simplicity that the samples have distinct absolute values and that no sample equals zero. (Zeros and ties introduce several complications; see below.) The test is performed as follows:[7][8]
- Compute .
- Sort , and use this sorted list to assign ranks : The rank of the smallest observation is one, the rank of the next smallest is two, and so on.
- Let denote the sign function: if and if . The test statistic is the signed-rank sum :
- Produce a -value by comparing to its distribution under the null hypothesis.
The ranks are defined so that is the number of for which . Additionally, if is such that , then for all .
The signed-rank sum is closely related to two other test statistics. The positive-rank sum and the negative-rank sum are defined by[9] Because equals the sum of all the ranks, which is , these three statistics are related by:[10] Because , , and carry the same information, any of them may be used as the test statistic.
The positive-rank sum and negative-rank sum have alternative interpretations that are useful for the theory behind the test. Define the Walsh average to be . Then:[11]
Null and alternative hypotheses
[edit]One-sample test
[edit]The one-sample Wilcoxon signed-rank test can be used to test whether data comes from a symmetric population with a specified center (which corresponds to median, mean and pseudomedian).[12] If the population center is known, then it can be used to test whether data is symmetric about its center.[13]
To explain the null and alternative hypotheses formally, assume that the data consists of independent and identically distributed samples from a distribution . If can be assumed symmetric, then the null and alternative hypotheses are the following:[14]
- Null hypothesis H0
- is symmetric about .
- One-sided alternative hypothesis H1
- is symmetric about .
- One-sided alternative hypothesis H2
- is symmetric about .
- Two-sided alternative hypothesis H3
- is symmetric about .
If in addition , then is a median of . If this median is unique, then the Wilcoxon signed-rank sum test becomes a test for the location of the median.[15] When the mean of is defined, then the mean is , and the test is also a test for the location of the mean.[16]
The restriction that the alternative distribution is symmetric is highly restrictive, but for one-sided tests it can be weakened. Say that is stochastically smaller than a distribution symmetric about zero if an -distributed random variable satisfies for all . Similarly, is stochastically larger than a distribution symmetric about zero if for all . Then the Wilcoxon signed-rank sum test can also be used for the following null and alternative hypotheses:[17][18]
- Null hypothesis H0
- is symmetric about .
- One-sided alternative hypothesis H1
- is stochastically smaller than a distribution symmetric about zero.
- One-sided alternative hypothesis H2
- is stochastically larger than a distribution symmetric about zero.
The hypothesis that the data are IID can be weakened. Each data point may be taken from a different distribution, as long as all the distributions are assumed to be continuous and symmetric about a common point . The data points are not required to be independent as long as the conditional distribution of each observation given the others is symmetric about .[19]
Paired data test
[edit]Because the paired data test arises from taking paired differences, its null and alternative hypotheses can be derived from those of the one-sample test. In each case, they become assertions about the behavior of the differences .
Let be the joint cumulative distribution of the pairs . In this case, the null and alternative hypotheses are:[20][21]
- Null hypothesis H0
- The observations are symmetric about .
- One-sided alternative hypothesis H1
- The observations are symmetric about .
- One-sided alternative hypothesis H2
- The observations are symmetric about .
- Two-sided alternative hypothesis H3
- The observations are symmetric about .
These can also be expressed more directly in terms of the original pairs:[22]
- Null hypothesis H0
- The observations are exchangeable, meaning that and have the same distribution. Equivalently, .
- One-sided alternative hypothesis H1
- For some , the pairs and have the same distribution.
- One-sided alternative hypothesis H2
- For some , the pairs and have the same distribution.
- Two-sided alternative hypothesis H3
- For some , the pairs and have the same distribution.
The null hypothesis of exchangeability can arise from a matched pair experiment with a treatment group and a control group. Randomizing the treatment and control within each pair makes the observations exchangeable. For an exchangeable distribution, has the same distribution as , and therefore, under the null hypothesis, the distribution is symmetric about zero.[23]
Because the one-sample test can be used as a one-sided test for stochastic dominance, the paired difference Wilcoxon test can be used to compare the following hypotheses:[24]
- Null hypothesis H0
- The observations are exchangeable.
- One-sided alternative hypothesis H1
- The differences are stochastically smaller than a distribution symmetric about zero, that is, for every , .
- One-sided alternative hypothesis H2
- The differences are stochastically larger than a distribution symmetric about zero, that is, for every , .
Zeros and ties
[edit]In real data, it sometimes happens that there is a sample which equals zero or a pair with . It can also happen that there are tied samples. This means that for some , we have (in the one-sample case) or (in the paired sample case). This is particularly common for discrete data. When this happens, the test procedure defined above is usually undefined because there is no way to uniquely rank the data. (The sole exception is if there is a single sample which is zero and no other zeros or ties.) Because of this, the test statistic needs to be modified.
Zeros
[edit]Wilcoxon's original paper did not address the question of observations (or, in the paired sample case, differences) that equal zero. However, in later surveys, he recommended removing zeros from the sample.[25] Then the standard signed-rank test could be applied to the resulting data, as long as there were no ties. This is now called the reduced sample procedure.
Pratt[26] observed that the reduced sample procedure can lead to paradoxical behavior. He gives the following example. Suppose that we are in the one-sample situation and have the following thirteen observations:
- 0, 2, 3, 4, 6, 7, 8, 9, 11, 14, 15, 17, −18.
The reduced sample procedure removes the zero. To the remaining data, it assigns the signed ranks:
- 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, −12.
This has a one-sided p-value of , and therefore the sample is not significantly positive at any significance level . Pratt argues that one would expect that decreasing the observations should certainly not make the data appear more positive. However, if the zero observation is decreased by an amount less than 2, or if all observations are decreased by an amount less than 1, then the signed ranks become:
- −1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, −13.
This has a one-sided p-value of . Therefore the sample would be judged significantly positive at any significance level . The paradox is that, if is between and , then decreasing an insignificant sample causes it to appear significantly positive.
Pratt therefore proposed the signed-rank zero procedure. This procedure includes the zeros when ranking the samples. However, it excludes them from the test statistic, or equivalently it defines . Pratt proved that the signed-rank zero procedure has several desirable behaviors not shared by the reduced sample procedure:[27]
- Increasing the observed values does not make a significantly positive sample insignificant, and it does not make an insignificant sample significantly negative.
- If the distribution of the observations is symmetric, then the values of which the test does not reject form an interval.
- A sample is significantly positive, not significant, or significantly negative, if and only if it is so when the zeros are assigned arbitrary non-zero signs, if and only if it is so when the zeros are replaced with non-zero values which are smaller in absolute value than any non-zero observation.
- For a fixed significance threshold , and for a test which is randomized to have level exactly , the probability of calling a set of observations significantly positive (respectively, significantly negative) is a non-decreasing (respectively, non-increasing) function of the observations.
Pratt remarks that, when the signed-rank zero procedure is combined with the average rank procedure for resolving ties, the resulting test is a consistent test against the alternative hypothesis that, for all , and differ by at least a fixed constant that is independent of and .[28]
The signed-rank zero procedure has the disadvantage that, when zeros occur, the null distribution of the test statistic changes, so tables of p-values can no longer be used.
When the data is on a Likert scale with equally spaced categories, the signed-rank zero procedure is more likely to maintain the Type I error rate than the reduced sample procedure.[29]
From the viewpoint of statistical efficiency, there is no perfect rule for handling zeros. Conover found examples of null and alternative hypotheses that show that neither Wilcoxon's and Pratt's methods are uniformly better than the other. When comparing a discrete uniform distribution to a distribution where probabilities linearly increase from left to right, Pratt's method outperforms Wilcoxon's. When testing a binomial distribution centered at zero to see whether the parameter of each Bernoulli trial is , Wilcoxon's method outperforms Pratt's.[30]
Ties
[edit]When the data does not have ties, the ranks are used to calculate the test statistic. In the presence of ties, the ranks are not defined. There are two main approaches to resolving this.
The most common procedure for handling ties, and the one originally recommended by Wilcoxon, is called the average rank or midrank procedure. This procedure assigns numbers between 1 and n to the observations, with two observations getting the same number if and only if they have the same absolute value. These numbers are conventionally called ranks even though the set of these numbers is not equal to (except when there are no ties). The rank assigned to an observation is the average of the possible ranks it would have if the ties were broken in all possible ways. Once the ranks are assigned, the test statistic is computed in the same way as usual.[31][32]
For example, suppose that the observations satisfy In this case, is assigned rank 1, and are assigned rank , is assigned rank 4, and , , and are assigned rank . Formally, suppose that there is a set of observations all having the same absolute value , that observations have absolute value less than , and that observations have absolute value less than or equal to . If the ties among the observations with absolute value were broken, then these observations would occupy ranks through . The average rank procedure therefore assigns them the rank .
Under the average rank procedure, the null distribution is different in the presence of ties.[33][34] The average rank procedure also has some disadvantages that are similar to those of the reduced sample procedure for zeros. It is possible that a sample can be judged significantly positive by the average rank procedure; but increasing some of the values so as to break the ties, or breaking the ties in any way whatsoever, results in a sample that the test judges to be not significant.[35][36] However, increasing all the observed values by the same amount cannot turn a significantly positive result into an insignificant one, nor an insignificant one into a significantly negative one. Furthermore, if the observations are distributed symmetrically, then the values of which the test does not reject form an interval.[37][38]
The other common option for handling ties is a tiebreaking procedure. In a tiebreaking procedure, the observations are assigned distinct ranks in the set . The rank assigned to an observation depends on its absolute value and the tiebreaking rule. Observations with smaller absolute values are always given smaller ranks, just as in the standard rank-sum test. The tiebreaking rule is used to assign ranks to observations with the same absolute value. One advantage of tiebreaking rules is that they allow the use of standard tables for computing p-values.[39]
Random tiebreaking breaks the ties at random. Under random tiebreaking, the null distribution is the same as when there are no ties, but the result of the test depends not only on the data but on additional random choices. Averaging the ranks over the possible random choices results in the average rank procedure.[40] One could also report the probability of rejection over all random choices.[41] Random tiebreaking has the advantage that the probability that a sample is judged significantly positive does not decrease when some observations are increased.[42] Conservative tiebreaking breaks the ties in favor of the null hypothesis. When performing a one-sided test in which negative values of tend to be more significant, ties are broken by assigning lower ranks to negative observations and higher ranks to positive ones. When the test makes positive values of significant, ties are broken the other way, and when large absolute values of are significant, ties are broken so as to make as small as possible. Pratt observes that when ties are likely, the conservative tiebreaking procedure "presumably has low power, since it amounts to breaking all ties in favor of the null hypothesis."[43]
The average rank procedure can disagree with tiebreaking procedures. Pratt gives the following example.[44] Suppose that the observations are:
- 1, 1, 1, 1, 2, 3, −4.
The average rank procedure assigns these the signed ranks
- 2.5, 2.5, 2.5, 2.5, 5, 6, −7.
This sample is significantly positive at the one-sided level . On the other hand, any tiebreaking rule will assign the ranks
- 1, 2, 3, 4, 5, 6, −7.
At the same one-sided level , this is not significant.
Two other options for handling ties are based around averaging the results of tiebreaking. In the average statistic method, the test statistic is computed for every possible way of breaking ties, and the final statistic is the mean of the tie-broken statistics. In the average probability method, the p-value is computed for every possible way of breaking ties, and the final p-value is the mean of the tie-broken p-values.[45]
Computing the null distribution
[edit]Computing p-values requires knowing the distribution of under the null hypothesis. There is no closed formula for this distribution.[46] However, for small values of , the distribution may be computed exactly. Under the null hypothesis that the data is symmetric about zero, each is exactly as likely to be positive as it is negative. Therefore the probability that under the null hypothesis is equal to the number of sign combinations that yield divided by the number of possible sign combinations . This can be used to compute the exact distribution of under the null hypothesis.[47]
Computing the distribution of by considering all possibilities requires computing sums, which is intractable for all but the smallest . However, there is an efficient recursion for the distribution of .[48][49] Define to be the number of sign combinations for which . This is equal to the number of subsets of which sum to . The base cases of the recursion are , for all , and for all or . The recursive formula is The formula is true because every subset of which sums to either does not contain , in which case it is also a subset of , or it does contain , in which case removing from the subset produces a subset of which sums to . Under the null hypothesis, the probability mass function of satisfies . The function is closely related to the integer partition function.[50]
If is the probability that under the null hypothesis when there are samples, then satisfies a similar recursion:[51] with similar boundary conditions. There is also a recursive formula for the cumulative distribution function .[52]
For very large , even the above recursion is too slow. In this case, the null distribution can be approximated. The null distributions of , , and are asymptotically normal with means and variances:[53]
Better approximations can be produced using Edgeworth expansions. Using a fourth-order Edgeworth expansion shows that:[54][55] where The technical underpinnings of these expansions are rather involved, because conventional Edgeworth expansions apply to sums of IID continuous random variables, while is a sum of non-identically distributed discrete random variables. The final result, however, is that the above expansion has an error of , just like a conventional fourth-order Edgeworth expansion.[54]
The moment generating function of has the exact formula:[56]
When zeros are present and the signed-rank zero procedure is used, or when ties are present and the average rank procedure is used, the null distribution of changes. Cureton derived a normal approximation for this situation.[57][58] Suppose that the original number of observations was and the number of zeros was . The tie correction is where the sum is over all the sizes of each group of tied observations. The expectation of is still zero, while the expectation of is If then
Alternative statistics
[edit]Wilcoxon[59] originally defined the Wilcoxon rank-sum statistic to be . Early authors such as Siegel[60] followed Wilcoxon. This is appropriate for two-sided hypothesis tests, but it cannot be used for one-sided tests.
Instead of assigning ranks between 1 and n, it is also possible to assign ranks between 0 and . These are called modified ranks.[61] The modified signed-rank sum , the modified positive-rank sum , and the modified negative-rank sum are defined analogously to , , and but with the modified ranks in place of the ordinary ranks. The probability that the sum of two independent -distributed random variables is positive can be estimated as .[62] When consideration is restricted to continuous distributions, this is a minimum variance unbiased estimator of .[63]
Example
[edit]
|
order by absolute difference |
|
is the sign function, is the absolute value, and is the rank. Notice that pairs 3 and 9 are tied in absolute value. They would be ranked 1 and 2, so each gets the average of those ranks, 1.5.
- that the median of pairwise differences is different from zero.
- The -value for this result is
Effect size
[edit]To compute an effect size for the signed-rank test, one can use the rank-biserial correlation.
If the test statistic T is reported, the rank correlation r is equal to the test statistic T divided by the total rank sum S, or r = T/S. [64] Using the above example, the test statistic is T = 9. The sample size of 9 has a total rank sum of S = (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9) = 45. Hence, the rank correlation is 9/45, so r = 0.20.
If the test statistic T is reported, an equivalent way to compute the rank correlation is with the difference in proportion between the two rank sums, which is the Kerby (2014) simple difference formula.[64] To continue with the current example, the sample size is 9, so the total rank sum is 45. T is the smaller of the two rank sums, so T is 3 + 4 + 5 + 6 = 18. From this information alone, the remaining rank sum can be computed, because it is the total sum S minus T, or in this case 45 − 18 = 27. Next, the two rank-sum proportions are 27/45 = 60% and 18/45 = 40%. Finally, the rank correlation is the difference between the two proportions (.60 minus .40), hence r = .20.
Software implementations
[edit]- R includes an implementation of the test as
wilcox.test(x,y, paired=TRUE)
, where x and y are vectors of equal length.[65] - ALGLIB includes implementation of the Wilcoxon signed-rank test in C++, C#, Delphi, Visual Basic, etc.
- GNU Octave implements various one-tailed and two-tailed versions of the test in the
wilcoxon_test
function. - SciPy includes an implementation of the Wilcoxon signed-rank test in Python.
- Accord.NET includes an implementation of the Wilcoxon signed-rank test in C# for .NET applications.
- MATLAB implements this test using "Wilcoxon rank sum test" as
[p,h] = signrank(x,y)
also returns a logical value indicating the test decision. The result h = 1 indicates a rejection of the null hypothesis, and h = 0 indicates a failure to reject the null hypothesis at the 5% significance level. - Julia HypothesisTests package includes the Wilcoxon signed-rank test as
value(SignedRankTest(x, y))
. - SAS PROC UNIVARIATE includes the Wilcoxon-Signed Rank Test in the frame titles "Tests for Location" as "Signed Rank". Even though this procedure calculates an S-Statistic rather than a W-Statistic, the resulting p-value can still be used for this test.[66]
See also
[edit]References
[edit]- ^ Conover, W. J. (1999). Practical nonparametric statistics (3rd ed.). John Wiley & Sons, Inc. ISBN 0-471-16068-7., p. 350
- ^ "Wilcoxon signed-rank test - Handbook of Biological Statistics". www.biostathandbook.com. Retrieved 2021-09-02.
- ^ Wilcoxon, Frank (Dec 1945). "Individual comparisons by ranking methods" (PDF). Biometrics Bulletin. 1 (6): 80–83. doi:10.2307/3001968. hdl:10338.dmlcz/135688. JSTOR 3001968.
- ^ Siegel, Sidney (1956). Non-parametric statistics for the behavioral sciences. New York: McGraw-Hill. pp. 75–83. ISBN 9780070573482.
- ^ Conover, p. 352
- ^ Siegel, p. 76
- ^ Conover, p. 353
- ^ Pratt, John W.; Gibbons, Jean D. (1981). Concepts of Nonparametric Theory. Springer-Verlag. ISBN 978-1-4612-5933-6., p. 148
- ^ Pratt and Gibbons, p. 148
- ^ Pratt and Gibbons, p. 148
- ^ Pratt and Gibbons, p. 150
- ^ Conover, pp. 352–357
- ^ Hettmansperger, Thomas P. (1984). Statistical Inference Based on Ranks. John Wiley & Sons. ISBN 0-471-88474-X., pp. 32, 50
- ^ Pratt and Gibbons, pp. 146–147
- ^ Hettmansperger, pp. 30–31
- ^ Conover, p. 353
- ^ Pratt and Gibbons, pp. 155–156
- ^ Hettmansperger, pp. 49–50
- ^ Pratt and Gibbons, p. 155
- ^ Conover, p. 354
- ^ Hollander, Myles; Wolfe, Douglas A.; Chicken, Eric (2014). Nonparametric Statistical Methods (Third ed.). John Wiley & Sons, Inc. ISBN 978-0-470-38737-5., pp. 39–41
- ^ Pratt and Gibbons, p. 147
- ^ Pratt and Gibbons, p. 147
- ^ Hettmansperger, pp. 49–50
- ^ Wilcoxon, Frank (1949). Some Rapid Approximate Statistical Procedures. American Cynamic Co.
- ^ Pratt, J. (1959). "Remarks on zeros and ties in the Wilcoxon signed rank procedures". Journal of the American Statistical Association. 54 (287): 655–667. doi:10.1080/01621459.1959.10501526.
- ^ Pratt, p. 659
- ^ Pratt, p. 663
- ^ Derrick, B; White, P (2017). "Comparing Two Samples from an Individual Likert Question". International Journal of Mathematics and Statistics. 18 (3): 1–13.
- ^ Conover, William Jay (1973). "On Methods of Handling Ties in the Wilcoxon Signed-Rank Test". Journal of the American Statistical Association. 68 (344): 985–988. doi:10.1080/01621459.1973.10481460.
- ^ Pratt and Gibbons, p. 162
- ^ Conover, pp. 352–353
- ^ Pratt and Gibbons, p. 164
- ^ Conover, pp. 358–359
- ^ Pratt, p. 660
- ^ Pratt and Gibbons, pp. 168–169
- ^ Pratt, pp. 661–662
- ^ Pratt and Gibbons, p. 170
- ^ Pratt and Gibbons, pp. 163, 166
- ^ Pratt, p. 660
- ^ Pratt and Gibbons, p. 166
- ^ Pratt and Gibbons, p. 171
- ^ Pratt, p. 661
- ^ Pratt, p. 660
- ^ Gibbons, Jean D.; Chakraborti, Subhabrata (2011). Nonparametric Statistical Inference (Fifth ed.). Chapman & Hall/CRC. ISBN 978-1-4200-7762-9., p. 194
- ^ Hettmansperger, p. 34
- ^ Pratt and Gibbons, pp. 148–149
- ^ Pratt and Gibbons, pp. 148–149, pp. 186–187
- ^ Hettmansperger, p. 171
- ^ Pratt and Gibbons, p. 187
- ^ Pratt and Gibbons, p. 187
- ^ Pratt and Gibbons, p. 187
- ^ Pratt and Gibbons, p. 149
- ^ a b Kolassa, John E. (1995). "Edgeworth approximations for rank sum test statistics". Statistics and Probability Letters. 24 (2): 169–171. doi:10.1016/0167-7152(95)00164-H.
- ^ Hettmansperger, p. 37
- ^ Hettmansperger, p. 35
- ^ Cureton, Edward E. (1967). "The normal approximation to the signed-rank sampling distribution when zero differences are present". Journal of the American Statistical Association. 62 (319): 1068–1069. doi:10.1080/01621459.1967.10500917.
- ^ Pratt and Gibbons, p. 193
- ^ Wilcoxon, p. 82
- ^ Siegel, p. 76
- ^ Pratt and Gibbons, p. 158
- ^ Pratt and Gibbons, p. 159
- ^ Pratt and Gibbons, p. 191
- ^ a b Kerby, Dave S. (2014), "The simple difference formula: An approach to teaching nonparametric correlation.", Comprehensive Psychology, 3: 11.IT.3.1, doi:10.2466/11.IT.3.1 (inactive 2024-06-26)
{{citation}}
: CS1 maint: DOI inactive as of June 2024 (link) - ^ Dalgaard, Peter (2008). Introductory Statistics with R. Springer Science & Business Media. pp. 99–100. ISBN 978-0-387-79053-4.
- ^ "Wilcox signed-rank test: SAS instruction". www.stat.purdue.edu. Retrieved 2023-08-24.
External links
[edit]- Wilcoxon Signed-Rank Test in R
- Example of using the Wilcoxon signed-rank test
- An online version of the test
- A table of critical values for the Wilcoxon signed-rank test
- Brief guide by experimental psychologist Karl L. Weunsch - Nonparametric effect size estimators (Copyright 2015 by Karl L. Weunsch)
- Kerby, D. S. (2014). The simple difference formula: An approach to teaching nonparametric correlation. Comprehensive Psychology, volume 3, article 1. doi:10.2466/11.IT.3.1. link to article