g08agf
g08agf
© Numerical Algorithms Group, 2002.
Purpose
G08AGF Performs the Wilcoxon one sample (matched pairs) signed rank test
Synopsis
[w,wnor,p,n1,ifail] = g08agf(x,xme<,tail,zeros,ifail>)
Description
The Wilcoxon one sample signed rank test may be used to test
whether a particular sample came from a population with a
specified median. It is assumed that the population distribution
is symmetric. The data consist of a single sample of n
observations denoted by x ,x ,...,x . This sample may arise from
1 2 n
the difference between pairs of observations from two matched
samples of equal size taken from two populations, in which case
the test may be used to test whether the median of the first
population is the same as that of the second population.
The hypothesis under test, H , often called the null hypothesis,
0
is that the median is equal to some given value (X ), and this
med
is to be tested against an alternative hypothesis H which is
1
H : population median /= X ; or
1 med
H : population median > X ; or
1 med
H : population median < X ,
1 med
using a two-tailed, upper-tailed or lower-tailed probability
respectively. The user selects the alternative hypothesis by
choosing the appropriate tail probability to be computed.
The Wilcoxon test differs from the Sign test (see G08AAF) in that
the magnitude of the scores is taken into account, rather than
simply the direction of such scores.
The test procedure is as follows:
(a) For each x , for i=1,2,...,n, the signed difference
i
d =x -X is found, where X is a given test value for
i i med med
the median of the sample.
(b) The absolute differences |d | are ranked with rank r and
i i
any tied values of |d | are assigned the average of the
i
tied ranks. The user may choose whether or not to ignore
any cases where d =0 by removing them before or after
i
ranking.
(c) The number of non-zero d 's is found.
i
(d) To each rank is affixed the sign of the d to which it
i
corresponds. Let s =sign(d )r
i i i
(e) The sum of the positive-signed ranks,
n
-- --
W= > s = > max(s ,0.0), is calculated.
-- i -- i
s >0 i=1
i
G08AGF returns:
(a) The test statistic W;
(b) The number n of non-zero d 's;
1 i
(c) The approximate Normal test statistic z, where
( n (n +1)) ( n (n +1))
( 1 1 ) ( 1 1 ) 1
(W- --------)-sign(W- --------)* -
( 4 ) ( 4 ) 2
z= ----------------------------------
________
/ n
/ 1 -- 2
/ - > s
/ 4 -- i
\/ i=1
(d) The tail probability, p, corresponding to W, depending on
the choice of the alternative hypothesis, H .
1
If n <=80, p is computed exactly; otherwise, an approximation to
1
p is returned based on an approximate Normal statistic corrected
for continuity according to the tail specified.
The value of p can be used to perform a significance test on the
median against the alternative hypothesis. Let (alpha) be the
size of the significance test (that is, (alpha) is the
probability of rejecting H when H is true). If p<(alpha) then
0 0
the null hypothesis is rejected. Typically (alpha) might be 0.05
or 0.01.
Parameters
g08agf
Required Input Arguments:
x (:) real
xme real
Optional Input Arguments: <Default>
tail (1) string 't'
zeros (1) string 'n'
ifail integer -1
Output Arguments:
w real
wnor real
p real
n1 integer
ifail integer