BCompare groups · Guide test 046
Tamhane T2 test
Uses unequal variance pairwise comparisons with multiplicity control.
Do it in CodeSplash
In the app, set it up in Analyze with this method:
- Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …) — Which groups differ from which?
In One-way ANOVA (Welch / classic), choose Post hoc comparisons = Tamhane T2. In Pairwise comparisons (Tukey, Games–Howell, Dunnett, Dunn, Steel–Dwass …), choose Comparison = Tamhane T2.
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 · Tamhane T2 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 6 independent |t| (Šidák), df 11.8.
- Your statistic, from the data above.
- The p-value: the area at least as extreme as yours (p = .855).
- 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. |
|---|---|---|---|
| .428 | .965 | ||
| .363 | .933 | ||
| .275 | .855 | ||
| .795 | 1.000 | ||
| .626 | .997 | ||
| .825 | 1.000 |
6 pairs; adjusted by Šidák. The highlighted row is the one in the reference pane (the most extreme by default).
The formula
With your numbers
- number of pairs in the family
- two-sided Welch t p-value for the pair
The verdict
|t| = 1.14, p = .855, Δ = −0.91
p > α = .050: compatible with H₀
Effect size: Group 1 − Group 4 (difference in means) Δ = −0.909
Welch t per pair with Šidák's adjustment: never anti-conservative for unequal variances, at some cost in power.
- Statistic
- 1.145
- p-value
- 0.8548
Tamhane T2 test on Group 1: n = 10; Group 2: n = 10; Group 3: n = 10; Group 4: n = 10: |t| = 1.14, p = .855, Δ = −0.91. The p-value is above α = .050, so the data are compatible with H₀.
Question and hypotheses
H0ij: μi=μj for each pair of independent groups.
Assumptions
Independent groups and independent observations; approximately normal within group sampling for small sample inference; variances may differ.
Formula
Parameters and notation
k is the group count; ni, x̄i, si² are group summaries; m is the number of pairwise comparisons.
Structure of the method
Calculate two-sided pairwise Welch t probabilities and apply the documented Dunn–Sidak adjustment across the all-pairs family. Tamhane T2 includes the unequal-variance degrees-of-freedom approximation; the package also exposes a distinct T2-prime option using a different reference degree of freedom, so the option is part of the method specification.
Estimated and nuisance parameters
Estimate group means and separate variances, then derive pairwise standard errors and degrees of freedom. The number of comparisons is fixed by the selected group family. Neither the Sidak exponent nor the familywise alpha is estimated from observed significance, and the method does not fit a joint multivariate mean model.
Settings and design choices
Prespecify the Welch versus T2-prime option, familywise alpha, eligible pairs, and transformation. The baseline default should be described as T2 with Welch approximation unless explicitly changed. Adjustment methods differ in assumptions; replacing Sidak with Holm can be reasonable but creates a differently named comparison procedure.
Fitting and adaptation
Refit group summaries and rerun all pairwise calculations if data or family membership change. For reproducibility, retain raw pairwise p-values alongside adjusted values and the comparison count. Adaptation to a new design requires checking dependence among observations and the validity of each marginal test before discussing multiplicity correction.
Sensitivity and robustness
Small samples and unstable unequal-variance estimates can degrade marginal p-values before adjustment is applied. Sidak is not a blanket theorem for arbitrary dependence among arbitrary tests. The shared-group dependence of pairwise comparisons and the approximations used by this named method should be acknowledged rather than advertising exact finite-sample protection universally.
How to use and calibrate
Compute each two sided Welch p value pij and use Šidák adjustment 1−(1−pij)^m for m=k(k−1)/2 comparisons.
Example application
Compare treatment means when group variances and sample sizes differ.
Interpretation and pitfalls
Watch out
The adjustment and Welch approximations are part of Tamhane T2; arbitrary dependence is not universally handled by Šidák.
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
Read the matrix of adjusted p-values. This is an independent-group example; Nemenyi also has a separate Friedman/block version. The first factor level is control for many-to-one procedures.
Not run — Python launcher syntax checked; R backend runtime not verified · needs Python standard library + Rscript; R packages: PMCMRplus
# Python launcher for the complete R implementation below.
# Requires Rscript on PATH and the listed R packages.
import shutil
import subprocess
rscript = shutil.which("Rscript")
if rscript is None:
raise RuntimeError("Install R and make Rscript available on PATH.")
r_code = r"""
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(PMCMRplus::tamhaneT2Test(value~group,data=d))
"""
# No shell interpolation. A failed R execution raises an error in Python.
result = subprocess.run([rscript, "--vanilla", "-"], input=r_code,
text=True, capture_output=True)
print(result.stdout)
if result.stderr:
print(result.stderr)
result.check_returncode()
Not run — Syntax checked; runtime not verified in the final environment · needs PMCMRplus
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(PMCMRplus::tamhaneT2Test(value~group,data=d))
Sources
- PMCMRplus — PMCMRplus · tamhaneT2TestAuthor documentation/source reviewed: PMCMRplus 1.9.12.search.r-project.org
- tamhaneT2Testsearch.r-project.org
- Statistics guide v4 (historical):
- Python: Python launcher syntax checked; R backend runtime not verified · R: Syntax checked; runtime not verified in the final environment
- Reference's record:
- Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Python-to-R bridge; Rscript is unavailable. R code was not executed. Python: Not run in the reference's review: Python-to-R bridge; Rscript is unavailable. R code was not executed. R: Reviewed but not run: R wasn't available to the reference's authors.
From the CodeSplash statistics guide (v4), entry 046, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT046.