about statistical-calculators.site
Enter the counts for each cell of the paired table (Before vs. After, or Condition A vs. Condition B):
Enter each subject's outcome as 0 (negative/no) or 1 (positive/yes), one value per subject, in the same order for both conditions:
Follow these simple steps to perform a McNemar test on your data:
Enter the four counts a, b, c, d of your paired 2×2 table. Each subject (or matched pair) contributes to exactly one cell based on their outcomes in the two conditions (Before/After, Treatment/Control, etc.).
If you have individual-level data, paste the binary outcomes (0 or 1) for each subject in the same order in both text areas, then click "Build Table from Raw Data". The contingency table will be filled automatically.
Click "Calculate McNemar Test". The calculator will display:
The McNemar test is a non-parametric statistical test used to analyze paired nominal (binary) data. It is typically applied in "before and after" study designs, matched case-control studies, or any situation where the same subjects are measured under two conditions and the outcome is binary (yes/no, success/failure, positive/negative).
The test was introduced by Quinn McNemar in 1947 and remains widely used in medicine, psychology, and social sciences for evaluating whether there is a significant change in proportion between two related observations.
The data are arranged in a 2×2 table. Let the rows represent the first condition (Before) and the columns represent the second condition (After):
| After: + | After: − | |
|---|---|---|
| Before: + | a | b |
| Before: − | c | d |
Cells a and d are concordant pairs — subjects who did not change. Cells b and c (highlighted) are discordant pairs — subjects who changed. The McNemar test is based entirely on b and c.
The null hypothesis is that the marginal proportions are equal — i.e., the probability of a positive outcome is the same under both conditions. A small p-value (typically p < 0.05) indicates that the proportion changed significantly between conditions.
Q1: How is the McNemar chi-square statistic calculated?
The standard McNemar statistic focuses on the discordant pairs. If b is the count of subjects who were positive before and negative after, and c is the count who were negative before and positive after, the test statistic is:
$$ \chi^2 = \frac{(b - c)^2}{b + c} $$This statistic follows a chi-square distribution with 1 degree of freedom under the null hypothesis.
Q2: What is the continuity correction, and when should it be applied?
For small samples (conventionally when b + c < 25), the chi-square approximation may be inaccurate. Edwards' continuity correction adjusts the formula by subtracting 1 from the absolute difference:
$$ \chi^2_c = \frac{(|b - c| - 1)^2}{b + c} $$This corrected version is more conservative (produces larger p-values) and is preferred for small discordant totals. This calculator always reports both values and flags which is recommended.
Q3: What is the exact McNemar test?
When the total number of discordant pairs (b + c) is very small (typically ≤ 5 or ≤ 10), even the continuity-corrected chi-square approximation may not be reliable. In such cases, the exact McNemar test should be used. It is based on the binomial distribution: under H₀, b (or c) follows a Binomial(b + c, 0.5) distribution, and the p-value is computed exactly from this distribution.
Q4: What is the difference between the McNemar test and the Chi-square test?
The standard Pearson chi-square test is used for independent samples. The McNemar test is designed for paired or dependent samples — when the two observations are linked (same subject measured twice, or matched pairs). Using a chi-square test on paired data ignores the dependency structure and leads to incorrect results. Conversely, using the McNemar test on independent samples is inappropriate.
Q5: How do I report the results of a McNemar test?
A typical reporting format: "A McNemar test indicated a statistically significant change in the proportion of positive responses from before (X%) to after (Y%), χ²(1, N = Z) = [value], p = [value]." Always report the contingency table so readers can see the raw discordant and concordant counts.
Q6: What is the effect size for the McNemar test?
A common effect size measure for the McNemar test is the odds ratio of the discordant pairs:
$$ OR = \frac{b}{c} $$An OR of 1 means no change. OR > 1 means the "Before+, After−" direction dominated; OR < 1 means the "Before−, After+" direction dominated. Some researchers also report the proportionate change or Cohen's g as an effect size.