bundles / scipy latest / scipy / stats / _multicomp / dunnett
function
scipy.stats._multicomp:dunnett
source: build-install/usr/lib/python3.14/site-packages/scipy/stats/_multicomp.py:189
Signature
def dunnett(*samples: npt.ArrayLike, control: npt.ArrayLike, alternative: Literal['two-sided', 'less', 'greater'] = two-sided, rng: SeedType = 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
*samples: 1D array_likeThe sample measurements for each experimental group.
control: 1D array_likeThe sample measurements for the control group.
alternative: {'two-sided', 'less', 'greater'}, optionalDefines 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`, optionalPseudorandom number generator state. When
rngis 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 aGenerator.
Returns
res: `~scipy.stats._result_classes.DunnettResult`An object containing attributes:
statistic
The computed statistic of the test for each comparison. The element at index
iis the statistic for the comparison between groupsiand the control.pvalue
The computed p-value of the test for each comparison. The element at index
iis the p-value for the comparison between groupiand the control.
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.
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✗
array([0.58316, 0.99819])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✗
array([0.30219, 0.69114])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