chap18_2010

advertisement
Chapter 18
Chi-Square Tests
2 Distribution
• Let x1, x2, .. xn be a random sample from a normal distribution
with  and 2, and let s2 be the sample variance, then the
random variable (n-1)s2/2 has 2 distribution with n-1 degrees
of freedom.
• Probability Density Function, with k degrees of freedom,
f (x) 
• Mean
• Variance
1
k
2 2 (k 2)
x ( k / 2 )1e  x / 2
E( x )  k
V ( x )  2k
• Mode = k-2 (when k 3)
x 0
2 Distribution
fr.academic.ru/pictures/frwiki/67/Chi-square_..
2 Distribution
• Goodness-of-fit Tests
• Tests of Independence
• Tests of Homogeneity
Multinominal Experiments
A Multinomial experiment is a statistical experiment that has
the following properties:
• It consists of n repeated trials (repetitions).
• Each trial can result in one of k possible outcomes.
• The trials are independent.
• The probabilities of the various events remain constant for
each trial.
Goodness-of-fit Test
• Observed Frequencies (Oi): Frequencies obtained from the
actual performance of an experiment.
• Goodness-of-fit Test: Test of null hypothesis that the
observed frequencies follow certain pattern or theoretical
distributions, expressed by the Expected Frequencies (Ei).
Goodness-of-fit Test
for Multinominal Experiments
2
(
O

E
)
i
 02   i
Ei
i 1
k
• Degree of freedom = k -1, where k is the number of
categories
• Chi-square goodness-of-fit test is always a right-tailed test
• Sample size should be large enough so that the expected
frequency for each category is at least 5.
Goodness-of-fit Test
for Multinominal Experiments
• Null Hypothesis: H0: the observed frequencies follow
certain pattern
• Test statistic:
2
k
(
O

E
)
i
 02   i
Ei
i 1
• Degree of Freedom = k -1
Alt. Hypothesis
H1
P-value
P(2>02)
Rejection Criterion
02 > 2,k-1
Goodness-of-fit Test for Multinominal
Experiments -- Example 18.1
•
•
•
•
•
Department stores in shopping mall
H0: p1 = p2 = p3 = p4 = p5 = .20
1
H1: At least 2 of pi  .20
2
 = .01, df = 5 -1 = 4
3
4
Test statistic:
(Oi  Ei )2
 
 19.79
Ei
i 1
k
2
0
• Critical value: .01,4 = 13.276
• P-value = .000549
• Reject H0
Oi
214
231
182
219
5 154
Ei Oi-Ei (Oi-Ei)2 (Oi-Ei)2/Ei
200 14 196
0.98
200 31 961
4.81
200 -18 324
1.62
200 19 361
1.81
200 -46 2116
10.58
19.79
Goodness-of-fit Test for Multinominal
Experiments -- Example 18.2
•
•
•
•
•
Market shares
H0: p1=.144, p2=.181, p3=.248, p4=.141, p5=.149, p6 =.137
H1: At least 2 of pi are different
Oi Ei Oi-Ei (Oi-Ei)2 (Oi-Ei)2/Ei
 = .025, df = 6 -1 = 5
1 270 288 -18
324 1.1250
2 382 362
20
400 1.1050
Test statistic:
(Oi  Ei )2
 
 8.6197
Ei
i 1
k
2
0
• Critical value: .025,5 = 12.8325
• P-value = .1252
• Fail to reject H0
3
4
5
6
467
317
288
276
2000
496
282
298
274
-29
35
-10
2
841
1225
100
4
1.6956
4.3440
0.3356
0.0146
8.6197
Test of Independence
for a Contingency Table
• Contingency Table
Columns
Rows
1
2
…
c
1
O11
O12
…
O1c
u1
2
O21
O22
…
O2c
u2
…
…
…
…
…
…
r
Or1
Or2
…
Orc
ur
1
2
1 r
ˆ j   Oij
n i 1
1 c
uˆi   Oij
n j 1
c
r
1 c
Eij  nuˆiˆ j  Oij Oij
n j 1 i 1
Test of Independence
for a Contingency Table
• Null Hypothesis: H0: The two attributes are independent
• Alt. Hypothesis: H1: The two attributes are dependent
• Test statistic:
r
c (O  E )2
ij
 02   ij
Eij
i 1 j 1
• Degree of Freedom = (r-1)(c-1)
Alt. Hypothesis
P-value
Rejection Criterion
H1
P(2>02)
02 > 2,df
Test of Independence for a
Contingency Table – Example 18.3
• Contingency Table
Oij
Support
Against
No Opinion
Total
ui
Female
87
32
6
125
.4167
Male
93
70
12
175
.5833
Total
180
102
18
300
j
.60
.34
.06
Eij
Support
Against
No Opinion
Female
75
42.5
7.5
Male
105
59.5
10.5
1 c
uˆi   Oij
n j 1
1 r
ˆ j   Oij
n i 1
r
1 c
Eij  nuˆiˆ j  Oij Oij
n j 1 i 1
Test of Independence for a
Contingency Table – Example 18.4
• Null Hypothesis: H0: The two attributes are independent
• Alt. Hypothesis: H1: The two attributes are dependent
• Test statistic: r c
2
(
O

E
)
ij
 02   ij
 8.2528
Eij
i 1 j 1
•
•
•
•
Degree of Freedom = (r-1)(c-1) = (2-1)(3-1) = 2
Critical value: .025,2 = 7.3778
P-value = .0161
Reject H0
Test of Independence for a
Contingency Table – Example 18.5
• Contingency Table
Oij
Good
Defective
Total
ui
Mac 1
109
11
120
.6
Mac 2
66
14
80
.4
Total
175
25
200
j
.875
.125
Eij
Good
Defective
Mac 1
105
15
Mac 2
70
10
1 c
uˆi   Oij
n j 1
1 r
ˆ j   Oij
n i 1
r
1 c
Eij  nuˆiˆ j  Oij Oij
n j 1 i 1
Test of Independence for a
Contingency Table – Example 18.5
• Null Hypothesis: H0: The two attributes are independent
• Alt. Hypothesis: H1: The two attributes are dependent
• Test statistic: r c
2
(
O

E
)
ij
 02   ij
 3.0476
Eij
i 1 j 1
•
•
•
•
Degree of Freedom = (r-1)(c-1) = (2-1)(2-1) = 1
Critical value: .01,1 = 6.6349
P-value = .0809
Fail to reject H0
Test of Homogeneity
• Similar to the test of independence
• If row/column totals are fixed, perform a test of homogeneity
Columns
Rows
1
2
…
c
1
O11
O12
…
O1c
u1
2
O21
O22
…
O2c
u2
…
…
…
…
…
…
r
Or1
Or2
…
Orc
ur
1
2
1 r
ˆ j   Oij
n i 1
1 c
uˆi   Oij
n j 1
c
r
1 c
Eij  nuˆiˆ j  Oij Oij
n j 1 i 1
Test of Homogeneity
• Null Hypothesis: H0: two sets of data are homogeneous
• Alt. Hypothesis: H1: sets of data are not homogeneous
• Test statistic:
r
c (O  E )2
ij
 02   ij
Eij
i 1 j 1
• Degree of Freedom = (r-1)(c-1)
Alt. Hypothesis
P-value
Rejection Criterion
H1
P(2>02)
02 > 2,df
Test of Independence for a
Contingency Table – Example 18.6
• Contingency Table
Oij
Calif.
NY
Total
ui
Eij
Very Satis.
60
75
135
.15
Somewhat Sat.
100
125
225
Somewhat Dissat.
184
140
Very Dissatis.
156
Total
j
Calif.
NY
Very Satis.
75
60
.25
Somewhat Sat.
125
100
324
.36
Somewhat Dissat.
180
144
60
216
.24
Very Dissatis.
120
96
500
400
900
.556
.444
Test of Independence for a
Contingency Table – Example 18.6
• Null Hypothesis: H0: The two states are homogeneous
• Alt. Hypothesis: H1: The two states are not homogeneous
• Test statistic: r c
2
(
O

E
)
ij
 02   ij
 42.50
Eij
i 1 j 1
•
•
•
•
Degree of Freedom = (r-1)(c-1) = (4-1)(2-1) = 3
Critical value: .025,3 = 9.3484
P-value = 3.1424E-9
Reject H0
Download