Professional Documents
Culture Documents
Jian Zou
1 / 94
Introduction
Rank-Based Methods
2 / 94
The Need for Distribution-Free Statistical Methods
3 / 94
The Need for Distribution-Free Statistical Methods
4 / 94
The Sign Test
5 / 94
The Sign Test
1
Continuous means that we regard the proportion of the population taking
any single value to be 0.
6 / 94
The Sign Test
I The Test Statistic The test statistic for the sign test is the
number of observations Yi which exceed θ0 . We will call this
statistic B.
The observed value of B, b ∗ , is the number we get when we
plug the data values into B.
I The p-value The p-value is the proportion of all samples,
when the null hypothesis is true, that have a value of the test
statistic giving as much or more evidence against the null
hypothesis and in favor of the alternative hypothesis as b ∗ .
7 / 94
The Sign Test
8 / 94
The Sign Test
9 / 94
The Sign Test
10 / 94
Large Sample Approximation
By the Central Limit Theorem, we know that if B ∼ b(n, p) and if
n is large, (np > 10 and n(1 − p) > 10) then, approximately,
B − np
p ∼ N(0, 1).
np(1 − p)
b ∗ − 0.5n + 0.5
zl∗ = √ .
0.25n
We then approximate p± by 2 min(P(Z ≥ zu∗ ), P(Z ≤ zl∗ )).
12 / 94
Example 1
13 / 94
Example 1
14 / 94
Example 1
93 − (150)(0.5) − 0.5
zu∗ = p = 2.86,
(150)(0.5)(0.5)
so the approximate p-value is
15 / 94
Estimation Based on the Sign Test
16 / 94
Estimation Based on the Sign Test
17 / 94
Estimation Based on the Sign Test
18 / 94
Example 2
115, 179, 199, 222, 225, 247, 276, 319, 342, 543, 798
19 / 94
Example 2, Continued
To obtain a 95% confidence interval for the median house price,
we look for a value k so that for X ∼ b(11, 0.5), 2P(X ≤ 11 − k)
is a close as possible to 0.05. We can use a table, a calculator, the
software (R, SAS ...), or some other technology to do this.
First, sort the values: −1.1 0.6 1.2 3.7 3.7 3.7 9.7 9.7
Next, assign integers 1 2 3 4 5 6 7 8
Finally, compute ranks
(note how the integers 1 2 3 5 5 5 7.5 7.5
are averaged for equal
data values)
21 / 94
The Wilcoxon Signed-Rank Test
22 / 94
The Wilcoxon Signed-Rank Test
23 / 94
The Wilcoxon Signed-Rank Test
Ha− : θ < θ0 p− = P0 (W ≤ w ∗ )
Ha± : θ 6= θ0 p± = 2 min(p + , p− )
24 / 94
Example 1, Revisited
25 / 94
Example 1, Revisited
So w ∗ = 2 + 0 + 3 = 5.
26 / 94
Example 1, Revisited
27 / 94
Example 1, Revisited
28 / 94
Example 1, Revisited
The table below shows the values of W resulting from each of the
8 different possible selections of signs for the Yi0 .
Note that the first line corresponds to the observed data, and so
its value W = w ∗ = 5.
29 / 94
Example 1, Revisited
30 / 94
Example 1, Revisited
31 / 94
Example 1, Revisited
Since exactly two of the 8 values (the first two) are at least as
large as w ∗ , the p-value= 2/8 = 0.25.
32 / 94
Tabulated Distribution
33 / 94
Example 1, Revisited
34 / 94
Example 1, Revisited
From software, we get the information that the value of the test
statistic is 2, which equals our value w ∗ minus 3(3 + 1)/4 = 3.
Thus we learn that w ∗ = 5, as we computed already by hand.
We also learn that the p-value of the two-sided test is 0.50. Since
our alternate hypothesis is Ha+ and 2 > 0, we can conclude that
the p-value for the one-sided test is 0.50/2 = 0.25, as we already
computed.
35 / 94
Large Sample Test
When H0 is true, the expected value and variance of W are
n(n + 1)/4 and n(n + 1)(2n + 1)/24, respectively. For large n, the
standardized test statistic
W − n(n + 1)/4
Z=p
n(n + 1)(2n + 1)/24
37 / 94
Example 1, Revisited Again
7914 − (150)(151)/4
z∗ = p = 4.22.
(150)(151)(301)/24
38 / 94
Paired Comparisons
The sign test and the Wilcoxon signed rank test can also be used
for paired data by taking the difference of each pair of observations.
See the text, p. 535 and p. 542, for relevant examples.
39 / 94
Estimation Based on the Wilcoxon Signed Rank Test
As with the sign test, we can use the Wilcoxon signed rank test to
develop point and interval estimators for the population median, θ.
Yi + Yj
, 1 ≤ i ≤ j ≤ n,
2
that are greater than θ0 . These averages are called Walsh
averages.
40 / 94
Estimation Based on the Wilcoxon Signed Rank Test
The Walsh averages play the same role for the Wilcoxon signed
rank test that the original data play for the sign test: The test
statistic for the sign test is the number of observations greater
than θ0 , while the test statistic for the Wilcoxon signed rank test is
the number of Walsh averages greater than θ0 .
The same goes for estimating θ: The estimator based on the sign
test is the median of the data, while the estimator based on the
Wilcoxon signed rank test is the median of the Walsh averages.
41 / 94
Estimation Based on the Wilcoxon Signed Rank Test
42 / 94
Estimation Based on the Wilcoxon Signed Rank Test
Let
a a a
W(1) ≤ W(2) ≤ . . . ≤ W(n(n+1)/2)
denote the ordered Walsh averages. An exact symmetric level L
confidence interval for θ is of the form
a a
(W((n(n+1)/2)−k+1) , W(k) ),
43 / 94
Estimation Based on the Wilcoxon Signed Rank Test
The software can output the sorted Walsh averages to a data set,
which makes calculation of the point estimate and confidence
inteval for the median pretty simple whether you are using Table
A.14 or the large sample approximation.
44 / 94
Example 3
Consider the data set consisting of the six values: 17, 22, 3, 20, -4,
14. A point estimator of the population median is the median of
the 6(6 + 1)/2 = 21 Walsh averages shown in the table below.
45 / 94
Example 3, Continued
From Table A.14, we find that for L = 0.969, k = 21, and for
L = 0.937, k = 20. Therefore, we obtain a level 0.969 confidence
interval for θ as
a a a a
(w(21−21+1) , w(21) ) = (w(1) , w(21) ) = (−4.0, 22.0),
46 / 94
Example 3, Continued
While we would not advise using the large sample interval for
n = 6, we will compute it now to illustrate the calculations. A level
0.95 interval will take
47 / 94
The Wilcoxon Rank Sum Test
When we wish to compare the central locations of two independent
populations, the Wilcoxon rank sum test is the appropriate
rank-based analogue to the two sample t test.
Y1,i = 1,i , i = 1, . . . , n1 ,
Y2,i = δ + 2,i , i = 1, . . . , n2 ,
where the 1,i and the 2,i are independent and have the same
continuous distribution. The parameter δ is a location shift, which
means that the distribution of the data from population 2 is the
distribution of the data from population 1 shifted δ units.
48 / 94
The Wilcoxon Rank Sum Test
Ha + : δ > δ0
H a− : δ < δ0
Ha± : δ 6 = δ0
49 / 94
The Wilcoxon Rank Sum Test
To compute the test statistic, we follow these steps:
1. Create the adjusted observations
0
Y2,i = Y2,i − δ0 , i = 1, . . . , n2 .
50 / 94
The Wilcoxon Rank Sum Test
51 / 94
The Wilcoxon Rank Sum Test
52 / 94
The Wilcoxon Rank Sum Test
There are
n1 + n2 (n1 + n2 )!
=
n2 n1 !n2 !
such permutations.
53 / 94
The Wilcoxon Rank Sum Test
54 / 94
Example 4
A company makes die-cast automotive parts. It recently replaced
two of its die-casting machines with machines using dies of a
different design. Soon after the replacement, production personnel
began to suspect that the new dies did not last as long as the old
dies. The table shows cycles to failure for four randomly-selected
dies of the new type and two randomly-selected dies of the old
type.
Cycles to
Failure Ranks
Old 9477 4
Dies 13581 6
New 7651 2
Dies 8337 3
6989 1
9568 5
55 / 94
Example 4, Continued
56 / 94
Example 4, Continued
v ∗ = 2 + 3 + 1 + 5 = 11.
Cycles to
Failure Ranks
Old 9477 4
Dies 13581 6
New 7651 2
Dies 8337 3
6989 1
9568 5
57 / 94
Example 4, Continued
6
I The P-Value The table lists all = 15 possible
4
assignments of the ranks into groups 1 and 2 and the values
of the test statistic they produce.
Group 1 Group 2 V Group 1 Group 2 V
1,2 3,4,5,6 18 3,4 1,2,5,6 14
1,3 2,4,5,6 17 3,5 1,2 4,6 13
1,4 2,3,5,6 16 2,6 1,3,4,5 13
2,3 1,4,5,6 16 3,6 1,2,4,5 12
1,5 2,3,4,6 15 4,5 1,2,3,6 12
2,4 1,3,5,6 15 4,6 1,2,3,5 11*
1,6 2,3,4,5 14 5,6 1,2,3,4 10
2,5 1,3,4,6 14
The p-value of the test is the proportion of these 15 V values
at least as small as v ∗ = 11. Since there are only 2 such
values (the last two), the p-value is p− = 2/15 = 0.133.
58 / 94
The Wilcoxon Rank Sum Test
59 / 94
The Wilcoxon Rank Sum Test
V − n2 (n1 + n2 + 1)/2
Z=p ,
n1 n2 (n1 + n2 + 1)/12
60 / 94
The Wilcoxon Rank Sum Test
and
∗ v ∗ − n2 (n1 + n2 + 1)/2 + 0.5
z− = p ,
n1 n2 (n1 + n2 + 1)/12
we can compute the approximate p-values
p + = P(Z ≥ z ∗+ ), p− = P(Z ≤ z−
∗
), p± = 2 min(p + , p− ),
61 / 94
Example 4, Continued
∗ ), where
Here, the p-value is p− = P(Z ≤ z−
∗ =
z−
Then p− =
62 / 94
The Wilcoxon Rank Sum Test
Ties are handled exactly as for the Wilcoxon signed rank test: by
taking average ranks. See p. 547 of the text for details.
63 / 94
Estimation Based on the Wilcoxon Rank Sum Test
We can use the Wilcoxon rank sum test to develop point and
interval estimators for the location shift, δ.
The Wilcoxon rank sum statistic V equals n2 (n2 + 1)/2 plus the
number of the n1 n2 differences
Y2,i − Y1,j , 1 ≤ i ≤ n2 , 1 ≤ j ≤ n1 ,
64 / 94
Estimation Based on the Wilcoxon Rank Sum Test
65 / 94
Estimation Based on the Wilcoxon Rank Sum Test
As with exact intervals based on the sign test and Wilcoxon signed
rank tests, an exact level L interval cannot be computed for all
desired levels L because of the discreteness of the distribution of
D, but Table A.15 gives the values closest to the most commonly
used values of L.
66 / 94
Example 4, Continued
Consider again the cycles to failure of the six dies. We want to
estimate the difference in location, δ, between the population
distributions of the cycles to failure of the old and the new dies.
To do this, we form the differences
67 / 94
Example 4, Continued
While we would not advise using the large sample interval for
n1 = 2 and n2 = 4, we will compute it now to illustrate the
calculations. A level 0.95 interval will take
r
(2)(4) (2)(4)(2 + 4 + 1)
k= + z0.975 = 8.2,
2 12
Therefore, we will round k to 8, and the resulting interval is the
same as the level 0.866 interval computed above.
68 / 94
Spearman Correlation
69 / 94
Example 5
Recall data on fuel consumption versus equivalence ratio,
considered in Chapter 7:
Ranks of Ranks of
Fuel Equivalence Fuel Equivalence
Consumption Ratio Consumption Ratio
98.0 0.64 1 1
100.0 0.65 2 2
100.1 0.66 3 3
102.0 0.74 6 4
101.0 0.75 4 5
103.0 0.77 7 7
103.2 0.76 8 6
101.9 0.80 5 8
104.0 0.81 9 9
105.0 0.88 10 10
105.5 0.90 11 11
105.6 0.91 12 12
106.0 0.92 13 13
110.0 1.00 14 14
111.0 1.02 15 15
115.0 1.04 16 16
121.5 1.14 17 17
123.5 1.16 18 18
136.0 1.24 19 19
70 / 94
Example 5, Continued
The scatterplots below show fuel consumption versus equivalence
ratio (left) and of the ranks of fuel consumption versus the ranks
of equivalence ratio (right) for these data.
R
F a
u 130 n
e k 15
l
o
C f
o 120
n f 10
s u
u e
m l
p 110
t c
i o 5
o n
n s
100 u
71 / 94
Example 5, Continued
The first plot shows the association between fuel consumption and
equivalence ratio to be nonlinear, and hence the Pearson
correlation, which equals a respectable 0.9332, is not the most
appropriate summary of that association. The right scatterplot
shows a more nearly linear association for the ranks of the
variables. The stronger linear association is reflected in the higher
Pearson correlation, 0.9842, between the ranks of fuel consumption
and equivalence ratio. This Pearson correlation between the ranks
is exactly the Spearman rank correlation.
72 / 94
Example 5, Continued
To illustrate the effect of outliers on both the Pearson and
Spearman correlations, we added an outlier to the data. The added
observation has a fuel consumption of 95 and an equivalence ratio
of 2.1. The resulting outlier can be seen in the lower right corner
of the left scatterplot. The right scatterplot of the ranks shows
that this data value is still an outlier, but is less extreme.
20
R
a
F 130 n
u k
e 15
l o
f
C 120
o F
n u
s e
l 10
u
m 110
p C
t o
i n
o s 5
n u
100 m
p
t
73 / 94
Example 5, Continued
74 / 94
Spearman Correlation
75 / 94
Spearman Correlation
R
Y Y
1 1
X RX
R
Y Y
2 2
X RX
R
Y Y
3 3
X RX
76 / 94
Spearman Correlation
versus
77 / 94
Example 5.5
78 / 94
Example 5.5, Continued
Here is the permutation distribution of the ranks:
RX: 1 2 3 4
Spearman
Permutation RY values correlation
1 4 3 2 1 −1.0
2 3 4 2 1 −0.8
3 4 2 3 1 −0.8
4 4 3 1 2 −0.8
5 3 4 1 2 −0.6
6 4 2 1 3 −0.4
7 2 4 3 1 −0.4
8 4 1 3 2 −0.4
9 3 2 4 1 −0.4
10 2 3 4 1 −0.2
11 4 1 2 3 −0.2
12 2 4 1 3 0.0
13 3 1 4 2 0.0
14 1 4 3 2 0.2
15 3 2 1 4 0.2
16 2 3 1 4 0.4
17 3 1 2 4 0.4
18 1 3 4 2 0.4
19 1 4 2 3 0.4
20 2 1 4 3 0.6*
21 1 3 2 4 0.8
22 1 2 4 3 0.8
23 2 1 3 4 0.8
24 1 2 3 4 1.0
79 / 94
Example 5.5, Continued
Ha + p+ =
The p values are:
H a− p− =
Ha± p± =
80 / 94
Spearman Correlation
Table A.10, p. 761 of the text gives values of p + for use in testing
monotone association for samples of size 10 and less. For larger
samples,
q an approximate test of may be obtained from the fact
n−2
that rs 1−r 2 has approximately a tn−2 distribution under the
s
assumption of no monotone association.
81 / 94
Example 5.75
82 / 94
The Kruskal-Wallis Test
Yij = µ + τi + ij , j = 1 . . . , ni , i = 1, . . . , k,
83 / 94
The Kruskal-Wallis Test
84 / 94
The Kruskal-Wallis Test
I The Test Statistic To compute the test statistic, follow
these steps:
Pk
1. Rank all n = i=1 ni observations, Yij . Let Rij denote the
rank of Yij .
2. Compute
ni ni k ni
X 1 X 1 XX n+1
Ri· = Rij , R i· = Rij , R ·· = Rij = .
ni n 2
j=1 j=1 i=1 j=1
86 / 94
The Kruskal-Wallis Test
87 / 94
The Kruskal-Wallis Test
88 / 94
Example 6
89 / 94
Example 6, Continued
90 / 94
Example 6, Continued
91 / 94
Example 6, Continued
R3· = 7 + 11 + 12 + 2 + 1 = 33,
so that
2
362 332
12 36
H = + + − 3(14 + 1)
(14)(15) 5 4 5
= 0.771
92 / 94
Example 6, Continued
93 / 94
Summary: Distribution-Free Inference Procedures
94 / 94