statsmodels.stats.gof.chisquare#

statsmodels.stats.gof.chisquare(f_obs, f_exp=None, value=0, ddof=0, return_basic=True)[source]#

chisquare goodness-of-fit test

The null hypothesis is that the distance between the expected distribution and the observed frequencies is value. The alternative hypothesis is that the distance is larger than value. value is normalized in terms of effect size.

The standard chisquare test has the null hypothesis that value=0, that is the distributions are the same.

Parameters:
f_obsarray_like

Observed frequencies.

f_exparray_like, optional

Expected frequencies. If None, then the observed frequencies are assumed to follow a uniform distribution over the bins.

valuefloat

Value of the effect size under the null hypothesis.

ddofint

Degrees of freedom correction.

return_basicbool

If True, return only the chisquare statistic and the p-value as a plain tuple. If False, return a ChisquareResult NamedTuple that additionally reports the degrees of freedom and the name of the distribution used to compute the p-value.

Returns:
chisqfloat

The chisquare test statistic.

pvaluefloat

The p-value based on the chisquare distribution if value is zero, or on the noncentral chisquare distribution otherwise.

If return_basic is False, a ChisquareResult NamedTuple is
returned instead, with fields chisq, pvalue, df, and
distr.

Notes

The case with value greater than zero is similar to an equivalence test, that the exact null hypothesis is replaced by an approximate hypothesis. However, TOST “reverses” null and alternative hypothesis, while here the alternative hypothesis is that the distance (divergence) is larger than a threshold.

References

McLaren, … Drost,…