Cochran’s Q test for identical effect of k treatments

Cochran’s Q is a k-sample extension of the McNemar test. If there are only two treatments, then Cochran’s Q test and McNemar test are equivalent.

Test that the probability of success is the same for each treatment. The alternative is that at least two treatments have a different probability of success.


x : array_like, 2d (N,k)

data with N cases and k variables


q_stat : float

test statistic

pvalue : float

pvalue from the chisquare distribution


In Wikipedia terminology, rows are blocks and columns are treatments. The number of rows N, should be large for the chisquare distribution to be a good approximation. The Null hypothesis of the test is that all treatments have the same effect.

References SAS Manual for NPAR TESTS