7.10.4.1. statsmodels.sandbox.stats.runs.mcnemar

statsmodels.sandbox.stats.runs.mcnemar(x, y=None, exact=True, correction=True)[source]

McNemar test

Parameters:

x, y : array_like

two paired data samples. If y is None, then x can be a 2 by 2 contingency table. x and y can have more than one dimension, then the results are calculated under the assumption that axis zero contains the observation for the samples.

exact : bool

If exact is true, then the binomial distribution will be used. If exact is false, then the chisquare distribution will be used, which is the approximation to the distribution of the test statistic for large sample sizes.

correction : bool

If true, then a continuity correction is used for the chisquare distribution (if exact is false.)

Returns:

stat : float or int, array

The test statistic is the chisquare statistic if exact is false. If the exact binomial distribution is used, then this contains the min(n1, n2), where n1, n2 are cases that are zero in one sample but one in the other sample.

pvalue : float or array

p-value of the null hypothesis of equal effects.

Notes

This is a special case of Cochran’s Q test. The results when the chisquare distribution is used are identical, except for continuity correction.