17.5.2.2 Algorithm (Paired-Sample Wilcoxon Signed Rank Test)
SignRank2-Algorithm
The paired sample WilCoxon sign rank test can be used to test whether the median of the first population is the same as that of the second population, which the two populations are matched with equal size.
- For
,
. The null hypothesis
is that the medians are the same, while the alternative hypothesis
can be one or two tailed. The Wilcoxon sign rank test differs from the sign test in that the magnitude of the scores is taken into account, rather than simply the direction of such scores.
- For
,
.The signed difference
is found.
- The absolute differences
are ranked with rank and any tied values of
are assigned the average of the tied ranks. The user may choose whether or not to ignore any cases where
by removing them before or after ranking.
- The number of non-zero
's is found denoted as
.
- To each rank is affixed the sign of the
to which it corresponds. Let
.
- The sum of the positive-signed ranks
is calculated.
- The tail probability,
, corresponding to
, depending on the choice of the alternative hypothesis,
. If
,
is computed exactly; otherwise, an approximation
to is returned based on an approximate Normal test statistics
, where /math-28553b84f7e48474ccf64f67b8d03413.png?v=0)
The value
of can be used to perform a significance test on the median against the alternative hypothesis. Let
be the size of significance test (that is,
is the probability of rejecting
when
is true). If
then the null hypothesis should be rejected. Typically
might be 0.05 or 0.01.
For more details of the algorithm, please refer to nag_wilcoxon_test (g08agc)