McNemar's test explained

McNemar's test is a statistical test used on paired nominal data. It is applied to 2 × 2 contingency tables with a dichotomous trait, with matched pairs of subjects, to determine whether the row and column marginal frequencies are equal (that is, whether there is "marginal homogeneity"). It is named after Quinn McNemar, who introduced it in 1947.[1] An application of the test in genetics is the transmission disequilibrium test for detecting linkage disequilibrium.[2]

The commonly used parameters to assess a diagnostic test in medical sciences are sensitivity and specificity. Sensitivity (or recall) is the ability of a test to correctly identify the people with disease. Specificity is the ability of the test to correctly identify those without the disease.

Now presume two tests are performed on the same group of patients. And also presume that these tests have identical sensitivity and specificity. In this situation one is carried away by these findings and presume that both the tests are equivalent. However this may not be the case. For this we have to study the patients with disease and patients without disease (by a reference test). We also have to find out where these two tests disagree with each other. This is precisely the basis of McNemar's test. This test compares the sensitivity and specificity of two diagnostic tests on the same group of patients.[3]

Definition

The test is applied to a 2 × 2 contingency table, which tabulates the outcomes of two tests on a sample of N subjects, as follows.

Test 2 positive Test 2 negative Row total
Test 1 positive a b a + b
Test 1 negative c d c + d
Column total a + c b + d N
The null hypothesis of marginal homogeneity states that the two marginal probabilities for each outcome are the same, i.e. pa + pb = pa + pc and pc + pd = pb + pd.

Thus the null and alternative hypotheses are[1]

\begin{align} H0&:~pb=pc\\ H1&:~pb\nepc \end{align}

Here pa, etc., denote the theoretical probability of occurrences in cells with the corresponding label.

The McNemar test statistic is:

\chi2={(b-c)2\overb+c}.

Under the null hypothesis, with a sufficiently large number of discordants (cells b and c),

\chi2

has a chi-squared distribution with 1 degree of freedom. If the

\chi2

result is significant, this provides sufficient evidence to reject the null hypothesis, in favour of the alternative hypothesis that pb ≠ pc, which would mean that the marginal proportions are significantly different from each other.

Variations

If either b or c is small (b + c < 25) then

\chi2

is not well-approximated by the chi-squared distribution. An exact binomial test can then be used, where b is compared to a binomial distribution with size parameter n = b + c and p = 0.5. Effectively, the exact binomial test evaluates the imbalance in the discordants b and c. To achieve a two-sided P-value, the P-value of the extreme tail should be multiplied by 2. For bc:

exact-P-value=2

n
\sum
i=b

{n\choosei}0.5i(1-0.5)n-i,

which is simply twice the binomial distribution cumulative distribution function with p = 0.5 and n = b + c.

Edwards[4] proposed the following continuity corrected version of the McNemar test to approximate the binomial exact-P-value:

\chi2={(|b-c|-1)2\overb+c}.

The mid-P McNemar test (mid-p binomial test) is calculated by subtracting half the probability of the observed b from the exactone-sided P-value, then double it to obtain the two-sided mid-P-value:[5] [6]

mid-p-value=2\left(

n
\sum
i=b

{n\choosei}0.5i(1-0.5)n-i-0.5{n\chooseb}0.5b(1-0.5)n-b\right)

This is equivalent to:

mid-p-value=exact-p-value-{n\chooseb}0.5b(1-0.5)n-b

where the second term is the binomial distribution probability mass function and n = b + c. Binomial distribution functions are readily available in common software packages and the McNemar mid-P test can easily be calculated.

The traditional advice has been to use the exact binomial test when b + c < 25. However, simulations have shown both the exact binomial test and the McNemar test with continuity correction to be overly conservative. When b + c < 6, the exact-P-value always exceeds the common significance level 0.05. The original McNemar test was most powerful, but often slightly liberal. The mid-P version was almost as powerful as the asymptotic McNemar test and was not found to exceed the nominal significance level.

Examples

In the first example, a researcher attempts to determine if a drug has an effect on a particular disease. There are 314 patients, and they are diagnosed (disease: present or absent) before and after using the drug, which means that each sample can be described using 1 out of 4 combinations.Counts of individuals are given in the table, with the diagnosis (disease: present or absent) before treatment given in the rows, and the diagnosis after treatment in the columns. The test requires the same subjects to be included in the before-and-after measurements (matched pairs).

After: presentAfter: absentRow total
Before: present101 121 222
Before: absent59 33 92
Column total 160 154 314

In this example, the null hypothesis of "marginal homogeneity" would mean there was no effect of the treatment. From the above data, the McNemar test statistic:

\chi2={(121-59)2\over{121+59}}

has the value 21.35, which is extremely unlikely to form the distribution implied by the null hypothesis (p < 0.001). Thus the test provides strong evidence to reject the null hypothesis of no treatment effect.

A second example illustrates differences between the asymptotic McNemar test and alternatives. The data table is formatted as before, with different numbers in the cells:

After: presentAfter: absentRow total
Before: present59 6 65
Before: absent16 80 96
Column total 75 86 161

With these data, the sample size (161 patients) is not small, however results from the McNemar test and other versions are different. The exact binomial test gives p = 0.053 and McNemar's test with continuity correction gives

\chi2

= 3.68 and p = 0.055. The asymptotic McNemar's test gives

\chi2

= 4.55 and p = 0.033 and the mid-P McNemar's test gives p = 0.035. Both the McNemar's test and mid-P version provide stronger evidence for a statistically significant treatment effect in this second example.

Discussion

An interesting observation when interpreting McNemar's test is that the elements of the main diagonal do not contribute to the decision about whether (in the above example) pre- or post-treatment condition is more favourable. Thus, the sum b + c can be small and statistical power of the tests described above can be low even though the number of pairs a + b + c + d is large (see second example above).

An extension of McNemar's test exists in situations where independence does not necessarily hold between the pairs; instead, there are clusters of paired data where the pairs in a cluster may not be independent, but independence holds between different clusters.[7] An example is analyzing the effectiveness of a dental procedure; in this case, a pair corresponds to the treatment of an individual tooth in patients who might have multiple teeth treated; the effectiveness of treatment of two teeth in the same patient is not likely to be independent, but the treatment of two teeth in different patients is more likely to be independent.[8]

Information in the pairings

In the 1970s, it was conjectured that retaining one's tonsils might protect against Hodgkin's lymphoma. John Rice wrote:[9]

85 Hodgkin's patients [...] had a sibling of the same sexwho was free of the disease and whose age was within 5 years ofthe patient's. These investigators presented the following table:

\begin{array}{c|c|c} \hline&Tonsillectomy&Notonsillectomy\\ \hlineHodgkins&41&44\\ \hlineControl&33&52 \end{array}

They calculated a chi-squared statistic [...] [they] had made an error in their analysis by ignoring the pairings.[...] [their] samples were not independent, because the siblings were paired [...] we set up a table that exhibits the pairings:

\begin{array}{cc} &Sibling\\ Patient& \begin{array}{c|c|c} \hline&Notonsillectomy&Tonsillectomy\\ \hlineNotonsillectomy&37&7\\ \hlineTonsillectomy&15&26 \end{array} \end{array}

It is to the second table that McNemar's test can be applied. Notice that the sum of the numbers in the second table is 85—the number of pairs of siblings—whereas the sum of the numbers in the first table is twice as big, 170—the number of individuals. The second table gives more information than the first. The numbers in the first table can be found by using the numbers in the second table, but not vice versa. The numbers in the first table give only the marginal totals of the numbers in the second table. McNemar's test allows the 15 and 7 pairs where the siblings had previously had differing treatment to their tonsils to be compared, as being relevant to the hypothesis, while ignoring the less informative 37 and 26 where the siblings had previously both had the treatment or to their tonsils or neither had.

Related tests and methods

See also

External links

Notes and References

  1. 10.1007/BF02295996. 12. 2. 153–157. McNemar. Quinn. Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika. June 18, 1947. 20254758. 46226024.
  2. Spielman RS . McGinnis RE . Ewens WJ . Warren Ewens . Transmission test for linkage disequilibrium: the insulin gene region and insulin-dependent diabetes mellitus (IDDM) . Am J Hum Genet . 52 . 3 . 506–16 . Mar 1993 . 8447318 . 1682161 .
  3. Hawass. N E. April 1997. Comparing the sensitivities and specificities of two diagnostic procedures performed on the same group of patients.. The British Journal of Radiology. 70. 832. 360–366. 10.1259/bjr.70.832.9166071. 9166071. 0007-1285.
  4. 13. 3. 185–187. Edwards. A. Note on the "correction for continuity" in testing the significance of the difference between correlated proportions. Psychometrika. 1948. 10.1007/bf02289261. 18885738. 33607853.
  5. 56. 294. 223–234. Lancaster. H.O.. Significance tests in discrete distributions.. J Am Stat Assoc. 1961. 10.1080/01621459.1961.10482105.
  6. 13 . 91 . Fagerland. M.W. . Lydersen. S. . Laake. P. . The McNemar test for binary matched-pairs data: mid-p and asymptotic are better than exact conditional . BMC Medical Research Methodology . 2013 . 10.1186/1471-2288-13-91. 23848987 . 3716987 . free .
  7. 10.1002/bimj.201000035 . A note on the tests for clustered matched-pair binary data . 2010 . Biometrical Journal . 638–652 . 52 . 5 . Yang . Z. . Sun . X. . Hardin . J.W. . 20976694. 29461324 .
  8. 10.1002/sim.1438 . Analysis of clustered matched-pair data . https://archive.today/20130105071155/http://www3.interscience.wiley.com/journal/104545274/abstract . dead . January 5, 2013 . 2003 . Statistics in Medicine . 2417–28 . 22 . 15 . Durkalski . V.L. . Palesch . Y.Y. . Lipsitz . S.R. . Rust . P.F. . April 1, 2009 . 12872299 . 25909362 .
  9. Book: 1995. Rice, John . Mathematical Statistics and Data Analysis . limited. Second . . Belmont, California . 978-0-534-20934-6 . 492–494 .
  10. 2988087. 295–304. Liddell. D.. Practical Tests of 2 × 2 Contingency Tables. 25. 4. Journal of the Royal Statistical Society. 1976. 10.2307/2988087 .
  11. Web site: Maxwell's test, McNemar's test, Kappa test . Rimarcik.com . 2012-11-22.
  12. Web site: Generalized McNemar's Test for Homogeneity of the Marginal Distributions. Xuezheng. Sun. Zhao. Yang. SAS Global Forum. 2008.
  13. 2333387. A Test for Homogeneity of the Marginal Distributions in a Two-Way Classification. Biometrika. 42. 3/4. 412–416. Alan. Stuart. 1955. 10.1093/biomet/42.3-4.412.
  14. Comparing the Classification of Subjects by Two Independent Judges. The British Journal of Psychiatry. 116. 535. 651–655. A.E.. Maxwell. 1970. 10.1192/bjp.116.535.651. 5452368. 9211848 .
  15. Web site: McNemar Tests of Marginal Homogeneity . John-uebersax.com . 2006-08-30 . 2012-11-22.
  16. 2283057. A Note on the Equivalence of Two Test Criteria for Hypotheses in Categorical Data. Journal of the American Statistical Association. 61. 313. 228–235. V.P.. Bhapkar. 1966. 10.1080/01621459.1966.10502021.
  17. 10.1177/0092861512442021 . Testing Marginal Homogeneity in Matched-Pair Polytomous Data . 2012 . Therapeutic Innovation & Regulatory Science . 434–438 . 46 . 4 . Yang . Z. . Sun . X. . Hardin . J.W.. 123109340 .
  18. Book: Agresti, Alan . 2002 . Categorical Data Analysis . Hooken, New Jersey . John Wiley & Sons, Inc. . 413 . 978-0-471-36093-3.