Download as pdf or txt
Download as pdf or txt
You are on page 1of 25

Wilcoxon Rank-Sum Test for

Differences in 2 Medians

2020
Wilcoxon Rank-Sum Test for Differences
in 2 Medians

• Test two independent population medians


• Populations need not be normally distributed
• Distribution free procedure
• Used when only rank data are available
• Must use normal approximation if either of the
sample sizes is larger than 10

2020
Wilcoxon Rank-Sum Test: Small Samples
• Can use when both n1 , n2 ≤ 10
• Assign ranks to the combined n1 + n2 sample
observations
• If unequal sample sizes, let n1 refer to smaller-sized sample
• Smallest value rank = 1, largest value rank = n1 + n2
• Assign average rank for ties
• Sum the ranks for each sample: T1 and T2
• Obtain test statistic, T1 (from smaller sample)

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-3 / 47
Checking the Rankings

• The sum of the rankings must satisfy the formula


below
• Can use this to verify the sums T1 and T2

n(n + 1)
T1 + T2 =
2

where n = n1 + n2

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-4 / 47
Wilcoxon Rank-Sum Test:
Hypothesis and Decision Rule
M1 = median of population 1; M2 = median of population 2

Test statistic = T1 (Sum of ranks from smaller sample)

Two-Tail Test Left-Tail Test Right-Tail Test


H0: M1 = M2 H0: M1  M2 H0: M1  M2
H1: M1  M2 H1: M1 < M2 H1: M1 > M2

Reject Do Not Reject Reject Do Not Reject Do Not Reject Reject


Reject
T1L T1U T1L T1U

Reject H0 if T1 < T1L


or if T1 > T1U Reject H0 if T1 < T1L Reject H0 if T1 > T1U

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-5 / 47
Wilcoxon Rank-Sum Test: Small Sample
Example
Sample data is collected on the capacity rates (% of
capacity) for two factories.
Are the median operating rates for two factories the
same?
• For factory A, the rates are 71, 82, 77, 94, 88
• For factory B, the rates are 85, 82, 92, 97
Test for equality of the sample medians
at the 0.05 significance level

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-6 / 47
Capacity Rank
Ranked Factory A Factory B Factory A Factory B
Capacity 71 1
values: 77 2
82 3.5
Tie in 3rd and 82 3.5
4th places 85 5
88 6
92 7
94 8
97 9
Rank Sums: 20.5 24.5

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-7 / 47
Wilcoxon Rank-Sum Test: Small Sample
Example
Factory B has the smaller sample size, so
the test statistic is the sum of the
Factory B ranks:
T1 = 24.5

The sample sizes are:


n1 = 4 (factory B)
n2 = 5 (factory A)
The level of significance is α = .05

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-8 / 47
T1L = 11
and T1U = 29
10
a = .05 Test Statistic (Sum of
n1 = 4 , n2 = 5 ranks from smaller sample):
Two-Tail Test
T1 = 24.5
H0: M1 = M2
H1: M1  M2

Decision:
Reject Do Not Reject
Do not reject at a = 0.05
Reject
T1L=11 T1U=29 Conclusion:
There is not enough evidence to prove that the
Reject H0 if T1 < T1L=11 medians are not equal.
or if T1 > T1U=29

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-11 / 47
Wilcoxon Rank-Sum Test
(Large Sample)
• For large samples, the test statistic T1 is approximately normal with
mean μT and standard deviation σ T1 :
1

n1(n + 1) n1 n2 (n + 1)
μT1 = σ T1 =
2 12

• Must use the normal approximation if either n1


or n2 > 10
• Assign n1 to be the smaller of the two sample sizes
• Can use the normal approximation for small samples

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-12 / 47
Wilcoxon Rank-Sum Test
(Large Sample)

• The Z test statistic is

T1 − μT1
Z=
σ T1

• Where Z approximately follows a standardized


normal distribution

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-13 / 47
Wilcoxon Rank-Sum Test: Normal
Approximation Example
Use the setting of the prior example:
The sample sizes were:
n1 = 4 (factory B)
n2 = 5 (factory A)
The level of significance was α = .05

The test statistic was T1 = 24.5

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-14 / 47
Wilcoxon Rank-Sum Test:
Normal Approximation Example
n1(n + 1) 4(9 + 1)
μT1 = = = 20
2 2

n1 n2 (n + 1) 4 (5) (9 + 1)
σ T1 = = = 2.739
12 12

• The test statistic is

T1 − μT1 24.5 − 20
Z= = = 1.64
σ T1 2.739
Z = 1.64 is not greater than the critical Z value of 1.96 (for α = .05) so we
do not reject H0 – there is not sufficient evidence that the medians are not
equal

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-15 / 47
Kruskal-Wallis Rank Test

•Tests the equality of more than 2 population


medians
•Use when the normality assumption for one-
way ANOVA is violated
•Assumptions:
• The samples are random and independent
• variables have a continuous distribution
• the data can be ranked
• populations have the same variability
• populations have the same shape

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-16 / 47
Kruskal-Wallis Test Procedure
•Obtain relative rankings for each value
•In event of tie, each of the tied values gets
the average rank
•Sum the rankings for data from each of
the c
groups
•Compute the H test statistic

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-17 / 47
•The Kruskal-Wallis H test statistic:
(with c – 1 degrees of freedom)
 12 c T2 
H=   j
 − 3(n + 1)
 n(n + 1) j=1 n j 

where:
n = sum of sample sizes in all samples
c = Number of samples
Tj = Sum of ranks in the jth sample
nj = Size of the jth sample

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-18 / 47
Complete the test by comparing the
calculated H value to a critical 2 value from
the chi-square distribution with c – 1 degrees
of freedom
• Decision rule
• Reject H0 if test statistic H > 2U
• Otherwise do not reject H0

0
Do not reject H0 Reject H0 2
2U

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-19 / 47
20
Kruskal-Wallis Example
• Do different departments have different class sizes?

Class size Class size Class size


(Math, M) (English, E) (Biology, B)
23 55 30
45 60 40
54 72 18
78 45 34
66 70 44

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-21 / 47
• Do different departments have different class sizes?

Class size Class size Class size


Ranking Ranking Ranking
(Math, M) (English, E) (Biology, B)
23 2 55 10 30 3
41 6 60 11 40 5
54 9 72 14 18 1
78 15 45 8 34 4
66 12 70 13 44 7
 = 44  = 56  = 20

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-22 / 47
H0 : MedianM = MedianE = MedianH
HA : Not all population Medians are equal

• The H statistic is

 12 c R2 
H=   j
 − 3(n + 1)
 n(n + 1) j=1 n j 

 12  442 562 202 


=  + +  − 3(15 + 1) = 6.72
15(15 + 1)  5 5 5 

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-23 / 47
n Compare H = 6.72 to the critical value from the
chi-square distribution for 3 – 1 = 2 degrees of
freedom and a = .05:
 = 95.991
2
U .4877

Since H = 6.72 >  = 95.991


2
.4877 U

reject H0
There is sufficient evidence to reject that the population
medians are all equal

STK211 Metode Statistika / Statistical Methods © 2004 Prentice-Hall, Inc.


2020 Week 12-24 / 47
Chapter Summary
• Developed and applied the 2 test for the difference
between two proportions
• Developed and applied the 2 test for differences in
more than two proportions
• Examined the 2 test for independence
• Used the Wilcoxon rank sum test for two population
medians
• Small Samples
• Large sample Z approximation
• Applied the Kruskal-Wallis H-test for multiple
population medians
2020

You might also like