Professional Documents
Culture Documents
Hypothesis Testing: Categorical Data Analysis
Hypothesis Testing: Categorical Data Analysis
EPI809/Spring 2008
Learning Objectives
1.
2.
3.
4.
5.
Kappa Statistic
6.
Data Types
Data
Data
Quantitative
Quantitative
Discrete
Discrete
Qualitative
Qualitative
Continuous
Continuous
EPI809/Spring 2008
Qualitative Data
1.
2.
3.
4.
Hypothesis Tests
Qualitative Data
Qualitative
Qualitative
Data
Data
11pop.
pop.
22orormore
more
pop.
pop.
Proportion
Proportion
Independence
Independence
22pop.
pop.
ZZTest
Test
ZZTest
Test
22 Test
Test
EPI809/Spring 2008
22 Test
Test
EPI809/Spring 2008
Hypotheses for
Two Proportions
EPI809/Spring 2008
Hypotheses for
Two Proportions
Research Questions
Hypothesis No Difference
Any Difference
Pop 1 Pop 2
Pop 1 < Pop 2
Pop 1 Pop 2
Pop 1 > Pop 2
H0
Ha
EPI809/Spring 2008
Hypotheses for
Two Proportions
Research Questions
Hypothesis No Difference
Any Difference
H0
Ha
Pop 1 Pop 2
Pop 1 < Pop 2
Pop 1 Pop 2
Pop 1 > Pop 2
p1 - p2 = 0
p1 - p2 0
EPI809/Spring 2008
Hypotheses for
Two Proportions
Research Questions
Hypothesis No Difference
Any Difference
H0
Ha
p1 - p2 = 0
p1 - p2 0
Pop 1 Pop 2
Pop 1 < Pop 2
Pop 1 Pop 2
Pop 1 > Pop 2
p1 - p2 0
p1 - p2 < 0
EPI809/Spring 2008
10
Hypotheses for
Two Proportions
Research Questions
Hypothesis No Difference
Any Difference
H0
Ha
p1 - p2 = 0
p1 - p2 0
Pop 1 Pop 2
Pop 1 < Pop 2
Pop 1 Pop 2
Pop 1 > Pop 2
p1 - p2 0
p1 - p2 < 0
p1 - p2 0
p1 - p2 > 0
EPI809/Spring 2008
11
Hypotheses for
Two Proportions
Research Questions
Hypothesis No Difference
Any Difference
H0
Ha
p1 - p2 = 0
p1 - p2 0
Pop 1 Pop 2
Pop 1 < Pop 2
Pop 1 Pop 2
Pop 1 > Pop 2
p1 - p2 0
p1 - p2 < 0
p1 - p2 0
p1 - p2 > 0
EPI809/Spring 2008
12
2.
p1 p 2 p1 p2
1 1
p 1 p
n1 n2
where p
EPI809/Spring 2008
X1 X 2
n1 n2
13
12 22
X 1 X 2 ~ N 1 2 ;
n1 n2
p1 1 p1 p2 1 p2
p1 p2 N p1 p2 ;
n
n
1
2
1 1
N 0; pq
under H 0 : p1 p2
n1 n2
x x
p 1 2,
n1 n2
EPI809/Spring 2008
14
CA
15
EPI809/Spring 2008
16
Test Statistic:
Decision:
Conclusion:
EPI809/Spring 2008
17
Decision:
Conclusion:
EPI809/Spring 2008
18
Decision:
Conclusion:
EPI809/Spring 2008
19
.05
-1.645
Decision:
Conclusion:
Z
EPI809/Spring 2008
20
.0493
nMA 1500
X CA 129
p CA
.0860
nCA 1500
X MA X CA
74 129
p
.0677
nMA nCA 1500 1500
Z
.0493 .0860 0
1
1
.0677 1 .0677
1500 1500
4.00
EPI809/Spring 2008
21
.05
-1.645
Decision:
Conclusion:
Z
EPI809/Spring 2008
22
Decision:
Reject at = .05
.05
Conclusion:
-1.645
Z
EPI809/Spring 2008
23
.05
-1.645
Decision:
Reject at = .05
Conclusion:
There is evidence MA
is less than CA
EPI809/Spring 2008
24
2 Test of Independence
Between 2 Categorical
Variables
EPI809/Spring 2008
25
Hypothesis Tests
Qualitative Data
Qualitative
Qualitative
Data
Data
11pop.
pop.
22orormore
more
pop.
pop.
Proportion
Proportion
Independence
Independence
22pop.
pop.
ZZTest
Test
ZZTest
Test
22 Test
Test
EPI809/Spring 2008
22 Test
Test
26
Test of Independence
2
27
Test of Independence
Contingency Table
2
1.
EPI809/Spring 2008
28
Test of Independence
Contingency Table
2
Levels of variable 1
EPI809/Spring 2008
29
Test of Independence
Hypotheses & Statistic
2
1.Hypotheses
EPI809/Spring 2008
30
Test of Independence
Hypotheses & Statistic
2
1.Hypotheses
H0: Variables Are Independent
Ha: Variables Are Related (Dependent)
2.Test Statistic
2
all cells
Observed count
ch
ch
nij E nij
E n
Expected
count
ij
EPI809/Spring 2008
31
Test of Independence
Hypotheses & Statistic
2
1.Hypotheses
H0: Variables Are Independent
Ha: Variables Are Related (Dependent)
2.Test Statistic
2
all cells
Observed count
ch
ch
nij E nij
E n
ij
Expected
count
Rows Columns
32
2 Test of Independence
Expected Counts
EPI809/Spring 2008
33
EPI809/Spring 2008
34
EPI809/Spring 2008
35
78
Marginal probability =
160
EPI809/Spring 2008
36
78
Marginal probability =
160
EPI809/Spring 2008
37
112 78
Expected count = 160
78
160 160
Marginal probability =
160
= 54.6
EPI809/Spring 2008
38
EPI809/Spring 2008
39
EPI809/Spring 2008
40
112x78
160
112x82
160
48x78
160
EPI809/Spring 2008
48x82
160
41
Test of Independence
Example on HIV
2
EPI809/Spring 2008
42
2 Test of Independence
Solution
EPI809/Spring 2008
43
2 Test of Independence
Solution
H0:
Ha:
=
df =
Critical Value(s):
Test Statistic:
Decision:
Reject
Conclusion:
0
EPI809/Spring 2008
44
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
=
df =
Critical Value(s):
Test Statistic:
Decision:
Reject
Conclusion:
0
EPI809/Spring 2008
45
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
= .05
df = (2 - 1)(2 - 1) = 1
Critical Value(s):
Test Statistic:
Decision:
Reject
Conclusion:
0
EPI809/Spring 2008
46
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
= .05
df = (2 - 1)(2 - 1) = 1
Critical Value(s):
Test Statistic:
Decision:
Reject
= .05
0
3.841
Conclusion:
EPI809/Spring 2008
47
2 Test of Independence
Solution
E(nij) 5 in all
cells
116x132
286
154x116
286
170x132
286
EPI809/Spring 2008
170x154
286
48
2 Test of Independence
Solution
2
all cells
af
af
n11 E n11
E n
11
84 53.5
53.5
ch
ch
nij E nij
E n
ij
af
af
n12 E n12
E n
12
af
af
n22 E n22
E n
32 62.5
122 91.5
62.5
91.5
EPI809/Spring 2008
22
54.29
49
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
= .05
df = (2 - 1)(2 - 1) = 1
Critical Value(s):
Test Statistic:
2 = 54.29
Decision:
Reject
= .05
0
3.841
Conclusion:
EPI809/Spring 2008
50
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
= .05
df = (2 - 1)(2 - 1) = 1
Critical Value(s):
Reject
= .05
0
3.841
Test Statistic:
2 = 54.29
Decision:
Reject at = .05
Conclusion:
EPI809/Spring 2008
51
2 Test of Independence
Solution
H0: No Relationship
Ha: Relationship
= .05
df = (2 - 1)(2 - 1) = 1
Critical Value(s):
Reject
= .05
0
3.841
Test Statistic:
2 = 54.29
Decision:
Reject at = .05
Conclusion:
There is evidence of a
relationship
EPI809/Spring 2008
52
2 Test of Independence
SAS CODES
Data dis;
input STDs HIV count;
cards;
1 1 84
1 2 32
2 1 48
2 2 122
;
run;
Proc freq data=dis order=data;
weight Count;
tables STDs*HIV/chisq;
run;
EPI809/Spring 2008
53
2 Test of Independence
SAS OUTPUT
Statistics for Table of STDs by HIV
54.1502
Statistic
DF
Value
Prob
------------------------------------------------------Chi-Square
1
<.0001
Likelihood Ratio Chi-Square
1
55.7826
<.0001
Continuity Adj. Chi-Square
1
52.3871
<.0001
Mantel-Haenszel Chi-Square
1
53.9609
<.0001
Phi Coefficient
0.4351
Contingency Coefficient
0.3990
Cramer's V
0.4351
EPI809/Spring 2008
54