Chapter 12
Chapter 12
Chapter 12
Chapter 12
Chi Square Tests and Nonparametric
Tests
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-1
Learning Objectives
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-2
Contingency Tables
Contingency Tables
Useful in situations involving multiple
population proportions
Used to classify sample observations
according to two or more characteristics
Also called a cross-classification table.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-3
Contingency Table Example
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-5
Contingency Table Example
H0: π1 = π2 (Proportion of females who are left
handed is equal to the proportion of
males who are left handed)
H1: π1 ≠ π2 (The two proportions are not the same –
Hand preference is not independent
of gender)
If H0 is true, then the proportion of left-handed females
should be the same as the proportion of left-handed males.
The two proportions above should be the same as the
proportion of left-handed people overall.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-6
The Chi-Square Test Statistic
The Chi-square test statistic is:
2
(f f )
χ2 o e
all cells fe
where:
fo = observed frequency in a particular cell
fe = expected frequency in a particular cell if H0 is true
Decision Rule:
If 2 > 2U, reject H0,
otherwise, do not reject
H0
0
Do not Reject H0
reject H0
2U
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-8
Computing the
Average Proportion
The average X1 X 2 X
p
proportion is: n1 n2 n
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-9
Finding Expected Frequencies
To obtain the expected frequency for left handed females,
multiply the average proportion left handed (p) by the total
number of females
To obtain the expected frequency for left handed males,
multiply the average proportion left handed (p) by the total
number of males
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-10
Observed vs. Expected
Frequencies
Gender
Hand
Female Male
Preference
Observed = 12 Observed = 24
Left 36
Expected = 14.4 Expected = 21.6
Observed = 108 Observed = 156
Right 264
Expected = 105.6 Expected = 158.4
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-11
The Chi-Square Test Statistic
Gender
Hand
Female Male
Preference
Observed = 12 Observed = 24
Left 36
Expected = 14.4 Expected = 21.6
Observed = 108 Observed = 156
Right 264
Expected = 105.6 Expected = 158.4
The test statistic is: 120 180 300
( fo fe )2
2
all cells fe
(12 14.4) 2 (108 105.6) 2 (24 21.6) 2 (156 158.4) 2
0.7576
14.4 105.6 21.6 158.4
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-12
The Chi-Square Test Statistic
The test statistic is 2 0.7576 , U2 with 1 d.f. 3.841
Decision Rule:
If 2 > 3.841, reject H0, otherwise, do
not reject H0
Here,
=.05 2 = 0..7576 < 2U = 3.841,
so you do not reject H0 and
0 conclude that there is
Do not Reject H0
reject H0 insufficient evidence that the
2U=3.841 two proportions are different.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-13
2 Test for The Differences Among
More Than Two Proportions
H0: π1 = π2 = … = πc
H1: Not all of the πj are equal (j = 1, 2, …, c)
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-14
The Chi-Square Test Statistic
The Chi-square test statistic is:
2
( f f )
2 o e
all cells fe
where:
fo = observed frequency in a particular cell of the 2 x c table
fe = expected frequency in a particular cell if H 0 is true
2 for the 2 x c case has (2-1)(c-1) = c - 1 degrees of freedom
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-17
2 Test with More Than Two
Proportions: Example
Organization
Object to Insurance Pharmacies Medical
Record Companies Researchers
Sharing
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-18
2 Test with More Than Two
Proportions: Example
The overall p
X 1 X 2 ... X c 410 295 335
0.6933
proportion is: n1 n2 ... nc 500 500 500
Organization
Object to Insurance Pharmacies Medical
Record Companies Researchers
Sharing
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-22
The Marascuilo Procedure
Critical Range for the Marascuilo Procedure:
p j (1 p j ) p j / (1 p j / )
Critical Range 2
U
nj n j/
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-23
The Marascuilo Procedure
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-25
The Marascuilo Procedure
Example
MARASCUILO TABLE
Absolute
Proportions Differences Critical Range
| Group 1 - Group 2 | 0.23 0.06831808
| Group 1 - Group 3 | 0.15 0.0664689
| Group 2 - Group 3 | 0.08 0.074485617
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-26
2 Test of Independence
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-27
2 Test of Independence
The Chi-square test statistic is:
2
( f f )
2 o e
all cells fe
where:
fo = observed frequency in a particular cell of the r x c table
fe = expected frequency in a particular cell if H0 is true
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-29
Decision Rule
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-30
Example: Test of Independence
The meal plan selected by 200 students is shown below:
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-32
Example: Test of Independence
Expected cell frequencies
if H0 is true:
Number of meals
Example for one cell: per week
Class 20/wk 10/wk none
row total x column total
fe Standing Total
n
Fresh. 24.5 30.8 14.7 70
30 70
10.5 Soph. 21.0 26.4 12.6 60
200
Junior 10.5 13.2 6.3 30
Senior 14.0 17.6 8.4 40
Total 70 88 42 200
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-33
Example: Test of Independence
( fo fe )2
2
all cells fe
(24 24.5) 2 (32 30.8) 2 (10 8.4) 2
0.709
24.5 30.8 8.4
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-34
Example: Test of
Independence
The test statistic is 2 0.709 , U2 with 6 d.f. 12.592
Decision Rule:
If 2 > 12.592, reject H0, otherwise,
do not reject H0
Here,
=0.05 2 = 0.709 < 2U = 12.592,
so do not reject H0
0 Conclusion: there is
Do not Reject H0 insufficient evidence that meal
reject H0
2U=12.592 plan and class standing are
related.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-35
McNemar Test
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-36
McNemar Test
Contingency Table
Condition (Group) 2
Condition (Group) 1 Yes No Totals
Yes A B A+B
No C D C+D
Totals A+C B+D n
Yes A B A+B
No C D C+D
Totals A+C B+D n
A B AC
p1 p2
n n
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-38
McNemar Test
Contingency Table
Condition (Group) 2
Condition (Group) 1 Yes No Totals
Yes A B A+B
No C D C+D
Totals A+C B+D n
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-39
McNemar Test
Test Statistic
To test the hypothesis:
H0: π1 = π2
H1: π1 ≠ π2
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-40
McNemar Test
Example
Suppose you survey 300 homeowners and ask
them if they are interested in refinancing their
home. In an effort to generate business, a
mortgage company improved their loan terms and
reduced closing costs. The same homeowners
were again surveyed. Determine if change in loan
terms was effective in generating business for the
mortgage company. The data are summarized as
follows:
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-41
McNemar Test
Example
Survey response after change
Survey response Yes No Totals
before change
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-42
McNemar Test
Example
Survey response after The critical value (.05
Survey change significance) is Z = -1.96
response Yes No Totals
before change The test statistic is:
B C 2 22
Z 4.08
Yes 118 2 120 B C 2 22
No 22 158 180
Totals 140 160 300
Since Z = -4.08 < -1.96, you reject H0 and conclude that the
change in loan terms significantly increase business for the
mortgage company.
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-43
Wilcoxon Rank-Sum Test
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-44
Wilcoxon Rank-Sum Test
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-45
Checking the Rankings
n(n 1)
T1 T2
2
where n = n1 + n2
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-46
Wilcoxon Rank-Sum Test
Hypothesis and Decision
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
T1 = 24.5
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-53
Wilcoxon Rank-Sum Test
Using Normal Approximation
The Z test statistic is
T1 μ T1
Z
σT1
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-54
Wilcoxon Rank-Sum Test
Using Normal Approximation
Use the setting of the prior example:
The sample sizes were:
n1 = 4 (factory B)
n2 = 5 (factory A)
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-55
Wilcoxon Rank-Sum Test
Using Normal Approximation
n1(n 1) 4(9 1)
μT1 20
2 2
n1 n2 (n 1) 4 (5) (9 1)
σT1 4.082
12 12
The test statistic is
T1 μ T1 24.5 20
Z 1.10
σT1 4.082
Z = 1.10 is less than the critical Z value of 1.96 (for α = .05)
so you do not reject H0 – there is not sufficient evidence that
the medians are not equal
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-56
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
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-57
Kruskal-Wallis Rank Test
Obtain overall 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
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-58
Kruskal-Wallis Rank Test
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 = total number of values over the combined samples
c = Number of groups
Tj = Sum of ranks in the jth sample
nj = Size of the jth sample
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-59
Kruskal-Wallis Rank Test
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
0 Otherwise do not reject H0
Do not Reject H0
reject H0
2U
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-60
Kruskal-Wallis Rank Test
Example
Do different branch offices have a different number of
employees?
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-61
Kruskal-Wallis Rank Test
Example
Do different branch offices have a different
number of employees?
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
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-62
Kruskal-Wallis Rank Test
Example
H 0 : Median C Median D Median H
H A : Not all population Medians are equal
The H statistic is
12 c T2
H j
3(n 1)
n(n 1) j 1 n j
12 44 2 56 2 20 2
3(15 1) 6.72
15(15 1) 5 5 5
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-63
Kruskal-Wallis Rank Test
Example
Compare H = 6.72 to the critical value from the chi-square
distribution for 3 – 1 = 2 degrees of freedom and = .05:
2
χ 5.991
U
2
Since H = 6.72 >U 5.991
χ ,
reject H0
Statistics for Managers Using Microsoft Excel, 5e © 2008 Prentice-Hall, Inc. Chap 12-65