critdd package

Subpackages

Submodules

critdd.diagram module

A module for assembling critical difference diagrams.

class critdd.diagram.AbstractDiagram

Bases: ABC

Abstract base class for critical difference diagrams in Tikz.

to_file(path, *args, **kwargs)

Store this diagram in a file.

Note

Storing Tikz code in a “.png” file or “.svg” file is not yet supported.

Parameters:
  • path – The file path where this diagram is to be stored. Has to be ending on “.tex”, “.tikz”, “.pdf”, “.png”, or “.svg”.

  • *args (optional) – See to_str.

  • **kwargs (optional) – See to_str.

abstract to_str(alpha=0.05, adjustment='holm', **kwargs)

Get a str object with the Tikz code for this diagram.

Parameters:
  • alpha (optional) – The threshold for rejecting a p value. Defaults to 0.05.

  • adjustment (optional) – The multiple testing adjustment. Defaults to “holm”. Another possible value is “bonferroni”.

  • reverse_x (optional) – Whether to reverse the x direction. Defaults to False.

  • as_document (optional) – Whether to include a \documentclass and a document environment. Defaults to False.

  • tikzpicture_options (optional) – A dict with options for the tikzpicture environment.

  • axis_options (optional) – A dict with options for the axis environment.

  • preamble (optional) – A str with LaTeX commands. Only used if as_document==True. Defaults to None.

Returns:

A str object with the Tikz code for this diagram.

class critdd.diagram.Diagram(X, *, treatment_names=None, maximize_outcome=False)

Bases: AbstractDiagram

A regular critical difference diagram.

Parameters:
  • X – An (n, k)-shaped matrix of observations, where n is the number of observations and k is the number of treatments.

  • treatment_names (optional) – The names of the k treatments. Defaults to None.

  • maximize_outcome (optional) – Whether the ranks represent a maximization (True) or a minimization (False) of the outcome. Defaults to False.

property average_ranks
get_groups(alpha=0.05, adjustment='holm', return_names=False, return_singletons=True)

Get the groups of indistinguishable treatments.

Parameters:
  • alpha (optional) – The threshold for rejecting a p value. Defaults to 0.05.

  • adjustment (optional) – The multiple testing adjustment. Defaults to “holm”. Another possible value is “bonferroni”.

  • return_names (optional) – Whether to represent the treatments in the groups by their names (True) or by their indices (False). Defaults to False.

  • return_singletons (optional) – Whether to return groups with single elements. Defaults to True.

Returns:

A list of statistically indistinguishable groups.

property maximize_outcome
to_str(alpha=0.05, adjustment='holm', **kwargs)

Get a str object with the Tikz code for this diagram.

Parameters:
  • alpha (optional) – The threshold for rejecting a p value. Defaults to 0.05.

  • adjustment (optional) – The multiple testing adjustment. Defaults to “holm”. Another possible value is “bonferroni”.

  • reverse_x (optional) – Whether to reverse the x direction. Defaults to False.

  • as_document (optional) – Whether to include a \documentclass and a document environment. Defaults to False.

  • tikzpicture_options (optional) – A dict with options for the tikzpicture environment.

  • axis_options (optional) – A dict with options for the axis environment.

  • preamble (optional) – A str with LaTeX commands. Only used if as_document==True. Defaults to None.

Returns:

A str object with the Tikz code for this diagram.

class critdd.diagram.Diagrams(Xs, *, diagram_names=None, treatment_names=None, maximize_outcome=False)

Bases: AbstractDiagram

A sequence of critical difference diagrams, plotted on a single 2-dimensional axis.

Parameters:
  • Xs – Observations, given either as a list of length m of (n, k)-shaped matrices or as an (m, n, k)-shaped tensor, where m is the number of diagrams, n is the number of observations, and k is the number of treatments.

  • diagram_names (optional) – The names of the m diagrams. Defaults to None.

  • treatment_names (optional) – The names of the k treatments. Defaults to None.

  • maximize_outcome (optional) – Whether the ranks represent a maximization (True) or a minimization (False) of the outcome. Defaults to False.

property maximize_outcome
to_str(alpha=0.05, adjustment='holm', **kwargs)

Get a str object with the Tikz code for this diagram.

Parameters:
  • alpha (optional) – The threshold for rejecting a p value. Defaults to 0.05.

  • adjustment (optional) – The multiple testing adjustment. Defaults to “holm”. Another possible value is “bonferroni”.

  • reverse_x (optional) – Whether to reverse the x direction. Defaults to False.

  • as_document (optional) – Whether to include a \documentclass and a document environment. Defaults to False.

  • tikzpicture_options (optional) – A dict with options for the tikzpicture environment.

  • axis_options (optional) – A dict with options for the axis environment.

  • preamble (optional) – A str with LaTeX commands. Only used if as_document==True. Defaults to None.

Returns:

A str object with the Tikz code for this diagram.

property treatment_names

critdd.stats module

A module for Friedman hypothesis tests.

These hypothesis tests are implemented in analogy to the hypothesis tests that are implemented in scipy.stats.

class critdd.stats.ChiSquareFriedmanResult(pvalue, statistic, n_df, average_ranks, n, maximize_outcome)

Bases: tuple

property average_ranks
property maximize_outcome
property n
property n_df
property pvalue
property statistic
class critdd.stats.FDistributedFriedmanResult(pvalue, statistic, chi_square_result, n_df_1, n_df_2)

Bases: tuple

property chi_square_result
property n_df_1
property n_df_2
property pvalue
property statistic
critdd.stats.adjust_pairwise_tests(P, adjustment)
critdd.stats.chi_square_distributed(X, *, maximize_outcome=False)

This version of the Friedman test uses a Chi-square-distributed test statistic.

critdd.stats.f_distributed(X, *, maximize_outcome=False)

This version of the Friedman test uses an F-distributed test statistic.

critdd.stats.friedman(X, *, maximize_outcome=False)

Calculate the Friedman hypothesis test.

The Friedman test tests the null hypothesis that n observations have the same distribution across all k treatments. This version of the test uses an F-distributed test statistic.

Parameters:
  • X – An (n, k)-shaped matrix of observations.

  • maximize_outcome – Whether the ranks represent a maximization (True) or a minimization (False) of the outcome. Defaults to False.

Returns:

An FDistributedFriedmanResult with properties pvalue (the p value), statistic (the test statistic), chi_square_result (a ChiSquareFriedmanResult), n_df_1 (first number of degrees of freedom), and n_df_2 (second number of degrees of freedom). The chi_square_result has additional properties average_ranks (the average ranks of the treatments), n (the number of observations), and maximize_outcome.

Return type:

r

critdd.stats.pairwise_tests(X)

critdd.tikz module

A module for the Tikz export.

exception critdd.tikz.ExportException(path)

Bases: Exception

critdd.tikz.requires_document(path)

Determine whether an export requires as_document=True.

critdd.tikz.to_file(path, tikz_code)

Export the tikz_code to a file.

critdd.tikz.to_str(average_ranks, groups, treatment_names, *, reverse_x=False, as_document=False, tikzpicture_options={}, axis_options={}, preamble=None, title=None)

Return a string with Tikz code.

critdd.tikz_2d module

A module for the Tikz export of 2-dimensional axes.

critdd.tikz_2d.to_str(average_ranks, groups, treatment_names, diagram_names, *, reverse_x=False, as_document=False, tikzpicture_options={}, axis_options={}, preamble=None)

Return a string with Tikz code.

Module contents

critdd: critical difference diagrams with Python and Tikz.