scikit_posthocs.posthoc_nemenyi_friedman

scikit_posthocs.posthoc_nemenyi_friedman(a, y_col=None, block_col=None, group_col=None, melted=False, sort=False)

Calculate pairwise comparisons using Nemenyi post hoc test for unreplicated blocked data. This test is usually conducted post hoc if significant results of the Friedman’s test are obtained. The statistics refer to upper quantiles of the studentized range distribution (Tukey) [1], [2], [3].

Parameters:
  • a (array_like or pandas DataFrame object) –

    An array, any object exposing the array interface or a pandas DataFrame.

    If melted is set to False (default), a is a typical matrix of block design, i.e. rows are blocks, and columns are groups. In this case you do not need to specify col arguments.

    If a is an array and melted is set to True, y_col, block_col and group_col must specify the indices of columns containing elements of correspondary type.

    If a is a Pandas DataFrame and melted is set to True, y_col, block_col and group_col must specify columns names (strings).

  • y_col (str or int) – Must be specified if a is a pandas DataFrame object. Name of the column that contains y data.
  • block_col (str or int) – Must be specified if a is a pandas DataFrame object. Name of the column that contains blocking factor values.
  • group_col (str or int) – Must be specified if a is a pandas DataFrame object. Name of the column that contains treatment (group) factor values.
  • melted (bool, optional) – Specifies if data are given as melted columns “y”, “blocks”, and “groups”.
  • sort (bool, optional) – If True, sort data by block and group columns.
Returns:

result – P values.

Return type:

pandas DataFrame

Notes

A one-way ANOVA with repeated measures that is also referred to as ANOVA with unreplicated block design can also be conducted via Friedman’s test. The consequent post hoc pairwise multiple comparison test according to Nemenyi is conducted with this function.

This function does not test for ties.

References

[1]J. Demsar (2006), Statistical comparisons of classifiers over multiple data sets, Journal of Machine Learning Research, 7, 1-30.
[2]P. Nemenyi (1963) Distribution-free Multiple Comparisons. Ph.D. thesis, Princeton University.
[3]L. Sachs (1997), Angewandte Statistik. Berlin: Springer. Pages: 668-675.

Examples

>>> # Non-melted case, x is a block design matrix, i.e. rows are blocks
>>> # and columns are groups.
>>> x = np.array([[31,27,24],[31,28,31],[45,29,46],[21,18,48],[42,36,46],[32,17,40]])
>>> sp.posthoc_nemenyi_friedman(x)