Categorical calculator

McNemar's test calculator for paired proportions

Evaluate paired or matched binary classification shifts using McNemar's test with continuity correction.

Run this test live in StatLab npm i @statlab/core

When to use it

Use when comparing paired binary outcomes on the exact same subjects or prompts.

Required Inputs

  • Paired 2x2 table [[Both Yes, A Yes / B No], [A No / B Yes, Both No]]

Mathematical Formula

χ² = (|b - c| - 1)² / (b + c)

Reporting Cautions

  • Tests discordant pairs (b and c); concordant pairs do not contribute to test statistic.
  • Use exact binomial test if b + c < 25.

Code Snippets (Python, R, TypeScript)

Python (SciPy / Statsmodels)
from statsmodels.stats.contingency_tables import mcnemar
res = mcnemar([[745, 35], [90, 130]], exact=False, correction=True)
print(f"p={res.pvalue:.5f}")
R Language
mcnemar.test(matrix(c(745, 90, 35, 130), nrow=2))
TypeScript (@statlab/core)
import { mcnemarTest } from '@statlab/core';
const res = mcnemarTest([[745, 35], [90, 130]]);

Developer Use Cases & Production Integrations

  • Evaluating pass/fail prompt test suite outcomes before and after prompt updates in VoxelAssurance.
  • Testing paired pre/post binary user conversion events.

VoxelPulse Telemetry Control Plane

Continuous A/B testing, statistical telemetry analysis, and automated feedback loops for live backend services.

Explore VoxelPulse →

VoxelAssurance Release Readiness

Fixed-price AI release-readiness sprints, automated regression testing, and reliability statistical benchmarks.

Explore VoxelAssurance →

Related Statistical Test Calculators

Explore static calculators across the StatLab inference engine suite.