scikit_posthocs.posthoc_lsd
- scikit_posthocs.posthoc_lsd(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, p_adjust: str | None = None, sort: bool = False) DataFrame
Fisher’s Least Significant Difference (LSD) all-pairs comparison test for normally distributed data with equal group variances, following a parametric ANOVA [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. Left as None (the default), this reproduces Fisher’s protected LSD test, which is only valid when applied after a significant omnibus ANOVA F-test.
sort (bool, optional) – If True, sort data by group columns.
- Returns:
result – P values.
- Return type:
pandas.DataFrame
Notes
Test statistics use the pooled within-group variance, equivalent to posthoc_ttest with pool_sd=True and no p value adjustment.
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_lsd(x, val_col='values', group_col='groups')