chi2_mcnemar(M)

Computes a McNemar test using data in matrix M and a significance level of 0.05 (5%). Matrix M must be a contingency table.

chi2_mcnemar(M, alpha)

As above but the significance level is alpha.


See also chi2_likelihood chi2_kappa chi2_mantel chi2_risk 


Example


A total of 20 teenagers were interviewed about their views on the death penalty; the study found that 12 were in favor of the death penalty and 8 were against it. Afterward, the youths were given lectures and attended seminars on the errors and abuse of the death penalty; a week later they were interviewed again.
The table below shows their opinions before and after:


Before
After
Total
In favor
Against
In favor
1
11
12
Against
3
5
8
Total
4
16
20

The data shows that all but one youth changed from in favor to against while 3 youths changed from against to in favor.

Entering the basic data in a matrix we obtain:

M = ( 1, 11; 3, 5)

/ 1 11 \

\ 3  5 /


We now use function chi2_totable to transform the matrix into a proper contingency table

M=chi2_totable(M)

/ "" "" "" "" \

| ""  1  11  16 |

| ""  3   5   8 |

\ ""  4  16 20 /


Using the function chi2_mcnemar we obtain (5% significance),

chi2_mcnemar(M)


McNemar test.

Hypothesis test assumes a two-tails test for changes in response. For other tests use the one-tail probability.

Ho : Proportions before and after are the same

Ha : Proportions before and after are not the same

Significance level : 0.05 (5.0%)

Results:

Do not reject the null hypothesis. (1.0)

Two-tails probability: 0.05737304687500008

For other test use:

One-tail probability: 0.02868652343750004