Logit Analysis of Contingency Tables
Logit Analysis of Contingency Tables
Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
CHAPTER 2: BINARY LOGIT ANALYSIS OF
CONTINGENCY TABLES
Prof. Alan Wan
1 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Table of contents
1. Introduction
2. Two-way classication and PROC GENMOD
2.1. PROC GENMOD: frequency weight syntax
2.2. PROC GENMOD: event/trial syntax
3. Three-way classication
4. Class exercises
2 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Introduction
Here is an example:
Annual changes
in stock prices
Up Down Total
January changes Up 22(16.1) 1(6.9) 23
in stock prices Down 6(11.9) 11(5.1) 17
Total 28 12 40
3 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Introduction
Here is an example:
Annual changes
in stock prices
Up Down Total
January changes Up 22(16.1) 1(6.9) 23
in stock prices Down 6(11.9) 11(5.1) 17
Total 28 12 40
3 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Introduction
s
2
=
n
i =1
(O
i
E
i
)
2
E
i
2
(r 1)(c1)
, where r and c
are the numbers of rows and columns in the table respectively;
4
i =1
(2216.1)
2
16.1
+
(16.9)
2
6.9
+
(611.9)
2
11.9
+
(115.1)
2
5.1
= 16.96;
Now,
2
1,0.05
= 3.84. Hence we reject H
0
and conclude that
stock price movements during the whole year are not
independent of their movements in January of the year.
6 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Introduction
data stock;
input f yp jp;
datalines;
22 1 1
6 1 0
1 0 1
11 0 0
;
proc freq data=stock;
weight f;
tables yp*jp/chisq cmh;
run;
Statistics for Table of yp by jp
Statistic DF Value Prob
Chi-Square 1 16.9577 <.0001
Likelihood Ratio Chi-Square 1 18.5678 <.0001
Continuity Adj. Chi-Square 1 14.2053 0.0002
Mantel-Haenszel Chi-Square 1 16.5338 <.0001
Phi Coefficient 0.6511
Contingency Coefficient 0.5456
Cramer's V 0.6511
7 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
2.1. PROC GENMOD: frequency weight syntax
2.2. PROC GENMOD: event/trial syntax
PROC GENMOD: frequency weight syntax
Deviance = 2[lnL(
S
) lnL(
E
)]
2
m
,
where m is the dierence in the number of parameters
between the saturated and the estimated models;
S
) = 1,
lnL(
S
) = 0 and Deviance = 2[lnL(
E
)].
13 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
2.1. PROC GENMOD: frequency weight syntax
2.2. PROC GENMOD: event/trial syntax
PROC GENMOD: event/trial syntax
DATA CONT1;
INPUT DEATH TOTAL BLACKD;
DATALINES;
22 74 0
28 73 1
;
PROC GENMOD DATA=CONT1;
MODEL DEATH/TOTAL=BLACKD/D=B;
RUN;
14 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
2.1. PROC GENMOD: frequency weight syntax
2.2. PROC GENMOD: event/trial syntax
PROC GENMOD: event/trial syntax
The GENMOD Procedure
Model Information
Data Set WORK.CONT1
Distribution Binomial
Link Function Logit
Response Variable (Events) DEATH
Response Variable (Trials) TOTAL
Observations Used 2
Number Of Events 50
Number Of Trials 147
Criteria For Assessing Goodness Of Fit
Criterion DF Value Value/DF
Deviance 0 0.0000 .
Scaled Deviance 0 0.0000 .
Pearson Chi-Square 0 0.0000 .
Scaled Pearson X2 0 0.0000 .
Log Likelihood -93.6352
Algorithm converged.
Analysis Of Parameter Estimates
Standard Wald 95% Confidence Chi-
Parameter DF Estimate Error Limits Square Pr > ChiSq
Intercept 1 -0.8602 0.2543 -1.3587 -0.3617 11.44 0.0007
BLACKD 1 0.3857 0.3502 -0.3006 1.0721 1.21 0.2706
Scale 0 1.0000 0.0000 1.0000 1.0000
NOTE: The scale parameter was held fixed.
15 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
2.1. PROC GENMOD: frequency weight syntax
2.2. PROC GENMOD: event/trial syntax
i =1
[
1
1 + e
(
1
+
2
BLACKD
i
)
]
DEATH
i
[1
1
1 + e
(
1
+
2
BLACKD
i
)
]
1DEATH
i
Estimated model:
p
i
=
1
1 + e
(
1
+
2
WHITE
i
+
3
MALE
i
)
Saturated model:
p
i
=
1
1 + e
(
1
+
2
WHITE
i
+
3
MALE
i
+
4
WHITE
i
MALE
i
)
22 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Three-way classication
Estimated model:
p
i
=
1
1 + e
(
1
+
2
WHITE
i
+
3
MALE
i
)
Saturated model:
p
i
=
1
1 + e
(
1
+
2
WHITE
i
+
3
MALE
i
+
4
WHITE
i
MALE
i
)
22 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Three-way classication
To see this more clearly, let us t the model explicitly with the
interaction term:
DATA DRIVER;
INPUT WHITE MALE YES NO;
TOTAL = YES+NO;
DATALINES;
1 1 43 134
1 0 26 149
0 1 29 23
0 0 22 36
;
PROC GENMOD DATA=DRIVER;
MODEL YES/TOTAL=WHITE MALE WHITE*MALE/D=B;
RUN;
24 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Three-way classication
The GENMOD Procedure
Model Information
Data Set WORK.DRIVER
Distribution Binomial
Link Function Logit
Response Variable (Events) YES
Response Variable (Trials) TOTAL
Observations Used 4
Number Of Events 120
Number Of Trials 462
Criteria For Assessing Goodness Of Fit
Criterion DF Value Value/DF
Deviance 0 0.0000 .
Scaled Deviance 0 0.0000 .
Pearson Chi-Square 0 0.0000 .
Scaled Pearson X2 0 0.0000 .
Log Likelihood -245.8682
Algorithm converged.
Analysis Of Parameter Estimates
Standard Wald 95% Confidence Chi-
Parameter DF Estimate Error Limits Square Pr > ChiSq
Intercept 1 -0.4925 0.2706 -1.0229 0.0379 3.31 0.0688
WHITE 1 -1.2534 0.3441 -1.9278 -0.5789 13.27 0.0003
MALE 1 0.7243 0.3888 -0.0378 1.4864 3.47 0.0625
WHITE*MALE 1 -0.1151 0.4765 -1.0491 0.8189 0.06 0.8092
Scale 0 1.0000 0.0000 1.0000 1.0000
NOTE: The scale parameter was held fixed.
25 / 29
1. Introduction
2. Two-way classication and PROC GENMOD
3. Three-way classication
4. Class exercises
Three-way classication
Now, to test H
0
:
4
= 0 vs. H
1
: otherwise, we apply the LR
test:
Deviance = 2(245.8682 245.8974)
= 0.0584