{ } Raw JSON

bundles / scipy 1.17.1 / scipy / stats / _multicomp / dunnett

function

scipy.stats._multicomp:dunnett

source: /scipy/stats/_multicomp.py :183

Signature

def   dunnett ( * samples : npt.ArrayLike control : npt.ArrayLike alternative : Literal['two-sided', 'less', 'greater'] = two-sided rng : int | numpy.integer | numpy.random._generator.Generator | numpy.random.mtrand.RandomState | None = None random_state = None )  →  <class 'scipy.stats._multicomp.DunnettResult'>

Summary

Dunnett's test: multiple comparisons of means against a control group.

Extended Summary

This is an implementation of Dunnett's original, single-step test as described in [1].

Parameters

sample1, sample2, ... : 1D array_like

The sample measurements for each experimental group.

control : 1D array_like

The sample measurements for the control group.

alternative : {'two-sided', 'less', 'greater'}, optional

Defines the alternative hypothesis.

The null hypothesis is that the means of the distributions underlying the samples and control are equal. The following alternative hypotheses are available (default is 'two-sided'):

  • 'two-sided': the means of the distributions underlying the samples and control are unequal.

  • 'less': the means of the distributions underlying the samples are less than the mean of the distribution underlying the control.

  • 'greater': the means of the distributions underlying the samples are greater than the mean of the distribution underlying the control.

rng : `numpy.random.Generator`, optional

Pseudorandom number generator state. When rng is None, a new numpy.random.Generator is created using entropy from the operating system. Types other than numpy.random.Generator are passed to numpy.random.default_rng to instantiate a Generator.

Returns

res : `~scipy.stats._result_classes.DunnettResult`

An object containing attributes:

statistic

statistic

pvalue

pvalue

And the following method:

confidence_interval(confidence_level=0.95) :

Compute the difference in means of the groups with the control +- the allowance.

Notes

Like the independent-sample t-test, Dunnett's test [1] is used to make inferences about the means of distributions from which samples were drawn. However, when multiple t-tests are performed at a fixed significance level, the "family-wise error rate" - the probability of incorrectly rejecting the null hypothesis in at least one test - will exceed the significance level. Dunnett's test is designed to perform multiple comparisons while controlling the family-wise error rate.

Dunnett's test compares the means of multiple experimental groups against a single control group. Tukey's Honestly Significant Difference Test is another multiple-comparison test that controls the family-wise error rate, but tukey_hsd performs all pairwise comparisons between groups. When pairwise comparisons between experimental groups are not needed, Dunnett's test is preferable due to its higher power.

The use of this test relies on several assumptions.

  • The observations are independent within and among groups.

  • The observations within each group are normally distributed.

  • The distributions from which the samples are drawn have the same finite variance.

Array API Standard Support

dunnett has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variable SCIPY_ARRAY_API=1 and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.

====================  ====================  ====================
Library               CPU                   GPU
====================  ====================  ====================
NumPy                 ✅                     n/a                 
CuPy                  n/a                   ⛔                   
PyTorch               ⛔                     ⛔                   
JAX                   ⛔                     ⛔                   
Dask                  ⛔                     n/a                 
====================  ====================  ====================

See dev-arrayapi for more information.

Examples

We'll use data from [2]_, Table 1. The null hypothesis is that the means of the distributions underlying the samples and control are equal. First, we test that the means of the distributions underlying the samples and control are unequal (``alternative='two-sided'``, the default).
import numpy as np
from scipy.stats import dunnett
samples = [[3.8, 2.7, 4.0, 2.4], [2.8, 3.4, 3.7, 2.2, 2.0]]
control = [2.9, 3.0, 2.5, 2.6, 3.2]
res = dunnett(*samples, control=control)
res.statistic
res.pvalue
Now, we test that the means of the distributions underlying the samples are greater than the mean of the distribution underlying the control.
res = dunnett(*samples, control=control, alternative='greater')
res.statistic
res.pvalue
For a more detailed example, see :ref:`hypothesis_dunnett`.

See also

hypothesis_dunnett

Extended example

tukey_hsd

performs pairwise comparison of means.

Aliases

  • scipy.stats.dunnett

Referenced by