StatsToDo : McNemar Test for Paired Changes in Proportions
Includes Sample Size and Power Estimate
Introduction McNemar's Test Sample Size & Power for McNemar's Test R Codes
 + - + a(n++) b(n-+) - c(n+-) d(n--)
The McNemar's test evaluates changes in related or paired binomial attributes, whether in one direction is significantly greater than that in the opposite direction.

The data structure is as shown in the table to the right, where columns represents before and rows represents after.

• a(n++) represents the numbers with positive attribute, unchanged
• d(n--) represents the numbers with negative attribute, unchanged
• b(n-+) represents the numbers with positive attribute that changed to negative
• c(n+-) represents the numbers with negative attribute that changed to positive
• b and c are used to calculate Chi Square
Chi Squares = (abs(b-c)-1)2 / (b+c)    degree of freedom = 1.

Example

We are going to study whether a major speech by the leader of a political party will affect the voting intentions of the public.

We recruited 250 subjects, and recorded their voting intensions before and after the speech.

There were 130 subjects who intended to vote against the party before the speech, 45 (18% of the total) of them changed their voting intension towards favouring the party after the speech.

There were 120 subjects who intended to vote for the party before the speech, 24 (9,6% of the total) of them changed their voting intension to against the party after the speech.

we found Chi Square = 5.8, df = 1, p=0.02. This indicates that the speech was effective in changing voting intensions towards favouring the party.

Reference: Siegel S and Castellan Jr. N J (1988) Nonparametric Statistics for the Behavioral Sciences 2nd. Ed. McGraw Hill, Inc. Boston Massachusetts. ISBN 0-07-057357-3 p 75

### Sample Size and Power

Sample size for the McNemar's test estimates the number of pairs (befre and after) required for anticipated p1 (proportion of cases that will switch one way (+ to -) and p2 (proportion of cases that will switch the other way (- to +). The other parameters are Type I error (α) and power (1-β).

Power estimation is the reverse of sample size. It estimate the power of the observed given α, sample size (the total number of pairs in the data), p1 and p2 observed

Reference: Machin D, Campbell M, Fayers, P, Pinol A (1997) Sample Size Tables for Clinical Studies. Second Ed. Blackwell Science IBSN 0-86542-870-0 p. 70 - 71