scikit_posthocs.test_median
- scikit_posthocs.test_median(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, correction: bool = False, sort: bool = False) tuple[float, float, int]
Brown-Mood median test.
Tests the null hypothesis that all groups share a common population median, 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.correction (bool = False) – Whether to apply Yates’ continuity correction in the underlying chi-squared test.
sort (bool = False) – If True, sort data by group_col.
- Returns:
P value, chi-squared statistic, and degrees of freedom.
- Return type:
tuple[float, float, int]
Notes
Observations are classified as above or at-or-below the grand median (computed once, from the pooled sample) and compared across groups with Pearson’s chi-squared test of independence.
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_median(x)