Advanced tables and statistics > Descriptive statistics > Non-parametric tests on frequencies > McNemar’s test
 
McNemar’s test
Quick reference
To request a McNemar test, type:
stat=mcnemar [, element_text] [;options]
as an element in the axis.
More information
McNemar’s test is used to test for differences in a variable with just two possible values (for example, yes/no). It is most commonly used to test whether differences between ‘before and after’ measurements on the same sample indicate a real change or are due to chance.
To run a McNemar test, you will need a stat=mcnemar element in the axis. This must be preceded by exactly two basic count elements representing the changes. For example, one might count those respondents answering yes before and no after, and the other those answering no before and yes after.
The first element in the axis must be a base element. If several McNemar tests are required in the same axis, each must follow a base element (use n11 if you don’t want to see these extra bases) and a pair of elements representing the changes.
When looking at the table, remember that:
The McNemar test is not concerned with the number of respondents whose opinions do not change.
If the two counts are equal, the statistic will have a small but non-zero value.
In the same way as for the one-dimensional chi-squared test, the sum of the two counts should be at least 10 to avoid giving misleading results.
Example
Here is an example. To examine whether trying out a washing powder affects respondents’ willingness to buy it, you might write this Quantum program:
tab change ban1
ttlQ9 Likelihood of Buying Washo
ttlBase: All Trying Sample
l change
n10Base
n01Yes then No;c=c34'12'.and.c48'45'
n01No then Yes;c=c34'45'.and.c48'12'
n03
stat=mcnemar,McNemar Value
l ban1
col 12;Base;Male;Female
col 15;AB;C1;C2;DE
g                Sex                    Social Class
g      Base     Male   Female     AB      C1      C2      DE
This produces:
Q9: Likelihood of buying Washo
Base: All Trying Sample

                        Sex                   Social Class
                Base   Male   Female     AB     C1      C2     DE

Base             400    184      216     88     96     112    104
Yes then No       96     56       40     48      8       8     32
No then Yes       99     32       56     16     40       8     24

McNemar Value   0.27   6.01     2.34  15.02  20.02    0.06   0.88
               0.600  0.014    0.126  0.000  0.000   0.803  0.350
This example has highly significant results for respondents in social classes AB and C1. The result for respondents in social class AB, shows 48 changed their mind negatively after trying Washo and decided that they would not buy it. Only 16 respondents in the same social group made the opposite decision. The significant result shows that for respondents in social class AB, trying Washo adversely affects their likelihood of purchasing it.
See also
Non-parametric tests on frequencies