statsmodels.stats.contingency_tables.cochrans_q#
- statsmodels.stats.contingency_tables.cochrans_q(x, return_object=None)[source]#
Cochran’s Q test for identical binomial proportions
- Parameters:
- xarray_like, 2d (
N,k) data with N cases and k variables
- return_objectbool,
optional No longer used.
cochrans_qalways returns aCochransQResult, which supports both the attribute access of the bunch thatreturn_object=Trueused to produce and the positional unpacking of the(statistic, pvalue, df)tuple thatreturn_object=Falseused to produce.Deprecated since version 0.15.0:
return_objectno longer affects the return value and will be removed in statsmodels 0.16.0. Passing it raises aFutureWarning; simply stop passing it.
- xarray_like, 2d (
- Returns:
CochransQResultA NamedTuple with fields:
- statisticfloat
test statistic
- pvaluefloat
pvalue from the chisquare distribution
- dfint
degrees of freedom of the chisquare distribution
CochransQResultunpacks and indexes exactly like the(statistic, pvalue, df)tuple thatreturn_object=Falsereturned, and exposes the samestatistic,pvalueanddfattributes as the bunch thatreturn_object=Truereturned. SeeCochransQResult.
Notes
Cochran’s Q is a k-sample extension of the McNemar test. If there are only two groups, then Cochran’s Q test and the McNemar test are equivalent.
The procedure tests that the probability of success is the same for every group. The alternative hypothesis is that at least two groups have a different probability of success.
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
https://en.wikipedia.org/wiki/Cochran_test SAS Manual for NPAR TESTS