Statistical Methods
Use Discordant Pairs in an Exact McNemar Test
Confirm that the observations are paired
McNemar's test addresses paired categorical data. Examples include the same participants classified before and after an intervention or matched observations with a binary response. Write the pair identifier and verify that the two classifications actually refer to the intended pair.
Do not analyze a paired table as though its rows were two independent samples. Conversely, two unrelated groups do not become paired because their sample sizes match. Preserve the reasons for incomplete pairs and state how many eligible participants lack one of the two classifications.
Label both disagreement directions
Arrange the four cells as before-positive/after-positive, before-positive/after-negative, before-negative/after-positive, and before-negative/after-negative. The two off-diagonal cells are discordant pairs. Their difference describes the direction of change; the diagonal cells record people whose classifications did not change.
The official statsmodels McNemar documentation distinguishes an exact binomial calculation from the chi-squared approximation. Specify which version you use instead of reporting only the test's name.
Recompute a fictional example
Suppose 50 complete pairs produce counts 20, 3, 12, and 15 in that order. There are 15 discordant pairs: three move from positive to negative and twelve move from negative to positive. The positive proportion increases from 23/50 = 46% to 32/50 = 64%, an observed increase of 18 percentage points.
Under the exact null calculation, the 15 discordant directions follow a binomial distribution with probability one-half. The conventional two-sided p-value is twice the probability of at most three in one direction, capped at one: approximately 0.03516. The exact McNemar tool reproduces this fictional example.
Keep the p-value in context
The test evaluates equality of the marginal probabilities, not whether most pairs agree. In the example, diagonal agreement is 35/50 = 70%, but that is a separate description. A small p-value does not establish a clinically important change or show that an intervention caused it.
Use the paired-binary audit worksheet to preserve the cell order, complete-pair denominator, discordant counts, and analysis method. If there are no discordant pairs, there is no directional information for this conditional comparison; an implementation may return p = 1 with an explanatory note.
Check whether pairs are independent of other pairs. Multiple visits or several matched units per participant may require a different analysis. Report the paired proportions and change with appropriate uncertainty alongside the test, and explain missing-pair handling. Do not select an exact, approximate, or one-sided version after seeing which produces the preferred conclusion.
Source checked on 1 November 2026; fictional binomial probability independently recalculated.