File: hypothesis_dunnett.md

package info (click to toggle)
scipy 1.16.3-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 236,092 kB
  • sloc: cpp: 503,720; python: 345,302; ansic: 195,677; javascript: 89,566; fortran: 56,210; cs: 3,081; f90: 1,150; sh: 857; makefile: 792; pascal: 284; csh: 135; lisp: 134; xml: 56; perl: 51
file content (83 lines) | stat: -rw-r--r-- 2,796 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
---
jupytext:
  text_representation:
    extension: .md
    format_name: myst
    format_version: 0.13
    jupytext_version: 1.16.1
kernelspec:
  display_name: Python 3 (ipykernel)
  language: python
  name: python3
---

+++ {"tags": ["jupyterlite_sphinx_strip"]}

```{eval-rst}
.. notebooklite:: hypothesis_dunnett.md
   :new_tab: True
```

(hypothesis_dunnett)=

+++

# Dunnett's test

Dunnett's test compares the means of multiple experimental groups against a
single control group. In [^1], the influence of drugs on blood count
measurements on three groups of animals is investigated.

The following table summarizes the results of the experiment in which two groups
received different drugs, and one group acted as a control. Blood counts (in
millions of cells per cubic millimeter) were recorded:

```{code-cell}
import numpy as np
control = np.array([7.40, 8.50, 7.20, 8.24, 9.84, 8.32])
drug_a = np.array([9.76, 8.80, 7.68, 9.36])
drug_b = np.array([12.80, 9.68, 12.16, 9.20, 10.55])
```

We would like to see if the means between any of the groups are
significantly different. First, visually examine a box and whisker plot.

```{code-cell}
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, 1)
ax.boxplot([control, drug_a, drug_b])
ax.set_xticklabels(["Control", "Drug A", "Drug B"])
ax.set_ylabel("mean")
plt.show()
```

Note the overlapping interquartile ranges of the drug A group and control group
and the apparent separation between the drug B group and control group.

Next, we will use {func}`Dunnett's test <scipy.stats.dunnett>` to assess whether
the difference between group means is significant while controlling the
family-wise error rate: the probability of making any false discoveries.

Let the null hypothesis be that the experimental groups have the same mean as
the control and the alternative be that an experimental group does not have the
same mean as the control. We will consider a 5% family-wise error rate to be
acceptable, and therefore we choose 0.05 as the threshold for significance.

```{code-cell}
from scipy.stats import dunnett
res = dunnett(drug_a, drug_b, control=control)
res.pvalue
```

The p-value corresponding with the comparison between group A and control
exceeds 0.05, so we do not reject the null hypothesis for that comparison.
However, the p-value corresponding with the comparison between group B and
control is less than 0.05, so we consider the experimental results to be
evidence against the null hypothesis in favor of the alternative: group B has a
different mean than the control group.

## References

[^1]: Dunnett, Charles W. (1955) "A Multiple Comparison Procedure for Comparing
Several Treatments with a Control." Journal of the American Statistical
Association, 50:272, 1096-1121. {doi}`10.1080/01621459.1955.10501294`