BCompare groups · Guide test 042
Dunnett test
Compares several treatment means with a common control using their joint distribution.
Do it in CodeSplash
In the app, set it up in Analyze with one of these methods:
- A/B test analysis — SRM check, lifts, CUPED, guardrails and a Bayesian view — Did the treatment change the metrics, and is the test trustworthy enough to decide?
- Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …) — Which groups differ from which?
In Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …), choose Comparison = Dunnett.
Do it in CodeSplash Run this test on your own data, in Python or R.
Bench
Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.
Bench · Dunnett test
Group i has true mean (i − 1) × spread.
Your data
Drag a point or use ↑/↓ to change itIf H₀ were true
- The reference: how |t| varies across samples when H₀ is true, the largest of 3 correlated |t| (Dunnett, df 36).
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .031).
- The hatched rejection region at α = .050: statistics landing here reject H₀.
The whole family
| Pair | Difference in means with 95% simultaneous interval | p | p adj. |
|---|---|---|---|
| .412 | – | ||
| .120 | – | ||
| .012 | .031 |
3 comparisons with group 1 (the control); adjusted by Dunnett's multivariate t. The highlighted row is the one in the reference pane (the most extreme by default).
The formula
With your numbers
- the control group's mean (group 1 here)
- correlated t statistics sharing the control
The verdict
|t| = 2.66, p = .031, Δ = 1.24
p ≤ α = .050: reject H₀
Effect size: Group 4 − Group 1 (difference in means) Δ = 1.239
Only treatment-versus-control comparisons, so it is more powerful than Tukey for that family. The shared control correlates the comparisons; the maximum of the correlated |t| gives the adjusted p.
- Statistic
- 2.659
- p-value
- 0.0309
Dunnett test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: |t| = 2.66, p = .031, Δ = 1.24. The p-value is below α = .050, so the data are hard to reconcile with H₀.
Question and hypotheses
H0j: μj=μ0 for each treatment versus one prespecified control.
Assumptions
Independent normal errors with common variance in a one factor model; group sizes may differ. The family of comparisons must be specified.
Formula
Parameters and notation
sp²=MSE; joint t degrees of freedom are N−k. Correlations reflect the shared control.
Structure of the method
Fit a common-variance model and form each treatment-minus-control contrast. Shared control observations induce positive covariance among contrasts, so the maximum of a correlated multivariate t vector supplies simultaneous calibration. The dependence structure is used directly rather than treating the comparisons as independent or applying an all-pairs range indiscriminately.
Estimated and nuisance parameters
Estimate group means and pooled residual variance. Group sample sizes determine the correlation matrix of standardized contrasts; the control identity, included treatments, and comparison direction are fixed design choices. Numerical multivariate-t integration estimates tail probabilities computationally, not additional population parameters.
Settings and design choices
Prespecify control, one- or two-sided alternatives, familywise alpha, and numerical integration precision or random-state settings where exposed. Selecting the best observed group as 'control' changes the inferential problem. If multiple endpoints or control families are analyzed, the scope of simultaneous protection must be expanded or clearly bounded.
Fitting and adaptation
Refit the common model and rebuild contrast covariance when group sizes or observations change. New candidate treatments enlarge the comparison family and require new critical values. For unequal variances or correlated units, use a justified generalized simultaneous-contrast model rather than assuming the original pooled-variance Dunnett law continues to apply.
Sensitivity and robustness
A very small control group makes every comparison imprecise and highly dependent. Numerical integration can produce small run-to-run p-value differences unless controlled. Common-variance misspecification affects the entire family. Dunnett's many-to-one procedure is distinct from Dunnett T3's unequal-variance all-pairs approximation despite the shared surname.
How to use and calibrate
Use the multivariate t maximum distribution for one or two sided simultaneous inference.
Example application
Compare several candidate interventions with one standard treatment.
Interpretation and pitfalls
Watch out
Dunnett’s original common variance control comparison is different from Dunnett T3 all pair comparisons.
What changed in edition 2
- New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.
Python and R
A is the prespecified common control; familywise error is controlled across treatment-versus-control contrasts.
Validated — Executed successfully in the validation environment · needs numpy, scipy
import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
groups = [rng.normal(m,1,20) for m in (0,.4,.8)]
print(stats.dunnett(groups[1],groups[2],control=groups[0]))
Output
Dunnett's test (95.0% Confidence Interval) Comparison Statistic p-value Lower CI Upper CI (Sample 0 - Control) 2.338 0.042 0.021 1.393 (Sample 1 - Control) 4.888 0.000 0.792 2.164
Not run — Syntax checked; runtime not verified in the final environment · needs DescTools
set.seed(2026)
d <- data.frame(value=c(rnorm(20),rnorm(20,.4),rnorm(20,.8)), group=factor(rep(c("A","B","C"),each=20)))
print(DescTools::DunnettTest(value~group,d,control="A"))
Sources
- SciPy — SciPy · dunnettdocs.scipy.org
- scipy.stats.dunnettdocs.scipy.org
- DunnettTestsearch.r-project.org
- Statistics guide v4 (historical):
- R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: executed · R: not executed (Rscript unavailable). Python: Ran in the reference's review, on this exact code. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 042, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT042.