Professional Documents
Culture Documents
Lecture 3 - Testing Independence 2 Way Contingency Tables
Lecture 3 - Testing Independence 2 Way Contingency Tables
STAT 63103
Lecture 03 – Testing independence for two way
contingency tables
Niroshan Withanage
niroshan@sjp.ac.lk
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
Association for ordinal data
Association for dependent samples
Outline
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Chi-Squared test
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
where
oij is the observed cell count in the ith row and jth column of
the table
eij is the expected cell count in the ith row and jth column of
the table, computed as
i th row total × j th column total
eij = i = 1, · · · , r ; j = 1, · · · , c.
Grand total
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Decision rule
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
G 2 = −2log (Λ)
where µ̂ Niroshan
be the expected
Withanage frequency STAT
niroshan@sjp.ac.lk under HLecture
63103 0 (proof later).
03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Note:
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Chi-Squared test
Association for nomonal variable
Likelihood ratio test
Association for ordinal data
Comparing test statistics
Association for dependent samples
Limitations of χ2 test
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Choices of scores
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Example contd...,
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Linear trend alternative to independence
Association for nomonal variable
Advantages over X 2 and G 2
Association for ordinal data
Example
Association for dependent samples
Example contd...,
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
Question of interest:
Is the probability of approal of the Priministers’ performance at
the first survey greater than the second?
In this example, the responses in the two samples are
statistically dependent.
The pairs of dependent observations are called matched pairs.
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
Marginal homogeneity
π1+ = π+1
π1+ − π+1 = 0
(π11 + π12 ) − (π11 + π21 ) = 0
π12 = π21
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
McNemar test
Test statistic:
n21 − n12
Z=√ ∼ N (0, 1)
n21 + n12
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
δ = π+1 − π1+
d = p+1 − p1+
π1+ (1 − π1+ ) + π+1 (1 − π+1 ) − 2 (π11 π22 − π12 π21 )
Var (d) =
n
For large sample, a (1 − α) 100% CI for δ = π+1 − π1+ is
given by:
d ± Z α2 Varˆ(d) (1)
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c
Outline
Association for nomonal variable
McNemar Test
Association for ordinal data
Association for dependent samples
Niroshan Withanage niroshan@sjp.ac.lk STAT 63103 Lecture 03 – Testing independence for two way c