scikit_posthocs.posthoc_npm_test(a: Union[list, ndarray, DataFrame], val_col: Optional[str] = None, group_col: Optional[str] = None, sort: bool = False) DataFrame

Calculate pairwise comparisons using Nashimoto and Wright´s all-pairs comparison procedure (NPM test) for simply ordered mean ranksums.

NPM test is basically an extension of Nemenyi´s procedure for testing increasingly ordered alternatives 1.

  • a (array_like or pandas DataFrame object) – 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 block and group columns.

  • 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)


result – P values.

Return type



The p values are estimated from the studentized range distribution. If the medians are already increasingly ordered, than the NPM-test simplifies to the ordinary Nemenyi test



Nashimoto, K., Wright, F.T., (2005), Multiple comparison procedures for detecting differences in simply ordered means. Comput. Statist. Data Anal. 48, 291–306.


>>> x = np.array([[102,109,114,120,124],
>>> sp.posthoc_npm_test(x)