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 thanvalue.valueis 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.
- value
float Value of the effect size under the null hypothesis.
- ddof
int 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
ChisquareResultNamedTuple that additionally reports the degrees of freedom and the name of the distribution used to compute the p-value.
- Returns:
- chisq
float The chisquare test statistic.
- pvalue
float The p-value based on the chisquare distribution if
valueis zero, or on the noncentral chisquare distribution otherwise.Ifreturn_basicisFalse,aChisquareResultNamedTupleisreturnedinstead,withfieldschisq,pvalue,df,anddistr.
- chisq
See also
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,…