scikit_posthocs.test_jonckheere
- scikit_posthocs.test_jonckheere(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, alternative: str = 'two-sided', continuity: bool = False, sort: bool = False) tuple[float, float]
Jonckheere-Terpstra test for ordered alternatives.
The null hypothesis, H0: theta_1 = theta_2 = … = theta_k, is tested against a simple order hypothesis, HA: theta_1 <= theta_2 <= … <= theta_k (theta_1 < theta_k), where group order is taken from the natural (or categorical) order of group_col, i.e. the order in which groups first appear in the data unless sort is True [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), given in the a priori hypothesized order. Must be specified if
datais a pandas DataFrame object.alternative (str = "two-sided") – The alternative hypothesis, one of “two-sided”, “greater”, or “less”.
continuity (bool = False) – Whether to apply a continuity correction, as for Kendall’s tau.
sort (bool = False) – If True, sort data by group_col (alphabetically) instead of preserving the order in which groups appear in the data.
- Returns:
P value and z statistic.
- Return type:
tuple[float, float]
Notes
P values are computed from the standard normal distribution. In the presence of ties, the standard deviation of the Jonckheere-Terpstra statistic is corrected following Kloke and McKean (2015) [2].
References
Examples
>>> import scikit_posthocs as sp >>> x = [[22, 23, 35], [60, 59, 54], [98, 78, 50]] >>> sp.test_jonckheere(x)