scikit_posthocs.posthoc_median

scikit_posthocs.posthoc_median(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, p_adjust: str | None = None, sort: bool = False) DataFrame

Brown-Mood all-pairs median test, a nonparametric alternative to Kruskal-Wallis-type all-pairs tests robust to outliers and skew [1].

Parameters:
  • a (Union[list, np.ndarray, DataFrame]) – An array, any object exposing the array interface or a pandas DataFrame.

  • 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.

  • p_adjust (str, optional) – Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details.

  • sort (bool, optional) – If True, sort data by group columns.

Returns:

result – P values.

Return type:

pandas.DataFrame

Notes

For each pair of groups, observations are classified as above or at-or-below the grand median (computed once, from the pooled sample of both groups’ parent dataset) and compared with Pearson’s chi-squared test (no continuity correction), following PMCMRplus’s medianAllPairsTest.

References

Examples

>>> import scikit_posthocs as sp
>>> import pandas as pd
>>> x = pd.DataFrame({"a": [1,2,3,5,1], "b": [12,31,54,62,12], "c": [10,12,6,74,11]})
>>> x = x.melt(var_name='groups', value_name='values')
>>> sp.posthoc_median(x, val_col='values', group_col='groups')