Calculator
Example Data Table
| Scenario | Both yes | First yes, second no | First no, second yes | Both no | Use |
|---|---|---|---|---|---|
| Before and after screening | 40 | 12 | 5 | 43 | Paired response change |
| Two diagnostic methods | 62 | 8 | 19 | 31 | Method disagreement |
| Matched case review | 25 | 3 | 14 | 58 | Marginal difference |
Formula Used
Use a paired two by two table:
a = both positive, b = first positive and second negative, c = first negative and second positive, d = both negative.
McNemar chi-square: X² = (b - c)² / (b + c)
Continuity corrected statistic: X² = (|b - c| - 1)² / (b + c)
Exact test: two-sided binomial probability using min(b, c) successes from b + c trials with p = 0.5.
Paired risk difference: RD = (b - c) / n
RD standard error: SE = sqrt(((b + c) - (b - c)² / n) / n²)
RD confidence interval: RD ± z × SE
Matched odds ratio: OR = b / c
Log odds ratio interval: exp(log(OR) ± z × sqrt(1 / b + 1 / c))
How to Use This Calculator
Enter the four paired table counts. Use whole numbers only. Select the confidence level. Choose whether the displayed chi-square result should use continuity correction. Select the zero correction option for odds ratio intervals. Press Calculate. Review the result above the form. Use CSV or PDF export when needed.
McNemar Confidence Interval Guide
Paired Nominal Data
McNemar analysis is used with paired nominal data. The same subject is checked twice. The same unit may also be matched with another unit. Each pair then has two possible outcomes. The useful counts are the discordant cells. These are the pairs that changed from one category to another. The calculator focuses on those cells.
When The Test Helps
Use this method when results are paired. A patient may be tested before and after treatment. A voter may answer two related questions. A device may be judged by two methods. In each case, the data must fit a two by two table. The table contains both positive, first only, second only, and both negative counts.
Main Measures
The McNemar statistic compares the two discordant cells. If both cells are close, the paired proportions are similar. If one cell is much larger, the two conditions may differ. The calculator reports the exact binomial result. It also reports chi-square results. Continuity correction can be used for cautious summaries.
Confidence Intervals
A confidence interval shows a likely range for the paired effect. The risk difference interval uses the difference between discordant counts. It reports how much the marginal proportions changed. The matched odds ratio interval uses the ratio of discordant cells. It is useful when a relative paired effect is needed. A zero correction can be applied when one discordant cell is zero.
Reading The Output
Start with the total sample size. Then review the discordant total. A small discordant total can make results unstable. Next check the p value. A small p value suggests imbalance between the paired outcomes. Then inspect the interval. A risk difference interval crossing zero suggests weak evidence of change. An odds ratio interval crossing one suggests weak evidence of a relative difference.
Practical Notes
Do not use this calculator for independent groups. It is designed for paired observations only. Keep raw counts as whole numbers. Confirm that every pair belongs to one table cell. Use the exports to save a transparent record. Report the method, counts, confidence level, p value, and selected interval in your notes. For publication, also state whether continuity correction was enabled during calculation. This improves review and reduces confusion.
FAQs
What is McNemar's test used for?
It tests paired nominal outcomes. It is useful when the same subjects are measured twice, or when observations are matched in pairs.
Which cells matter most?
The discordant cells matter most. These are b and c. They show how many pairs changed in opposite directions.
What does the risk difference mean?
It shows the paired marginal difference. It is calculated as b minus c, divided by the total number of paired observations.
What does the matched odds ratio mean?
It compares the two discordant counts. A value above one means b is larger than c. A value below one means c is larger.
Should I use continuity correction?
Continuity correction is more conservative. It is often used for smaller discordant totals. The calculator also shows exact binomial results.
What if b or c is zero?
The odds ratio can become undefined. The optional 0.5 correction helps produce a practical interval when a discordant cell is zero.
Can I use this for independent samples?
No. McNemar's test is for paired or matched binary outcomes. Independent groups need other proportion tests.
What should I report?
Report the four counts, discordant total, confidence level, p value, chosen correction, and confidence interval. Add the test context clearly.