scikit_posthocs.posthoc_nemenyi

scikit_posthocs.posthoc_nemenyi(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, dist: str = 'chi', sort: bool = True) → DataFrame

Post hoc pairwise test for multiple comparisons of mean rank sums (Nemenyi’s test). May be used after Kruskal-Wallis one-way analysis of variance by ranks to do pairwise comparisons [1].

Parameters:
  • a (array_like or pandas DataFrame object) – An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional. Second dimension may vary, i.e. groups may have different lengths.

  • val_col (str, optional) – 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 a is a pandas DataFrame object.

  • group_col (str, optional) – Name of a DataFrame column that contains independent variable values (grouping or predictor variable). Values should have a nominal scale (categorical). Must be specified if a is a pandas DataFrame object.

  • dist (str, optional) – Method for determining the p value. The default distribution is “chi” (chi-squared), else “tukey” (studentized range).

  • sort (bool, optional) – Specifies whether to sort DataFrame by group_col or not. Recommended unless you sort your data manually.

Returns:

result – P values.

Return type:

pandas.DataFrame

Warns:

UserWarning – If dist="tukey" is requested for data containing ties, because Tukey p values are not corrected for ties.

Notes

A tie correction is applied when dist="chi". Tukey p values are not corrected for ties. Rows with a missing value or group label are excluded before ranking and counting.

References

Examples

>>> import numpy as np
>>> import scikit_posthocs as sp
>>> x = [[1,2,3,5,1], [12,31,54, np.nan], [10,12,6,74,11]]
>>> sp.posthoc_nemenyi(x)