scikit_posthocs.posthoc_steel
- scikit_posthocs.posthoc_steel(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, control: str | None = None, alternative: Literal['two-sided', 'less', 'greater'] = 'two-sided', p_adjust: str | None = None, sort: bool = False, to_matrix: bool = True) Series | DataFrame
Steel’s many-to-one rank test [1], a nonparametric alternative to Dunnett’s test for comparisons of several treatment groups against one control group.
- 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.
control (str, optional) – Name of the control group within the group_col column. Must be specified if a is a pandas DataFrame.
alternative (['two-sided', 'less', or 'greater'], optional) – Whether to get the p-value for the one-sided hypothesis (‘less’ or ‘greater’) or for the two-sided hypothesis (‘two-sided’). Defaults to ‘two-sided’.
p_adjust (str, optional) – Method for adjusting p values across the treatment-vs-control comparisons. See statsmodels.sandbox.stats.multicomp for details.
sort (bool, optional) – Specifies whether to sort DataFrame by group_col or not.
to_matrix (bool, optional) – Specifies whether to return a DataFrame or a Series. If True, a DataFrame is returned with some NaN values since it’s not a pairwise comparison. Default is True.
- Returns:
result – P values.
- Return type:
pandas.Series or pandas.DataFrame
Notes
This implements the normal-approximation variant of Steel’s test: each treatment group is compared to the control with a Mann-Whitney U test (scipy.stats.mannwhitneyu), and the resulting p values across treatments may be combined with p_adjust. PMCMRplus’s steelTest instead looks up exact critical rank-sum values from a fixed table (balanced designs only, n <= 20, k <= 9, alpha = 0.05); that table is not reproduced here.
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_steel(x, val_col='values', group_col='groups', control='a')