Chapter 5
One Way Layout
1
Question 5.1
We use Wilcoxon Rank Sum test statistic
W to compare the locations of two
populations
(a) What is the value of E(W) under H0?
(b) What is the value of E(U) under H0
where U denotes the rank sum of the
sample with larger sample size?
2
Question 5.2
If we need to compare the locations
of three different populations, what
can be done?
3
[Link] Wallis Statistics
• The Kruskal Wallis statistic is 1-way ANOVA applied to the
ranks, instead of the original observations.
k
• k independent samples: n1 , n2 , , nk , ∑ ni = N .
i =1
• Model:
X ij = µ + α i + eij i = 1,2, , k , j = 1,2, , ni
∑ α i = 0,
eij i.i.d. F (continuous)
H0: α1 = α2 =…= αk (all α = 0, no treatment difference)
H1: α’s are not all equal.
4
Procedure
1. Rank all N data points in the k samples
2. 12 k R2
H = ∑ i − 3( N + 1)
N ( N + 1) i =1 ni
where
Ri = sum of ranks for the ith sample.
3. Reject H0 if H is too large.
5
Justification
Ri
If H0 is true, expect , average rank for ith sample, to be
ni
1+ 2 ++ N 1
close to the overall average rank = = ( N + 1).
N 2
Let D = measure of discrepancy
2
k Ri N + 1
D = ∑ ni −
i =1 ni 2
k
(Compare with Treatment SS = ∑ ni ( X i . − X .. ) 2 in 1-way ANOVA).
i =1
12 D
It can be shown that H = .
N ( N + 1)
12
The factor transforms the distribution of D to a well-
N ( N + 1)
known form ( χ2) in large sample. 6
Example
A: 2, 4,
B: 3, 5, 7
C: 1, 6
R1 = 6, R2 = 15, R3 = 7
12 3 R2 12 36 225 49
H = ∑ i
− 3( N + 1) = + + − 3× 8
N ( N + 1) i =1 ni 7×8 2 3 2
= 1.179
Reject H0 of no treatment difference if H is too large.
- Need the distribution of H under H0. Table A.7 of
Hollander & Wolfe
From Table A.7, p-value = 0.657.
(check the one with n1=2, n2=2, n3=3, p.296 of the table)
∴ Not significant, no evidence to support that the distributions
of A, B and C are different. 7
Exact distribution of H
• Under H0, use randomization model.
• Calculate all values of H for every possible combinations of ranks.
• If k = 3, n1 = n2 = n3 = 3, there are
9!
= 1680
3! 3! 3!
possible combinations. Tedious!
• The exact distribution of H is given in Table A.7 of Hollander and
Wolfe.
8
Example
n1 = 1, n2 = 1, n3 = 2. R3
∑ Ri / ni
2
R1 R2 R31 R32 i H
There are totally 3 4 1 2 9+16+ 9/2 2.7
4!
= 12 4 3 1 2 9+16+ 9/2 2.7
1!1!2! 2 4 1 3 4+16+16/2 1.8
different combinations. 4 2 1 3 4+16+16/2 1.8
2 3 1 4 4+ 9+25/2 0.3
∴ PH 0 ( H ≥ 2.7) = 6 / 12 = 0.5 3 2 1 4 4+ 9+25/2 0.3
PH 0 ( H ≥ 1.8) = 10 / 12 = 0.833 1 4 2 3 1+16+25/2 2.7
4 1 2 3 1+16+25/2 2.7
PH 0 ( H ≥ 0.3) = 12 / 12 = 1.0 1 3 2 4 1+ 9+36/2 1.8
3 1 2 4 1+ 9+36/2 1.8
The same as those in Table A.7. 1 2 3 4 1+ 4+49/2 2.7
2 1 3 4 1+ 4+49/2 2.7
9
Large sample distribution
Under H0,
H ~ χ k2−1
Approximation OK if min( ni ) > 3
Ties
• Use average rank.
- Distribution in Table A.7 is no longer exact.
• In large sample. Let
+ H H: calculated using average rank.
H =
1−
∑ j −tj)
(t 3
tj: no. of ties in each tied group.
N3 − N
• The distribution of H+ is approximatelyχ k −1 for large sample.
2
10
The special case of comparing two groups
• k=2
• Assume no tie.
• Let W = Wilcoxon Rank Sum Test Statistic, it can be shown that
(W − E (W )) 2 .
H=
Var (W )
1 Your assignment !
where E (W ) = n( N + 1)
2
mn( N + 1)
Var (W ) =
12
11
Example
X 1.2(1) 7.4 (5) 4.8 (4) 9.2 (6) m = n1=4
Y 4.1 (3) 3.1 (2) n = n2=2
W = 2 + 3 = 5, R1=16, R2=5
1 1
E (W ) = n( N + 1) = × 2 × 7 = 7
2 2
mn( N + 1) 2 × 4 × 7 14
Var (W ) = = =
12 12 3
(W − E (W )) 2 4 12 6
= = = .
Var (W ) 14 3 14 7
12 2
Ri2 12 16 2 52 6
H= ∑
N ( N + 1) i =1 ni
− 3( N + 1) =
6× 7 4
+
2
− 3 × 7 =
7
.
(W − E (W )) 2
∴ H= .
Var (W ) 12
2. An Application to 2 x t contingency table
If there are no clear a priori directions for the effect of the
treatment, and if we wish to know only whether or not there is
some difference between the treatments, we can apply the
following method (see Lehmann p.210 for more details):
Example: Opinion Polls
100 voters, 3 candidates A, B and C
40 picked at random for interview.
60 given a questionnaire. A B C
Q 28 15 17 60
I 13 6 21 40
41 21 38 100
H0: No difference between Q and I.
H1: There is a difference but in which directions unknown. 13
Nonparametric Test: Treat A, B, C as 3 independent samples
- Score 1 if a person is given Q
- Score 2 if person given I
H0*: There is no difference between the 3 candidates w.r.t. their support by Q or I.
Basically, H0 & H0* both assert the independence of the preference for a
candidate from the polling method.
A B C The Q’s have average rank:
t1=60 1 + 2 + + 60 61
Q 28 15 17 60 =
I 13 6 21 40 60 2
t2=40
41 21 38 100 The I’s have average rank:
61 + 62 + + 100 161
61 161 =
A : rank sum = 28 × + 13 × = 1900.5 40 2
2 2
61 161
B : rank sum = 15 × + 6 × = 940.5 R1=1900.5
2 2
R2=940.5
61 161
C : rank sum = 17 × + 21× = 2209.0 R3=2209.5 14
2 2
12 3 R2 R1=1900.5 n1=41
H = ∑ i − 3( N + 1) R2=940.5 n2=21
N ( N + 1) i =1 ni R3=2209.5 n3= 38
= 4.282
H
H+ =
1−
∑ j −tj)
(t 3 t1 = 60
N3 − N t2 = 40
4.282
=
0.720
= 5.95
χ 22 (5.95) = 0.050 ( χ 22 (5.99) = 0.05)
∴ (Marginally) Do not reject H0* (and hence H0) at α = 0.05.
15
General formula for the test
2 × t contingency table:
Category: 1 2 3 … k Total
A A1 A2 A3 … Ak m
B B1 B2 B3 … Bk n
Total d1 d2 d3 … dk N
It can be shown that
N ( N − 1) k
A 2
m 2
+
H = ∑ i
−
mn i =1 d i N
and
H + ~ χ k2−1
In our example,
100 × 99 282 152 17 2 60 2
+
H = + + − = 5.946
60 × 40 41 21 38 100 16
Question 5.3
What are the two non-parametric
methods for testing the following?
H0: H1:
X X
Y Y
17
Question 5.4
Construct a test statistic J that will
have extreme value under H1.
H0:
H1:
X X
Y Y
Z Z
18
Question 5.5
Describe how can we derive the
distribution of J under H0.
19
3. Jonckheere-Terpstra Test for Ordered Alternatives
• Population model:
X ij = µ + α i + eij i = 1,2, , k
∑α i =0
eij: independent from continuous distribution F.
• Test
H 0 : α1 = α 2 = = α k
H1 : α1 ≤ α 2 ≤ ≤ α k with at least one strict inequality.
(eg. the observations are responses from increasing dose levels.)
20
Procedure
1. Compute Mann-Whitney statistic Uuv (u < v) for all k (k – 1)/2
pairs of samples
Xi – u th sample
U uv = # ( X i , Y j ) with X i < Y j
Yj – v th sample
2. J = ∑ ∑ U uv
u <v
3. Large J is evidence in favor of H1.
k
J can be computed from the joint rankings of all N = ∑ ni observations.
i =1
N!
Exact distribution of J: Under H0 , all n1! nk !
rank assignments are
equally likely. (Table A.8 of Hollander & Wolfe).
21
Large sample approximation:
J is approximately normal for large sample size
2 k 2
E ( J ) = N − ∑ ni / 4,
i =1
2 k
Var ( J ) = N (2 N + 3) − ∑ ni2 (2ni + 3) / 72
i =1
22
Example
Weight gain of three diets:
A 99 114 116 127 146
B 111 125 143 148 157
C 133 139 149 160 184
H0: no difference
H1: Weight gain in A ≤ weight gain in B ≤ weight gain in C
with at least one strict inequality.
3× 2
Need to calculate = 3 Mann-Whitney Statistics
2
UAB = 18
UAC = 23 J = 18 + 18 + 23 = 59
UBC = 18
Table A.8 :
From Table A.8 (k=3, n=5,5,5, p.321) k = 3,4,5,6
Pr(J ≥ 59) = 0.012 2 ≤ n1 ≤ n2 ≤ n3 ≤ 8 23
∴ Reject H0 at α = 0.05.
When using large sample approximation
E ( J ) = (152 − 3 × 52 ) / 4
= 37.5
Var ( J ) = (152 (30 + 3) − 3 × 52 (10 + 3)) / 72
= 89.58
J − E( J ) J − 0. 5 − E ( J )
∴ = 2.27 ∴ = 2.22
Var ( J ) Var ( J )
∴ Pr( N (0,1) ≥ 2.27) = 0.0116 withou t continutiy correction
∴ Pr( N (0,1) ≥ 2.22) = 0.0132 with continuity correction
Close to the exact p-value 0.012.
24
Ties
Use U = ∑ ∑ φ ( xi , y j )
i j
where
1 if a < b
φ ( a, b) = 0 if a > b
1 if a = b
2
Correction for ties to variance
- Very tedious
(see Lehmann, p.235 for detail)
25
4. Online resource
A detailed description of Kruskal-Wallis Test:
[Link]
26