McNemar's Test Calculator
Test for significant changes in paired nominal data using a 2×2 contingency table
About the McNemar's Test Calculator
McNemar's Test is a statistical procedure used to determine if there is a significant change in proportions within paired nominal data. It is most commonly applied in 'before and after' studies where the same subjects are measured twice, or in matched-pair designs where subjects are linked by specific characteristics. Unlike the standard Pearson's Chi-Square test, which analyzes independent groups, McNemar's focuses on the internal consistency of a single group over time or across different conditions. Researchers in medicine, psychology, and marketing use this tool to evaluate the effectiveness of an intervention or the impact of a specific event on a binary outcome. The test specifically examines the 'discordant pairs'—those instances where a subject's response changed between the first and second measurement. If the number of people switching from 'Yes' to 'No' is significantly different from the number switching from 'No' to 'Yes,' the test indicates a statistically significant shift, suggesting the intervention had a measurable effect. This calculator streamlines the process by computing the Chi-Square value and the associated p-value from your raw contingency table data.
Formula
Chi-Square = (b - c)^2 / (b + c)In a 2x2 contingency table, 'b' represents the number of cases that changed from positive to negative, while 'c' represents cases that changed from negative to positive. These are the discordant pairs. The formula calculates a chi-square statistic with one degree of freedom. If applying the continuity correction for small samples, the formula is modified to: Chi-Square = (|b - c| - 1)^2 / (b + c).
Worked examples
Example 1: A company tests 100 employees on safety protocols before and after a training seminar. 10 employees failed both, 60 passed both, 25 passed only after the training (c), and 5 passed before but failed after (b).
Discordant pairs: b = 5, c = 25\nFormula: (5 - 25)^2 / (5 + 25)\nCalculation: (-20)^2 / 30 = 400 / 30 = 13.33 (Note: Using continuity correction for accuracy)\nCorrected Calculation: (|5 - 25| - 1)^2 / (5 + 25) = (19)^2 / 30 = 361 / 30 = 12.03
Result: Chi-Square = 5.33, p-value = 0.021. This result is statistically significant at the 0.05 level, suggesting the training program changed employee behavior.
Common use cases
- Testing if a specific medication significantly changes the presence of a symptom in a group of 100 patients.
- Analyzing if a political debate changed voters' opinions from 'Support' to 'Oppose' or vice versa using the same panel of participants.
- Evaluating the accuracy of two different diagnostic tests performed on the same set of tissue samples.
Pitfalls and limitations
- The test cannot be used for independent groups; you must use a standard Chi-Square test if the subjects are different.
- McNemar's test is only valid for 2x2 tables with dichotomous outcomes; larger tables require the McNemar-Bowker test.
- The test provides no information about the 'concordant' pairs (those who stayed the same), which can lead to a loss of context if the total sample size is not reported.
Frequently asked questions
when to use mcnemar test vs chi square
You use McNemar's test when you have categorical data from the same subjects measured twice, such as a group of people before and after a medical treatment. It is specifically designed for dependent samples, whereas the standard Chi-Square test assumes the groups are independent.
why does mcnemar test ignore concordant pairs
The test only analyzes the discordant cells—those individuals who changed their status from 'yes' to 'no' or 'no' to 'yes.' The concordant cells, where people stayed the same across both time points, provide no information about the effect of the intervention and are ignored in the calculation.
do I need mcnemar test with continuity correction
The continuity correction, or Edwards correction, is recommended when the number of discordant pairs is small, typically less than 25. It subtracts 0.5 from the difference before squaring to prevent overestimating significance in small samples.
null hypothesis for mcnemar test explained
The null hypothesis for McNemar's test is that the marginal probabilities for each outcome are the same, meaning the probability of a subject switching from A to B is equal to the probability of switching from B to A. This implies the treatment or time interval had no significant effect.
minimum sample size for mcnemar test
Waitzman or exact binomial tests should be used if the sum of the discordant cells is very low, usually less than 10. In these cases, the Chi-Square approximation used in the standard McNemar formula becomes unreliable.