McNemar's test allows to compare two paired samples of binary data. Run it in Excel using the XLSTAT add-on statistical software.
McNemar's test definition and advantages
McNemar’s test is a special case of the Cochran’s Q test when there are only two treatments. As for the Cochran’s Q test, the variable of interest is binary. However, the McNemar’s test has two advantages:
- Obtaining an exact p-value is possible;
- The data can be summarized in a 2x2 contingency table.
In the case of the two-tailed (or two-sided) test, the null (H0) and alternative (Ha) hypotheses are:
H0: Treatment 1 = Treatment 2 and Ha: Treatment 1 ≠ Treatment 2
In the one-tailed case, you need to distinguish the left-tailed (or lower-tailed or lower one-sided) test and the right-tailed (or upper-tailed or upper one-sided) test. In the left-tailed test, the following hypotheses are used:
H0: Treatment 1 = Treatment 2 and Ha: Treatment 1 < Treatment 2
In the right-tailed test, the following hypotheses are used:
H0: Treatment 1 = Treatment 2 and Ha: Treatment 1 > Treatment 2
Input data for the McNemar's test
There are three possible formats are available for the input data:
- You can select data in a "raw" format. In this case, each column corresponds to a treatment and each row to a subject (or individual, or bloc).
- You can also select the data in a "grouped" format. Here, each column corresponds to a treatment, and each row corresponds to a unique combine of the k treatments. You then need to select the frequencies corresponding to each combine.
- You can also select a contingency table with two rows and two columns. In the case where you choose this, the first and second treatments are respectively considered as corresponding to the rows and the columns. The positive response cases (or successes) are considered as corresponding to the first row of the contingency table for the first treatment, and to the first column for the second treatment.
analyze your data with xlstat