scikit_posthocs.posthoc_dunnett_t3
- scikit_posthocs.posthoc_dunnett_t3(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, sort: bool = False) DataFrame
Dunnett’s T3 all-pairs comparison test for normally distributed data with unequal group variances. A total of m = k(k-1)/2 hypotheses can be tested. The null hypothesis is tested in the two-tailed test against the alternative hypothesis [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.
sort (bool, optional) – If True, sort data by group columns.
- Returns:
result – P values.
- Return type:
pandas.DataFrame
Notes
Test statistics are Welch t values, with degrees of freedom rounded to the nearest integer (matching PMCMRplus; this is what numerically distinguishes T3 from posthoc_tamhane, whose Welch df are not rounded). P values are obtained with a single-step Dunn-Sidak-type adjustment, 1 - (1 - p) ** m with m = k * (k - 1) / 2 the number of pairwise comparisons, applied to the raw two-sided Welch t p value of each pair. This reproduces PMCMRplus’s studentized maximum modulus computation (an equicorrelated multivariate t distribution with zero off-diagonal correlation reduces exactly to this closed form), without requiring a multivariate-t dependency.
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_dunnett_t3(x, val_col='values', group_col='groups')