Contents
ALGORITHMS
Site map
Links
Site and author
News
About the site
FAQ
Contact
TERMS OF USE
Contents - Statistics - Hypothesis testing - Wilcoxon signed-rank test

Wilcoxon signed-rank test

The Wilcoxon signed-rank test is a non-parametric test used to compare the distribution median with a given value m. This criterion could be used as an alternative for one-sample Student t-test. Unlike the t-test, Wilcoxon signed-rank test can work with non-normal distributions.

This test has the following requirements:

  • the scale of measurement[1] should be ordinal, interval or ratio (i.e. test could not be applied to nominal variables)
  • the distribution should be continuous and symmetric relative to its median

Note #1
The distribution symmetry requirement is critical. If the distribution is non-symmetric, the test could not be used. In that case we can use less powerful (but more general) sign test.

Subroutine WilcoxonSignedRankTest returns three p-values:

  • p-value for two-tailed test (null hypothesis - the median is equal to the given value)
  • p-value for left-tailed test (null hypothesis - the median is greater than or equal to the given value)
  • p-value for right-tailed test (null hypothesis - the median is less than or equal to the given value)

The test algorithm is simple. All elements which are equal to m are thrown out. After that we have elements of two types only: elements which are greater than m and which are less than m. Elements are sorted by their absolute value. After that W + (sum of positive elements ranks) is calculated. If this hypothesis is true (the median equals m), W + has a distribution which could easily be calculated (using dynamic programming) and tabulated. To define the significance level corresponding to the W + value tables (for small Ns) or asymptotic approximations (for greater Ns) are used. This method lets us calculate p-values with two decimal places in interval [0.0001, 1]. "Two decimal places" does not sound very impressive, but in practice the relative error of less than 1% is enough to make a decision.

Note #2
Some sources recommend to use normal distribution with μ = 0.25·N·(N+1) and σ 2 = N·(N+1)·(2N+1)/24 when estimating the significance level. In fact, as N increases W + converges to normal distribution with these parameters. However, although the rate of convergence is good it's better not to approximate W + with normal distribution, because this approximation can be insufficiently precise.

Links

  1. 'Level of measurement', Wikipedia
  2. 'Wilcoxon signed-rank test', Wikipedia
  3. 'Hypothesis testing', Wikipedia
  4. 'P-value', Wikipedia

Report a bug

Source codes

C#

C# 1.0 source.
wsr.csharp.zip - Wilcoxon signed-rank test


C++

C++ source.
wsr.cpp.zip - Wilcoxon signed-rank test
ablas.zip - optimized basic linear algebra subroutines with SSE2 support (for C++ sources only)


Delphi

Delphi source.
Can be compiled under FPC (in Delphi compatibility mode).
wsr.delphi.zip - Wilcoxon signed-rank test


Visual Basic 6

Visual Basic 6 source.
wsr.vb6.zip - Wilcoxon signed-rank test


Zonnon beta

Zonnon source.
Zonnon is an experimental language developed at ETH Zurich.
See www.zonnon.ethz.ch for more information.
wsr.zonnon.zip - Wilcoxon signed-rank test



 
 
Sergey Bochkanov, Vladimir Bystritsky
Copyright © 1999-2008