10.3. Signed-Rank Wilcoxon 589
Note that the support ofTis much denser than that of the sign test, so the
normal approximation is good even for a sample size of 10.
There is another formulation ofTthat is convenient. LetT+denote the sum of
the ranks of the positiveXis. Then, because the sum of all ranks isn(n+1)/2, we
have
T =
∑n
i=1
sgn(Xi)R|Xi|=
∑
Xi> 0
R|Xi|−
∑
Xi< 0
R|Xi|
=2
∑
Xi> 0
R|Xi|−
n(n+1)
2
=2T+−
n(n+1)
2
. (10.3.11)
HenceT+is a linear function ofTand thus is an equivalent formulation of the
signed-rank test statisticT. For the record, we note the null mean and variance of
T+:
EH 0 (T+)=n(n 4 +1) and VarH 0 (T+)=n(n+1)(2 24 n+1). (10.3.12)
The intrinsic R functionwilcox.testcomputes the signed-rank analysis, re-
turning the test statisticT+and thep-value. If the sample is in the R vectorx
then the signed-rank test of the hypotheses (10.3.1) is computed by the R com-
mandwilcox.test(x,alt="greater"). The arguments for the other one-sided
and the two-sided hypotheses are respectivelyalt="less"andalt="two.sided".
To compute the signed-rank test of the hypothesesH 0 :θ=θ 0 versusH 1 :θ =θ 0 ,
use the commandwilcox.test(x,alt="two.sided",mu=theta0). Also, the R call
psignrank(y,n)computes the cdf ofT+aty.
Example 10.3.1(Zea maysData of Darwin). Reconsider the data set discussed
in Example 4.5.1. Recall thatWiis the difference in heights of the cross-fertilized
plant minus the self-fertilized plant in poti,fori=1,...,15. Letθbe the location
parameter and consider the one-sided hypotheses
H 0 :θ=0versusH 1 : θ> 0. (10.3.13)
Table 10.3.1 displays the data and the signed ranks.
Adding up the ranks of the positive items in column 5 of Table 10.3.1, we obtain
T+= 96. Using the exact distribution, the R command is1-psignrank(95,15)),
we obtain thep-value,p̂=PH 0 (T+≥96) = 0.021. For comparison, the asymptotic
p-value, using the continuity correction is
PH 0 (T+≥96) =PH 0 (T+≥ 95 .5) ≈ P
(
Z≥
95. 5 − 60
√
15 · 16 · 31 / 24
)
= P(Z≥ 2 .016) = 0. 022 ,
which is quite close to the exact value of 0.021.
Suppose the R vectordscontains the paired differences between cross and self-
fertilized. Then the R commandwilcox.test(ds,alt="greater")computes the