# 12.9: What’s the Difference Between McNemar and Independence?


Let’s go all the way back to the beginning of the chapter, and look at the cards data set again. If you recall, the actual experimental design that I described involved people making two choices. Because we have information about the first choice and the second choice that everyone made, we can construct the following contingency table that cross-tabulates the first choice against the second choice.

cardChoices <- xtabs( ~ choice_1 + choice_2, data = cards )
cardChoices
##           choice_2
## choice_1   clubs diamonds hearts spades
##   clubs       10        9     10      6
##   diamonds    20        4     13     14
##   hearts      20       18      3     23
##   spades      18       13     15      4

Suppose I wanted to know whether the choice you make the second time is dependent on the choice you made the first time. This is where a test of independence is useful, and what we’re trying to do is see if there’s some relationship between the rows and columns of this table. Here’s the result:

chisq.test( cardChoices )

Alternatively, suppose I wanted to know if on average, the frequencies of suit choices were different the second time than the first time. In that situation, what I’m really trying to see if the row totals in cardChoices (i.e., the frequencies for choice_1) are different from the column totals (i.e., the frequencies for choice_2). That’s when you use the McNemar test:

mcnemar.test( cardChoices )

##
##  McNemar's Chi-squared test
##
## data:  cardChoices
## McNemar's chi-squared = 16.033, df = 6, p-value = 0.01358

Notice that the results are different! These aren’t the same test.

This page titled 12.9: What’s the Difference Between McNemar and Independence? is shared under a CC BY-SA 4.0 license and was authored, remixed, and/or curated by Danielle Navarro via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.