scikit_posthocs.posthoc_tamhane(a: Union[list, numpy.ndarray, pandas.core.frame.DataFrame], val_col: str = None, group_col: str = None, welch: bool = True, sort: bool = False) → pandas.core.frame.DataFrame

Tamhane’s T2 all-pairs comparison test for normally distributed data with unequal variances. Tamhane’s T2 test can be performed for all-pairs comparisons in an one-factorial layout with normally distributed residuals but unequal groups 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].

  • 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.
  • welch (bool, optional) – If True, use Welch’s approximate solution for calculating the degree of freedom. T2 test uses the usual df = N - 2 approximation.
  • sort (bool, optional) – If True, sort data by block and group columns.

result – P values.

Return type:



The p values are computed from the t-distribution and adjusted according to Dunn-Sidak.


[1]A.C. Tamhane (1979), A Comparison of Procedures for Multiple Comparisons of Means with Unequal Variances. Journal of the American Statistical Association, 74, 471-480.


>>> 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_tamhane(x, val_col='values', group_col='groups')