Post Hoc Comparisons: Dunnett, Games-Howell & Dunn
An ANOVA says that the group means are not all equal, and few studies are about that sentence. The claim that reaches a paper is a difference between two named groups, and a design with four groups offers six of them. A post hoc procedure estimates a set of differences and widens each interval so that the whole set holds together. This page fixes the set first, then runs Tukey’s HSD, Dunnett’s test, Games-Howell, and Dunn’s test on one mouse study, in R and Python.
Get the data
Section titled “Get the data”Download triglycerides.csv into your working directory. The invented table has 48 rows, one per mouse, and three columns: mouse_id, treatment, and tg_mg_dl, the fasting plasma triglyceride concentration in mg/dL. Twelve mice on a high-fat diet received vehicle and twelve received each of three compounds. Each mouse was dosed and bled separately, so each row is one experimental unit.
The values come from a simulation with known answers. The true means are 150 mg/dL for vehicle, 110 for Compound A, 135 for Compound B, and 150 for Compound C, so the true effects against vehicle are −40, −15, and 0 mg/dL. The true standard deviations differ on purpose: 20, 10, 25, and 35 mg/dL.
Both tabs define one helper that prints a contrast, its interval, and its adjusted p-value on one line. The later sections reuse it.
library(multcomp)library(ggplot2)
tg <- read.csv("triglycerides.csv")groups <- c("Vehicle", "Compound A", "Compound B", "Compound C")tg$treatment <- factor(tg$treatment, levels = groups)dir.create("outputs", showWarnings = FALSE)
#' Print contrasts with their intervals and adjusted p-values.#'#' @param label The names of the contrasts.#' @param estimate The differences in means.#' @param lower The lower limits of the intervals.#' @param upper The upper limits of the intervals.#' @param p_adjusted The adjusted p-values.#' @return Invisibly, NULL.PrintContrast <- function(label, estimate, lower, upper, p_adjusted) { cat(sprintf("%-23s %7.2f [%7.2f, %7.2f] p adj = %.2g\n", label, estimate, lower, upper, p_adjusted), sep = "") invisible(NULL)}
for (group in groups) { values <- tg$tg_mg_dl[tg$treatment == group] cat(sprintf("%-10s n = %d, mean = %.1f, SD = %.1f\n", group, length(values), mean(values), sd(values)))}Vehicle n = 12, mean = 144.7, SD = 17.0Compound A n = 12, mean = 109.1, SD = 12.2Compound B n = 12, mean = 134.0, SD = 19.6Compound C n = 12, mean = 154.4, SD = 28.2import itertoolsfrom pathlib import Path
import matplotlib.pyplot as pltimport numpy as npimport pandas as pdimport pingouin as pgimport scikit_posthocs as spfrom scipy import statsfrom statsmodels.stats.multitest import multipletests
tg = pd.read_csv("triglycerides.csv")groups = ["Vehicle", "Compound A", "Compound B", "Compound C"]tg["treatment"] = pd.Categorical(tg["treatment"], categories=groups)samples = [tg.loc[tg["treatment"] == group, "tg_mg_dl"].to_numpy() for group in groups]output = Path("outputs")output.mkdir(exist_ok=True)
def print_contrast(label, estimate, lower, upper, p_adjusted): """Print one contrast with its interval and adjusted p-value.
Args: label: The name of the contrast. estimate: The difference in means. lower: The lower limit of the interval. upper: The upper limit of the interval. p_adjusted: The adjusted p-value.
Returns: None. """ print(f"{label:<23} {estimate:7.2f} [{lower:7.2f}, {upper:7.2f}] " f"p adj = {p_adjusted:.2g}")
for group, values in zip(groups, samples): print(f"{group:<10} n = {len(values)}, mean = {values.mean():.1f}, " f"SD = {values.std(ddof=1):.1f}")Vehicle n = 12, mean = 144.7, SD = 17.0Compound A n = 12, mean = 109.1, SD = 12.2Compound B n = 12, mean = 134.0, SD = 19.6Compound C n = 12, mean = 154.4, SD = 28.2The sample means put Compound A 35.6 mg/dL below vehicle, Compound B 10.7 below, and Compound C 9.7 above. The sample standard deviations run from 12.2 to 28.2 mg/dL, so the groups do not share one spread.
Choose the family before the test
Section titled “Choose the family before the test”A family is the set of comparisons that one claim rests on. A procedure with a 95% family-wise confidence level builds intervals that all cover their true differences together in 95% of repeated studies. The price of that guarantee grows with the size of the set, so the set comes first and the test second.
| Family | Comparisons with four groups | Procedures on this page |
|---|---|---|
| All pairs | 6 | Tukey’s HSD, Games-Howell |
| Each treatment against the control | 3 | Dunnett’s test, Welch t-tests with Holm, Dunn’s test with a reference group |
This study screens three compounds against vehicle. No conclusion depends on Compound B against Compound C, so the family has three comparisons, and the protocol says so before the first mouse is dosed. The page still starts with all six pairs, because the cost of the larger family is easier to see next to it.
All pairs: Tukey’s HSD
Section titled “All pairs: Tukey’s HSD”Tukey’s HSD covers every pairwise difference with one pooled variance. The ANOVA page explains the procedure; here it supplies the six-comparison baseline.
fit <- aov(tg_mg_dl ~ treatment, data = tg)tukey <- TukeyHSD(fit, conf.level = 0.95)$treatmentPrintContrast(sub("-", " - ", rownames(tukey)), tukey[, "diff"], tukey[, "lwr"], tukey[, "upr"], tukey[, "p adj"])Compound A - Vehicle -35.62 [ -57.52, -13.71] p adj = 0.00046Compound B - Vehicle -10.72 [ -32.62, 11.19] p adj = 0.56Compound C - Vehicle 9.70 [ -12.20, 31.60] p adj = 0.64Compound B - Compound A 24.90 [ 3.00, 46.80] p adj = 0.02Compound C - Compound A 45.32 [ 23.41, 67.22] p adj = 9.8e-06Compound C - Compound B 20.42 [ -1.49, 42.32] p adj = 0.076tukey = stats.tukey_hsd(*samples)tukey_ci = tukey.confidence_interval(confidence_level=0.95)for first, second in itertools.combinations(range(len(groups)), 2): print_contrast(f"{groups[second]} - {groups[first]}", tukey.statistic[second, first], tukey_ci.low[second, first], tukey_ci.high[second, first], tukey.pvalue[second, first])Compound A - Vehicle -35.62 [ -57.52, -13.71] p adj = 0.00046Compound B - Vehicle -10.72 [ -32.62, 11.19] p adj = 0.56Compound C - Vehicle 9.70 [ -12.20, 31.60] p adj = 0.64Compound B - Compound A 24.90 [ 3.00, 46.80] p adj = 0.02Compound C - Compound A 45.32 [ 23.41, 67.22] p adj = 9.8e-06Compound C - Compound B 20.42 [ -1.49, 42.32] p adj = 0.076Every interval has the same half-width, 21.90 mg/dL, because the design is balanced and the variance is pooled. Compound A against vehicle is −35.62 mg/dL with an interval from −57.52 to −13.71. Three of the six rows compare two compounds, and this study never asked about them.
Each treatment against the control: Dunnett’s test
Section titled “Each treatment against the control: Dunnett’s test”Dunnett’s procedure covers only the comparisons with one control. In R, glht() from multcomp takes the fitted model and mcp(treatment = "Dunnett"), which contrasts every level with the first level of the factor. In Python, scipy.stats.dunnett() takes the treatment samples and the control sample.
Both functions need the joint distribution of three correlated t statistics, and both integrate it with a randomized numerical method. A fixed seed makes each run repeat its own digits.
set.seed(1)dunnett <- glht(fit, linfct = mcp(treatment = "Dunnett"))dunnett_tests <- summary(dunnett)$testdunnett_ci <- confint(dunnett, level = 0.95)$confintPrintContrast(rownames(dunnett_ci), dunnett_ci[, "Estimate"], dunnett_ci[, "lwr"], dunnett_ci[, "upr"], dunnett_tests$pvalues)Compound A - Vehicle -35.62 [ -55.58, -15.65] p adj = 0.00023Compound B - Vehicle -10.72 [ -30.68, 9.25] p adj = 0.43Compound C - Vehicle 9.70 [ -10.27, 29.67] p adj = 0.5dunnett = stats.dunnett(*samples[1:], control=samples[0], rng=np.random.default_rng(1))dunnett_ci = dunnett.confidence_interval(confidence_level=0.95)differences = np.array([values.mean() - samples[0].mean() for values in samples[1:]])contrasts = [f"{group} - Vehicle" for group in groups[1:]]for index, label in enumerate(contrasts): print_contrast(label, differences[index], dunnett_ci.low[index], dunnett_ci.high[index], dunnett.pvalue[index])Compound A - Vehicle -35.62 [ -55.58, -15.66] p adj = 0.00023Compound B - Vehicle -10.72 [ -30.68, 9.24] p adj = 0.43Compound C - Vehicle 9.70 [ -10.26, 29.66] p adj = 0.5The estimates are the differences of the sample means, so they match the first three Tukey rows. The limits differ between the tabs by at most 0.01 mg/dL, which is the precision of the numerical integration and not a disagreement about the method.
Compound A lowered triglycerides by 35.62 mg/dL, and reductions from about 15.6 to 55.6 mg/dL are compatible with the data. The true effect, −40, lies inside. The Compound B interval runs from −30.68 to 9.25 mg/dL in the R tab. It includes zero and it includes the true effect of −15, so “Compound B does not lower triglycerides” would misread an adjusted p-value of 0.43. Twelve mice per group cannot separate a 15 mg/dL reduction from none.
One contrast under two families
Section titled “One contrast under two families”The Compound B row has the same estimate under both procedures and a different interval. Each interval is the estimate plus or minus a critical value times the standard error of the difference. The standard error is the same in both procedures, so the critical value carries the whole difference.
standard_error <- dunnett_tests$sigma[["Compound B - Vehicle"]]df_error <- fit$df.residualcritical <- c(qt(0.975, df_error), attr(dunnett_ci, "calpha"), qtukey(0.95, length(groups), df_error) / sqrt(2))cat(sprintf("Standard error = %.2f mg/dL, error df = %d\n", standard_error, df_error))cat(sprintf("%-18s comparisons = %d, critical = %.2f, half-width = %5.2f\n", c("One t interval", "Dunnett", "Tukey"), c(1, 3, 6), critical, critical * standard_error), sep = "")Standard error = 8.20 mg/dL, error df = 44One t interval comparisons = 1, critical = 2.02, half-width = 16.53Dunnett comparisons = 3, critical = 2.43, half-width = 19.97Tukey comparisons = 6, critical = 2.67, half-width = 21.90df_error = len(tg) - len(groups)pooled_variance = sum((len(values) - 1) * values.var(ddof=1) for values in samples) / df_errorstandard_error = np.sqrt(pooled_variance * (1 / len(samples[2]) + 1 / len(samples[0])))dunnett_half_width = (dunnett_ci.high[1] - dunnett_ci.low[1]) / 2critical = [stats.t.ppf(0.975, df_error), dunnett_half_width / standard_error, stats.studentized_range.ppf(0.95, len(groups), df_error) / np.sqrt(2)]print(f"Standard error = {standard_error:.2f} mg/dL, error df = {df_error}")families = [("One t interval", 1), ("Dunnett", 3), ("Tukey", 6)]for (name, comparisons), value in zip(families, critical): print(f"{name:<18} comparisons = {comparisons}, critical = {value:.2f}, " f"half-width = {value * standard_error:5.2f}")Standard error = 8.20 mg/dL, error df = 44One t interval comparisons = 1, critical = 2.02, half-width = 16.53Dunnett comparisons = 3, critical = 2.43, half-width = 19.96Tukey comparisons = 6, critical = 2.67, half-width = 21.90A single unadjusted interval uses 2.02 standard errors. Dunnett’s procedure uses 2.43, and Tukey’s uses 2.67. The critical value is the 95th percentile of the largest absolute t statistic in the family when no true difference exists. The largest of six statistics exceeds the largest of three, so the six-pair family needs the larger multiplier.
For Compound B against vehicle the half-width falls from 21.90 mg/dL under Tukey to 19.97 under Dunnett in the R tab, an interval about 9% narrower from the same 48 mice. That gain is the reward for stating, before the data, that the compound-to-compound pairs are not part of the claim.
Plot the differences from control
Section titled “Plot the differences from control”A plot of the three differences with their Dunnett intervals shows the size and the uncertainty of each effect, which a row of stars cannot. The code adds the true effects of the simulation as crosses, which a real study does not have.
dunnett_table <- data.frame( contrast = factor(rownames(dunnett_ci), levels = rev(rownames(dunnett_ci))), estimate = dunnett_ci[, "Estimate"], lower = dunnett_ci[, "lwr"], upper = dunnett_ci[, "upr"], truth = c(-40, -15, 0))dunnett_plot <- ggplot(dunnett_table, aes(estimate, contrast)) + geom_vline(xintercept = 0, linetype = "dashed", color = "grey50") + geom_linerange(aes(xmin = lower, xmax = upper), linewidth = 0.9, color = "#1f4e5f") + geom_point(size = 3, color = "#1f4e5f") + geom_point(aes(x = truth), shape = 4, size = 3, stroke = 1.2, color = "#c44e52") + labs(x = "Difference from vehicle (mg/dL)", y = NULL, title = "Dunnett 95% simultaneous intervals", caption = "Dot: estimate. Cross: true effect of the simulation.") + theme_classic(base_size = 12)ggsave("outputs/posthoc-dunnett-r.png", dunnett_plot, width = 6.5, height = 3.2, dpi = 150)
true_effects = [-40, -15, 0]positions = np.arange(len(contrasts))[::-1]figure, axes = plt.subplots(figsize=(6.5, 3.2))axes.axvline(0, color="grey", linestyle="--", linewidth=1)axes.hlines(positions, dunnett_ci.low, dunnett_ci.high, color="#1f2a44", linewidth=2)axes.plot(differences, positions, "o", color="#1f2a44", markersize=8, label="Estimate")axes.plot(true_effects, positions, "x", color="#c44e52", markersize=8, markeredgewidth=2, label="True effect of the simulation")axes.set_yticks(positions, contrasts)axes.set_ylim(-0.6, len(contrasts) - 0.4)axes.set_xlabel("Difference from vehicle (mg/dL)")axes.set_title("Dunnett 95% simultaneous intervals")axes.legend(frameon=False, fontsize=8, loc="lower left")axes.spines[["top", "right"]].set_visible(False)figure.tight_layout()figure.savefig(output / "posthoc-dunnett-python.png", dpi=150)plt.close(figure)
All three intervals contain their cross. The three intervals have the same width, and that sameness is an assumption of the pooled variance and not a property of the mice.
Unequal variances: Welch’s ANOVA and Games-Howell
Section titled “Unequal variances: Welch’s ANOVA and Games-Howell”Tukey and Dunnett give every contrast the pooled standard error of 8.20 mg/dL. The groups here were simulated with standard deviations from 10 to 35 mg/dL, and a compound that changes lipid metabolism can change the spread between animals as well as the mean. When the design gives no reason to expect one common variance, estimate each contrast from its own two groups.
Welch’s ANOVA is the omnibus test of that kind. Games-Howell is the all-pairs procedure: each pair gets a Welch standard error and Welch degrees of freedom, and the studentized range distribution supplies the adjustment. games_howell_test() from rstatix returns the intervals. pairwise_gameshowell() from pingouin returns the standard error and the degrees of freedom without an interval, so the Python code builds each interval from those two columns. pingouin reports the first group minus the second, and the code flips the sign to match R.
welch <- oneway.test(tg_mg_dl ~ treatment, data = tg, var.equal = FALSE)cat(sprintf("Welch F(%.0f, %.2f) = %.2f, p = %.2g\n", welch$parameter[1], welch$parameter[2], welch$statistic, welch$p.value))games_howell <- rstatix::games_howell_test(tg, tg_mg_dl ~ treatment, conf.level = 0.95)PrintContrast(paste(games_howell$group2, "-", games_howell$group1), games_howell$estimate, games_howell$conf.low, games_howell$conf.high, games_howell$p.adj)Welch F(3, 23.59) = 16.28, p = 6e-06Compound A - Vehicle -35.62 [ -52.56, -18.67] p adj = 5.2e-05Compound B - Vehicle -10.72 [ -31.54, 10.11] p adj = 0.49Compound C - Vehicle 9.70 [ -17.14, 36.54] p adj = 0.74Compound B - Compound A 24.90 [ 6.13, 43.67] p adj = 0.0072Compound C - Compound A 45.32 [ 19.78, 70.86] p adj = 0.00066Compound C - Compound B 20.42 [ -7.33, 48.17] p adj = 0.2welch = pg.welch_anova(data=tg, dv="tg_mg_dl", between="treatment")print(f"Welch F({welch.loc[0, 'ddof1']:.0f}, {welch.loc[0, 'ddof2']:.2f}) = " f"{welch.loc[0, 'F']:.2f}, p = {welch.loc[0, 'p_unc']:.2g}")games_howell = pg.pairwise_gameshowell(data=tg, dv="tg_mg_dl", between="treatment")for row in games_howell.itertuples(): quantile = stats.studentized_range.ppf(0.95, len(groups), row.df) half_width = quantile / np.sqrt(2) * row.se print_contrast(f"{row.B} - {row.A}", -row.diff, -row.diff - half_width, -row.diff + half_width, row.pval)Welch F(3, 23.59) = 16.28, p = 6e-06Compound A - Vehicle -35.62 [ -52.56, -18.67] p adj = 5.2e-05Compound B - Vehicle -10.72 [ -31.54, 10.11] p adj = 0.49Compound C - Vehicle 9.70 [ -17.14, 36.54] p adj = 0.74Compound B - Compound A 24.90 [ 6.13, 43.67] p adj = 0.0072Compound C - Compound A 45.32 [ 19.78, 70.86] p adj = 0.00066Compound C - Compound B 20.42 [ -7.33, 48.17] p adj = 0.2The estimates are unchanged, and the intervals now follow the groups. Compound A against vehicle compares the two tightest groups, and its half-width falls from 21.90 mg/dL under Tukey to about 16.9. Compound C against vehicle involves the most variable group, and its half-width grows from 21.90 to about 26.8. The pooled procedure was too cautious about the first contrast and too confident about the second.
Pairwise Welch t-tests with Holm and Bonferroni
Section titled “Pairwise Welch t-tests with Holm and Bonferroni”Games-Howell pays for six pairs. For the three control comparisons with unequal variances, run a Welch t-test for each compound against vehicle and adjust the three p-values. Bonferroni multiplies every p-value by 3. Holm multiplies the smallest by 3, the next by 2, and the largest by 1, and it never lets an adjusted value fall below the one before it. The multiple testing page covers Bonferroni and the choice of the family.
Holm has no interval of its own. A Bonferroni interval at a confidence level of 1 − 0.05/3 for each contrast gives three intervals with joint coverage of at least 95%.
pairwise <- pairwise.t.test(tg$tg_mg_dl, tg$treatment, pool.sd = FALSE, p.adjust.method = "none")raw_p <- pairwise$p.value[, "Vehicle"]cat(sprintf("%-20s raw p = %-8.2g Bonferroni = %-8.2g Holm = %.2g\n", paste(names(raw_p), "- Vehicle"), raw_p, p.adjust(raw_p, method = "bonferroni"), p.adjust(raw_p, method = "holm")), sep = "")vehicle <- tg$tg_mg_dl[tg$treatment == "Vehicle"]for (group in groups[-1]) { welch_t <- t.test(tg$tg_mg_dl[tg$treatment == group], vehicle, conf.level = 1 - 0.05 / 3) cat(sprintf("%-20s %7.2f [%7.2f, %7.2f]\n", paste(group, "- Vehicle"), welch_t$estimate[1] - welch_t$estimate[2], welch_t$conf.int[1], welch_t$conf.int[2]))}Compound A - Vehicle raw p = 9.4e-06 Bonferroni = 2.8e-05 Holm = 2.8e-05Compound B - Vehicle raw p = 0.17 Bonferroni = 0.5 Holm = 0.33Compound C - Vehicle raw p = 0.32 Bonferroni = 0.96 Holm = 0.33Compound A - Vehicle -35.62 [ -51.43, -19.80]Compound B - Vehicle -10.72 [ -30.15, 8.71]Compound C - Vehicle 9.70 [ -15.36, 34.76]welch_tests = [stats.ttest_ind(values, samples[0], equal_var=False) for values in samples[1:]]raw_p = [test.pvalue for test in welch_tests]bonferroni = multipletests(raw_p, method="bonferroni")[1]holm = multipletests(raw_p, method="holm")[1]for index, label in enumerate(contrasts): print(f"{label:<20} raw p = {raw_p[index]:<8.2g} " f"Bonferroni = {bonferroni[index]:<8.2g} " f"Holm = {holm[index]:.2g}")for index, label in enumerate(contrasts): interval = welch_tests[index].confidence_interval(1 - 0.05 / 3) print(f"{label:<20} {differences[index]:7.2f} " f"[{interval.low:7.2f}, {interval.high:7.2f}]")Compound A - Vehicle raw p = 9.4e-06 Bonferroni = 2.8e-05 Holm = 2.8e-05Compound B - Vehicle raw p = 0.17 Bonferroni = 0.5 Holm = 0.33Compound C - Vehicle raw p = 0.32 Bonferroni = 0.96 Holm = 0.33Compound A - Vehicle -35.62 [ -51.43, -19.80]Compound B - Vehicle -10.72 [ -30.15, 8.71]Compound C - Vehicle 9.70 [ -15.36, 34.76]The two rules agree on the smallest p-value and part ways after it. For Compound C, Bonferroni reports 0.96 and Holm reports 0.33. Holm rejects every hypothesis that Bonferroni rejects and sometimes more, with the same control of the family-wise error rate. Bonferroni keeps one use: its adjusted p-values match simultaneous intervals at the same level, and Holm has no such intervals.
The intervals follow the groups as the Games-Howell intervals do, with less width, because the family has three comparisons and not six. Compound A against vehicle has a half-width of about 15.8 mg/dL here, against 16.9 under Games-Howell. Set these rows beside the Dunnett table as well. The Compound C interval, −10.27 to 29.67 mg/dL under the pooled variance in R, becomes −15.36 to 34.76 once the spread of Compound C counts in full.
A question about ranks: Kruskal-Wallis and Dunn’s test
Section titled “A question about ranks: Kruskal-Wallis and Dunn’s test”Rank procedures answer a different question from the ones above. Kruskal-Wallis ranks all 48 values together and asks whether the mean rank is the same in every group, which is a question about whether mice in one group tend to have higher values than mice in another. Dunn’s test compares the mean ranks of two groups within that joint ranking. Choose them when that tendency is the claim, for example when the assay saturates and only the order of the values is trustworthy. They do not estimate a difference in mg/dL.
dunn_test() from rstatix takes ref.group and adjusts over the three control comparisons. posthoc_dunn() from scikit-posthocs returns all six pairs, so the Python code takes the unadjusted p-values, keeps the vehicle column, and applies Holm to those three.
kruskal <- kruskal.test(tg_mg_dl ~ treatment, data = tg)cat(sprintf("Kruskal-Wallis H = %.2f, df = %d, p = %.2g\n", kruskal$statistic, kruskal$parameter, kruskal$p.value))dunn <- rstatix::dunn_test(tg, tg_mg_dl ~ treatment, p.adjust.method = "holm", ref.group = "Vehicle", detailed = TRUE)cat(sprintf("%s - %s: mean rank %5.2f against %.2f, p adj = %.2g\n", dunn$group2, dunn$group1, dunn$estimate2, dunn$estimate1, dunn$p.adj), sep = "")Kruskal-Wallis H = 21.58, df = 3, p = 8e-05Compound A - Vehicle: mean rank 9.50 against 29.96, p adj = 0.001Compound B - Vehicle: mean rank 24.17 against 29.96, p adj = 0.62Compound C - Vehicle: mean rank 34.38 against 29.96, p adj = 0.62kruskal = stats.kruskal(*samples)print(f"Kruskal-Wallis H = {kruskal.statistic:.2f}, " f"df = {len(groups) - 1}, p = {kruskal.pvalue:.2g}")tg["rank"] = tg["tg_mg_dl"].rank()mean_rank = tg.groupby("treatment", observed=True)["rank"].mean()dunn_raw = sp.posthoc_dunn(tg, val_col="tg_mg_dl", group_col="treatment")dunn_holm = multipletests(dunn_raw.loc[groups[1:], "Vehicle"], method="holm")[1]for group, p_holm in zip(groups[1:], dunn_holm): print(f"{group} - Vehicle: mean rank {mean_rank[group]:5.2f} against " f"{mean_rank['Vehicle']:.2f}, p adj = {p_holm:.2g}")Kruskal-Wallis H = 21.58, df = 3, p = 8e-05Compound A - Vehicle: mean rank 9.50 against 29.96, p adj = 0.001Compound B - Vehicle: mean rank 24.17 against 29.96, p adj = 0.62Compound C - Vehicle: mean rank 34.38 against 29.96, p adj = 0.62Compound A has a mean rank of 9.50 against 29.96 for vehicle: its mice sit low in the joint ordering of 48 values. Compound C has a mean rank of 34.38, above vehicle, with an adjusted p-value of 0.62.
Do not read these p-values as tests of the medians. A difference in mean rank can be read as a shift in the median only when the groups have the same shape and spread, and these groups were simulated with different spreads.
Mistakes to avoid
Section titled “Mistakes to avoid”Do not choose the family after you see the data. In the Tukey table, Compound C against Compound A is the largest difference, 45.32 mg/dL. A reader who notices it and then reports that one pair with an unadjusted t-test has in effect searched six pairs and corrected for one. Write the family in the protocol.
Do not make a significant F-test the entry ticket for Tukey or Dunnett. Each procedure controls the error rate of its own family without help from the omnibus test. Hothorn (2016) gives data configurations in which the F-test is not significant and Dunnett’s test is, and concludes that the two-step rule can raise the false negative rate. The rule belongs to Fisher’s least significant difference, which has no adjustment of its own.
Do not report stars alone. “Compound B, ns” hides a Dunnett interval from about −30.7 to 9.3 mg/dL, which is the only part of the result that tells a reader what the study could and could not detect.
Do not run Dunnett’s test and then quote the compound-to-compound differences from a Tukey table. Two families on one data set are two claims, and each needs its own justification.
Report the result
Section titled “Report the result”Name the family, the procedure, the estimates with their simultaneous intervals, and the number of experimental units: “Each compound was compared with vehicle, a family of three comparisons. Compound A lowered fasting triglycerides by 35.6 mg/dL (Welch t-test, 95% simultaneous Bonferroni interval 19.8 to 51.4, Holm-adjusted p = 2.8e-05). Compound B differed from vehicle by −10.7 mg/dL (−30.1 to 8.7) and Compound C by 9.7 mg/dL (−15.4 to 34.8); 12 mice per group.”
Scientific references
Section titled “Scientific references”Dunnett, 1955 describes the multiple comparison procedure for several treatments against one control.
Hothorn, Bretz, and Westfall, 2008 describe simultaneous inference in general parametric models and the multcomp package that implements it.
Games and Howell, 1976 compare three pairwise procedures by simulation under unequal group sizes and variances, and find that only the Behrens-Fisher statistic, the basis of the Games-Howell test, controlled the family-wise error rate with groups of six or more.
Dunn, 1964 describes multiple comparisons that use rank sums.
Hothorn, 2016 shows that a significant ANOVA F-test as a condition for Dunnett’s comparisons can raise the false negative rate, and recommends against the global pre-test.
Vallat, 2018 describes Pingouin, the Python statistics package that supplies the Welch ANOVA and the Games-Howell test here.
Terpilowski, 2019 describes scikit-posthocs and its pairwise multiple comparison tests in Python.
Further reading
Section titled “Further reading”The chapter Contrasts and Multiple Testing of Lukas Meier’s book ANOVA and Mixed Models derives the Tukey and Dunnett procedures, and its FAQ explains why neither depends on a significant F-test.
The SciPy dunnett reference lists the assumptions of the test and the one-sided alternatives, which fit a study that only asks whether a compound lowers the response.
The multcomp glht reference documents the three ways to specify a set of contrasts. It also warns that mcp() compares main effects only in a two-way ANOVA or an ANCOVA model, where it ignores covariates and interactions.
The ANOVA page covers the omnibus tests and Tukey’s HSD on three groups. The multiple testing page separates family-wise error control from false discovery control, and the estimation statistics page draws shared-control differences with bootstrap intervals.