The McNemar Test

advertisement
252McNemar 11/02/05
The McNemar Test
In Method D6a, we assume that we are comparing proportions from two independent
samples. In Method D6b, the McNemar Test, we compare two proportions taken from the
same sample. Assume that two different questions are asked of the same group with the
question 1
following responses.
yes
no
question 2
yes no
 x11 x12 
x

 21 x 22 
So, for example x 21 is the number of people
who answered no to question 1 and yes to question 1. x11  x12  x 21  x 22  n , p1 
x11  x12
n
H : p  p
x11  x 21
n
2
. If we wish to test  0 1
, where p1 is the proportion saying ‘yes’
H
:
p

p
2
 1 1
to the first question and p 2 is the proportion saying ‘yes’ to the second question, let
and p 2 
z
x12  x 21
x12  x 21
(The test is valid only if x12  x 21  10 .)
A famous example of this concerns a debate between candidates, question 1 is whether
the respondent supports candidate 1 before the debate and question 2 is whether the
question 1
respondent supports candidate 1 after the debate. The data is
yes
no
question 2
yes no
27 7
 13 28 


and the
question is whether the debate has changed the fraction supporting candidate 1. Write this
out as a hypothesis test and do the test.
H : p  p
H : p  p  0
2
Solution:  0 1
or  0 1 2
This is a two-sided test, so if we use a 5%
H
:
p

p
2
 1 1
H 1 : p1  p 2  0
significance level, our rejection regions are below z .025  1.96 and above z.025  1.96 .
z
x12  x 21
x12  x 21

7  13
7  13

6
20

36
  1.8  1.34 , and we cannot reject the null
20
hypothesis. If we use a p-value, 2Pz  1.34   2.5  .4099   0.0901 , so we could reject the
null hypothesis at a 10% significance level, but not a 5% level. If you (wrongly, but
H 0 : p1  p 2
H : p  p  0
or  0 1 2
, the 5%
H 1 : p1  p 2
H 1 : p1  p 2  0
understandably though that the hypotheses were 
rejection region would be below z.05  1.645 and we still could not reject the null
hypothesis.
Note: This is a version of the Chi-Square Test (so don’t read this until you have learned
how to do a chi-squared test) – Recall that  2  
O  E 2 . If we take
E
x11 and x 22 as
given, and assume that the null hypothesis is correct, then the table already
question 1
given,
yes
no
question 2
yes no
 x11 x12 
x

 21 x 22 
is our O , and the numbers in the x12 and the x 21 slots must
be equal for there to be no change in preferences, so that our E is
question 1
yes
no
question 2
yes
no
x12  x 21  .

x11


2
x  x

21
 12
x 22 


2
This means that two of the four terms in  2  
2
are zero and the remaining terms are

x12  x 21 2
x12  x 21
x  x 21 
x  x 21 


 x12  12

 x 21  12

2
2



2  

x12  x 21
x12  x 21
2
2
O  E 2
E
2
. But  2 has only one degree of freedom, and, since  2 is defined as a sum
of z 2 , we can take a square root and say z 
x12  x 21
x12  x 21
.
Download