scikit_posthocs.test_hartley
- scikit_posthocs.test_hartley(data: _Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str] | DataFrame, val_col: str | None = None, group_col: str | None = None, n_perm: int = 100000, sort: bool = False) tuple[float, float, int]
Hartley’s maximum F-ratio test of homogeneity of variances.
Tests the null hypothesis that the variances in each of the groups are equal, against the alternative that at least one differs [1].
- Parameters:
data (Union[List, numpy.ndarray, DataFrame]) – An array, any object exposing the array interface or a pandas DataFrame with data values.
val_col (str = None) – Name of a DataFrame column that contains dependent variable values (test or response variable). Values should have a non-nominal scale. Must be specified if
datais a pandas DataFrame object.group_col (str = None) – Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Must be specified if
datais a pandas DataFrame object.n_perm (int = 100000) – Number of Monte Carlo samples used to approximate the null distribution of the maximum F-ratio statistic.
sort (bool = False) – If True, sort data by group_col.
- Returns:
P value, F-max statistic, and degrees of freedom (of the minimum-variance group).
- Return type:
tuple[float, float, int]
Notes
Hartley’s test requires a (nearly) balanced design; a warning is issued otherwise. The p value is approximated by Monte Carlo simulation of k independent chi-squared(df) variables (df taken from the minimum-variance group, following PMCMRplus), rather than PMCMRplus’s exact pmaxFratio distribution (which has no scipy equivalent).
References
Examples
>>> import scikit_posthocs as sp >>> x = [[1,2,3,5,1], [12,31,54,62,12], [10,12,6,74,11]] >>> sp.test_hartley(x)