McNemar's Test Calculator

Hypothesis Testing and Statistical Inference

This tool performs McNemar's test, a statistical test used on paired nominal data to determine if the row and column marginal frequencies are equal.

2x2 Contingency Table

Practical Examples

Explore these real-world scenarios to understand the applications of McNemar's test.

Drug Efficacy Trial

Medical Study

A study tests a new drug. 150 patients are assessed for a symptom before and after treatment. We want to know if the drug significantly changed the presence of the symptom.

a: 60, b: 50

c: 10, d: 30

Ad Campaign Impact

Marketing

A company surveys 200 people about their brand preference before and after a new ad campaign. The goal is to see if the campaign significantly shifted preferences.

a: 70, b: 15

c: 35, d: 80

Effectiveness of a Teaching Method

Education

100 students are tested on a concept, then retaught using a new method and tested again. We are analyzing the change in pass/fail rates.

a: 40, b: 5

c: 25, d: 30

Low Discordant Pairs

Edge Case

An example where there is very little change between the two conditions, testing the calculator's handling of low discordant pair counts.

a: 100, b: 2

c: 3, d: 150

Other Titles
Understanding McNemar's Test: A Comprehensive Guide
An in-depth look at McNemar's test for analyzing paired categorical data, its applications, and the mathematics behind it.

What is McNemar's Test?

  • Core Concepts
  • When to Use It
  • Null and Alternative Hypotheses
McNemar's test is a statistical test used for analyzing paired dichotomous data. It is specifically designed for 'before-and-after' studies or matched-pair designs where each subject is measured twice under two different conditions. The primary goal is to detect if there is a significant change in the proportion of subjects who fall into one of two categories.
Core Concepts
Unlike the chi-squared test of independence, which is used for unpaired data, McNemar's test focuses on the subjects who have changed their response between the two measurements. These are known as the 'discordant pairs'. The test essentially ignores the subjects whose responses did not change (the 'concordant pairs') because they provide no information about the directional change.
When to Use It
You should use McNemar's test when you have: 1. A single group of subjects. 2. Each subject is measured on a binary nominal variable (e.g., yes/no, pass/fail) on two separate occasions or under two different conditions. 3. The two measurements are paired or related.
Null and Alternative Hypotheses
The null hypothesis (H₀) states that there is no change in the proportions between the two conditions. In other words, the number of subjects who changed from 'Yes' to 'No' is equal to the number who changed from 'No' to 'Yes'. The alternative hypothesis (H₁) states that there is a significant change in proportions.

Step-by-Step Guide to Using the McNemar's Test Calculator

  • Data Entry
  • Setting the Significance Level
  • Interpreting the Results
Our calculator simplifies the process of performing McNemar's test. Follow these steps to get your results.
Data Entry for the 2x2 Table

The calculator uses a standard 2x2 contingency table format. You need to input the counts for four specific cells: a) Positive in Condition 1 and Positive in Condition 2 b) Positive in Condition 1 and Negative in Condition 2 c) Negative in Condition 1 and Positive in Condition 2 d) Negative in Condition 1 and Negative in Condition 2. Ensure that you input non-negative integer values.

Setting the Significance Level (α)
The significance level, or alpha (α), is the threshold for deciding statistical significance. A common choice is 0.05, which corresponds to a 95% confidence level. You can adjust this value based on your study's requirements.
Interpreting the Results
After clicking 'Calculate', the tool will provide the McNemar's statistic (χ²), the p-value, and an odds ratio. The key result is the p-value. If the p-value is less than your chosen significance level (p < α), you reject the null hypothesis and conclude that there is a statistically significant change in proportions. Otherwise, you fail to reject the null hypothesis.

Real-World Applications of McNemar's Test

  • Medical and Clinical Research
  • Marketing and Business Analytics
  • Social Sciences and Polling
McNemar's test is a versatile tool used across various fields.
Medical and Clinical Research
It's frequently used to assess the effectiveness of a medical treatment. For example, researchers might record whether a patient has a specific symptom before and after receiving a new drug. McNemar's test can determine if the drug led to a significant reduction in symptom prevalence.
Marketing and Business Analytics
A company might use this test to see if a marketing campaign changed consumer preference for their product. A sample of consumers would be surveyed about their brand choice before and after the campaign, and the test would reveal if the campaign caused a significant shift.
Social Sciences and Polling
In political science, it can be used to track changes in voter opinion. A group of voters could be polled on their support for a candidate before and after a major debate to see if the event significantly altered their views.

Common Misconceptions and Correct Methods

  • McNemar's Test vs. Chi-Squared Test
  • The Importance of Paired Data
  • Continuity Correction
Understanding the nuances of McNemar's test is crucial for its correct application.
McNemar's Test vs. Chi-Squared Test of Independence
A common error is using the standard Chi-Squared test for paired data. The Chi-Squared test assumes independent groups, whereas McNemar's test is specifically for dependent, paired samples. Using the wrong test can lead to incorrect conclusions.
The Importance of Paired Data
The entire validity of McNemar's test rests on the data being paired. This means each data point in the first group is directly related to a specific data point in the second group (e.g., the same person measured twice). If your data comes from two different, independent groups of subjects, you should use a different test.
Continuity Correction
The test uses the chi-squared distribution, which is continuous, to approximate a discrete binomial distribution. To improve this approximation, especially with smaller sample sizes, a continuity correction is often applied. Our calculator incorporates the Edwards continuity correction: (|b - c| - 1)² / (b + c).

Mathematical Derivation and Examples

  • The Contingency Table
  • The Formula
  • Worked Example
The Contingency Table

The test is based on a 2x2 table for paired data:

Condition 2: Positive Condition 2: Negative
Condition 1: Positive a b
Condition 1: Negative c d

Here, 'a' and 'd' are concordant pairs (no change), while 'b' and 'c' are discordant pairs (change occurred).

The Formula
The test statistic is calculated using only the discordant pairs (b and c). The formula with continuity correction is: χ² = (|b - c| - 1)² / (b + c)
This value is then compared to a chi-squared distribution with 1 degree of freedom to find the p-value.
Worked Example

Let's use the 'Drug Efficacy Trial' from our examples: a=60, b=50, c=10, d=30.

  1. Identify discordant pairs: b=50, c=10.
  2. Apply the formula: χ² = (|50 - 10| - 1)² / (50 + 10) = (40 - 1)² / 60 = 39² / 60 = 1521 / 60 = 25.35.
  3. A χ² value of 25.35 with 1 degree of freedom corresponds to a very small p-value (p < 0.00001). Since this is less than the standard α of 0.05, we conclude the drug had a significant effect.