Formula: McNemar’s Paired χ² Test Formula
- discordantNegToPosCellB: Discordant Neg To Pos Cell B (cell b)
- discordantPosToNegCellC: Discordant Pos To Neg Cell C (cell c)
- concordantPairsAPlusD: Concordant Pairs A Plus D (a + d)
Test paired nominal shifts via McNemar’s χ², continuity-corrected χ², and matched Odds Ratio.
It evaluates χ²_McNemar = (b − c)² / (b + c); χ²_Edwards = (|b − c| − 1)² / (b + c); OR_matched = b / c directly in your browser and updates three custom SVG visualizations in real time.
The concordant pairs are not used in either χ² or in the odds ratio, because a pair that did not change says nothing about direction. They only enter the net proportion shift, which divides b minus c by the total of all pairs. So the engine needs their sum, not the two cells separately. At the default, 112 concordant pairs give a total of 150 pairs.
Compare the statistic with the χ² distribution on one degree of freedom, using any statistics package or a χ² table. The two sided 0.05 cut off is 3.84, and 0.01 is about 6.63. The default unadjusted 8.526 works out to a p of about 0.0035, and the corrected 7.605 to about 0.0058. The page itself does not print a p value.
Follow your field's convention or your analysis plan, and choose before you look at the result. Many authors report the uncorrected statistic with large counts and an exact test with small ones, using the corrected figure as a middle option. Whatever you pick, state which one it is, because readers cannot tell 8.526 and 7.605 apart without a label.
The Edwards correction subtracts 1 from the absolute difference between b and c before squaring. If that difference is exactly 1, the corrected numerator becomes zero. With b at 11 and c at 10, the uncorrected χ² is 0.048 and the corrected one is 0. Either way the conclusion is the same: there is no evidence of a directional shift.
It is b minus c as a share of all pairs. At the default, 28 minus 10 is 18 more pairs moving positive than negative, out of 150 in total, so the overall positive rate rose by 12 percentage points between the two measurements. It is an effect size, separate from the significance test, and it shrinks if you add more concordant pairs.
The matched odds ratio is b divided by c, and dividing by zero gives an infinite value, so the page leaves that line out rather than show a misleading figure. With b at 8 and c at 0 the χ² of 8 and corrected χ² of 6.125 are still valid, though an exact test is better with so few pairs. Describe the result as all eight changes going one way.
Yes, if each case is rated by both raters on a yes or no scale and you want to know whether one rater says yes more often than the other. Put cases where rater one said no and rater two said yes in b, the reverse in c, and the agreements in a plus d. For agreement beyond chance, a kappa statistic answers a different question.
The χ² values do not change, because the difference is squared. The odds ratio becomes its reciprocal and the net shift changes sign. Swapping the default cells gives the same 8.526 and 7.605, an odds ratio of 0.357 and a net shift of minus 12%. Check your cell labels so the direction you report matches what happened.
No. McNemar's test is built on counts of pairs, and the χ² depends on how many there are. Entering 28 and 10 as percentages of some unknown total would give a statistic that has no meaning. Use the actual number of pairs that changed in each direction, which you get by cross tabulating the paired records.
Not in this form. The calculator handles a 2×2 table: one yes or no outcome measured twice. For three or more categories measured in pairs, the extension is the Stuart Maxwell or Bowker test, which this page does not compute. Collapsing categories into two to fit this tool changes the question being asked.
The preset describes 150 paired observations. In 112 of them nothing changed: the before and after answers agreed. In 28 the answer went from negative to positive, which is cell b. In 10 it went from positive to negative, which is cell c.
From those counts the calculator reports an unadjusted McNemar χ² of 8.526 with one degree of freedom, an Edwards continuity corrected χ² of 7.605, a matched odds ratio of 2.8 and a net proportion shift of 12%.
You can check the main figure by hand. The difference between the discordant cells is 28 minus 10, which is 18. Square it and divide by the 38 discordant pairs and you get 8.526. For the corrected version, take 1 off the absolute difference first, so 17 squared over 38, which is 7.605. The odds ratio is 28 divided by 10. The net shift is 18 divided by all 150 pairs.
In plain terms: among the pairs that changed at all, nearly three moved in the positive direction for every one that moved the other way.
McNemar's test looks only at pairs that disagree. A pair that was positive both times, or negative both times, tells you nothing about which direction change tends to go. So the χ² formula uses b and c and nothing else.
The concordant box matters for one output only: the net proportion shift, which divides b minus c by the total number of pairs. Raise the concordant count from 112 to five hundred and the χ² stays at 8.526, the corrected χ² stays at 7.605 and the odds ratio stays at 2.8, but the net shift falls from 12% to 3.346%.
That is a useful distinction when you report results. The χ² answers whether the change is lopsided. The net shift answers how big the change is across everyone studied. A study can have a highly significant McNemar test and a small net shift if most participants never changed at all.
The page asks for a plus d as one combined number for this reason. It does not need them separately for anything it calculates.
The calculator gives the statistic but not a p value. With one degree of freedom, the usual reference point is 3.84, the χ² value that marks a two sided p of 0.05. A statistic above it is significant at that level; one below it is not. At the stricter 0.01 level the line is about 6.63.
Against those lines the presets sort cleanly. The default 8.526 corresponds to a p of roughly 0.0035, and the corrected 7.605 to roughly 0.0058, so both clear 0.01. The lower preset, with b at 17, gives 1.815 unadjusted and 1.333 corrected, well short of 3.84. The higher preset, with b at 42, gives 19.692 and 18.481, far past any conventional line.
Decide in advance which statistic you will report. Picking whichever one crosses 3.84 after seeing both is a quiet form of p hacking, and reviewers notice it when the two disagree.
The Edwards correction subtracts 1 from the absolute difference before squaring. Its job is to make the χ² approximation behave better when the discordant counts are small. The cost is that it is conservative: it makes the statistic smaller and the test harder to pass.
With large counts the two figures sit close together, as 19.692 and 18.481 do in the higher preset. With small counts they can land on opposite sides of 3.84. Take b at 20 and c at 10. The unadjusted χ² is 3.333 and the corrected one is 2.7. Neither passes. Now take b at 6 and c at 1: the unadjusted value is 3.571, the corrected one is 2.286, and an exact binomial test on those 7 discordant pairs gives a two sided p of 0.125. All three agree that 6 against 1 is not convincing evidence, but the uncorrected figure is the one that comes closest to suggesting otherwise.
When b and c differ by exactly 1, the engine's corrected χ² is 0. With b at 11 and c at 10 the uncorrected figure is 0.048 and the corrected one shows 0. That is the formula doing what it should: a difference of one pair is no evidence of direction at all.
Both χ² versions rely on an approximation that works when b plus c is reasonably large. Many textbooks suggest switching to an exact binomial test once the discordant total drops into the low twenties or below. The exact test asks how likely a split at least as uneven as yours would be if each discordant pair were a coin toss.
This calculator does not run the exact test. It reports the two χ² versions and the odds ratio. For small samples you will need to do the binomial step elsewhere. For the default 28 against 10, the exact two sided p is about 0.0051, close to the χ² answer, because 38 discordant pairs is enough for the approximation to hold. For 17 against 10 the exact p is about 0.248, close to the corrected χ² p of about 0.248, and very different from a conclusion of significance.
A practical rule: when b plus c is small, report the exact p and treat the χ² figures as a sanity check rather than the result.
The matched odds ratio is simply b over c. At the default it is 2.8. Swap the cells, putting 10 in b and 28 in c, and it becomes 0.357, the reciprocal. The χ² does not change when you swap, because squaring removes the sign, but the net shift flips to minus 12%. Direction lives in the odds ratio and the net shift, not in the χ².
Zero cells need care. When c is zero the ratio b over c is infinite, so the page hides the odds ratio line rather than printing a made up number. With b at 8 and c at 0 you still get a χ² of 8 and a corrected χ² of 6.125, but no odds ratio. When b is zero and c is not, the ratio is a genuine 0. If both cells are zero, the page shows an error, because with no discordant pairs there is nothing to test.
No confidence interval is given for the odds ratio. If you need one, calculate it separately from b and c, and avoid quoting the ratio on its own when either cell is small.
A McNemar result needs four things in a report: the discordant counts, the statistic and which version it is, the p value, and an effect size. The calculator supplies three of them directly. You add the p value.
For the default table a clear sentence would read something like this. Of 150 participants, 28 changed from negative to positive and 10 from positive to negative; McNemar's test with continuity correction gave χ² of 7.605 on one degree of freedom, p of about 0.006, with a matched odds ratio of 2.8 and a net increase of 12 percentage points.
Notice what that sentence avoids. It does not say the treatment caused the change, because a before and after design with no control group cannot show that on its own. It does not round the odds ratio up to 3, and it does not drop the counts in favour of percentages, which would hide how few pairs actually changed.
If the result is not significant, report it the same way. With b at 17 and c at 10 the corrected χ² is 1.333, which tells readers the shift could easily be chance. A missing result is harder to interpret than a reported null one, and the counts let others pool your data later.
Most wrong McNemar results come from a wrong table, not wrong arithmetic. The test is for paired data: the same people measured twice, matched case and control pairs, or two raters judging the same items. Each pair contributes one count to exactly one of the four cells.
Cell b on this page is negative first and positive second. Cell c is positive first and negative second. If your software or paper lays out the table the other way round, the χ² will match but the odds ratio and net shift will flip direction, so check which way is which before reporting.
Do not enter the column or row totals into b and c. If 38 people were positive after and 20 before, those are margins, not discordant cells. You need the count of individuals who actually changed in each direction, which comes from the paired records, not from two summary percentages.
Independent groups belong to a different test. If the before and after samples are different people, McNemar's test is the wrong tool and the ordinary chi square test for a 2×2 table applies instead.