scikit_posthocs.posthoc_ttest
- scikit_posthocs.posthoc_ttest(a: list | ndarray | DataFrame, val_col: str = None, group_col: str = None, pool_sd: bool = False, equal_var: bool = True, p_adjust: str = None, sort: bool = False) DataFrame
Pairwise T test for multiple comparisons of independent groups. May be used after a parametric ANOVA to do pairwise comparisons.
- Parameters:
a (array_like or pandas DataFrame object) – An array, any object exposing the array interface or a pandas DataFrame. Array must be two-dimensional.
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.
equal_var (bool, optional) – If True (default), perform a standard independent test that assumes equal population variances [1]. If False, perform Welch’s t-test, which does not assume equal population variance [2].
pool_sd (bool, optional) – Calculate a common SD for all groups and use that for all comparisons (this can be useful if some groups are small). This method does not actually call scipy ttest_ind() function, so extra arguments are ignored. Default is False.
p_adjust (str, optional) – Method for adjusting p values. See statsmodels.sandbox.stats.multicomp for details. Available methods are: ‘bonferroni’ : one-step correction ‘sidak’ : one-step correction ‘holm-sidak’ : step-down method using Sidak adjustments ‘holm’ : step-down method using Bonferroni adjustments ‘simes-hochberg’ : step-up method (independent) ‘hommel’ : closed method based on Simes tests (non-negative) ‘fdr_bh’ : Benjamini/Hochberg (non-negative) ‘fdr_by’ : Benjamini/Yekutieli (negative) ‘fdr_tsbh’ : two stage fdr correction (non-negative) ‘fdr_tsbky’ : two stage fdr correction (non-negative)
sort (bool, optional) – Specifies whether to sort DataFrame by group_col or not. Recommended unless you sort your data manually.
- Returns:
result – P values.
- Return type:
pandas.DataFrame
References
Examples
>>> x = [[1,2,3,5,1], [12,31,54, np.nan], [10,12,6,74,11]] >>> sp.posthoc_ttest(x, p_adjust = 'holm') array([[-1. , 0.04600899, 0.31269089], [ 0.04600899, -1. , 0.6327077 ], [ 0.31269089, 0.6327077 , -1. ]])