StatsCalculators.com

Tukey's HSD Test

Created:December 1, 2024
Last Updated:October 8, 2025

This calculator helps you perform comprehensive pairwise comparisons between all group means after obtaining a significant ANOVA result. Tukey's HSD (Honestly Significant Difference) test is the gold standard for systematically examining every possible group pair while maintaining strict control over the familywise error rate, ensuring your findings are both thorough and statistically sound.

What You'll Get:

  • Complete Pairwise Analysis: Every possible group comparison with adjusted p-values and effect sizes
  • ANOVA Integration: Full ANOVA results plus detailed post-hoc comparisons in one analysis
  • Effect Size Metrics: Cohen's d for each comparison to assess practical significance
  • Visual Insights: Significance matrix, group comparison charts, and distribution plots
  • Assumption Validation: Comprehensive normality and homogeneity of variance testing
  • CLD Notation: Critical Difference Letters to clearly identify which groups differ significantly
  • Professional Reporting: APA-formatted results with effect sizes ready for publication

πŸ’‘ Pro Tip: Use Tukey's HSD when you want to compare all groups to each other. If you only need to compare treatments to a control group, use ourDunnett's Test Calculatorfor more focused analysis. Always ensure your ANOVA is significant first!

Ready to discover which groups truly differ? Load long format sample or load wide format sample to see how it works, or upload your own data to uncover the specific patterns of differences across all your groups.

Calculator

1. Load Your Data

2. Select Data Format & Options

Related Calculators

Learn More

Tukey's HSD Test

Definition

Tukey's HSD (Honestly Significant Difference) Test is a post-hoc test used after ANOVA to determine which specific groups differ from each other. It controls the family-wise error rate while conducting multiple pairwise comparisons.

Formula

Test Statistic:

HSD=qΞ±,k,Nβˆ’kMSEnHSD = q_{\alpha,k,N-k}\sqrt{\frac{MSE}{n}}

Where:

  • qΞ±,k,Nβˆ’kq_{\alpha,k,N-k} = studentized range statistic
  • MSEMSE = Mean Square Error from ANOVA, which is equivalent to Mean Square Within (MSWithinMS_{Within})
  • nn = sample size per group
  • kk = number of groups
  • NN = total sample size

Key Assumptions

Independence: Observations must be independent
Normality: Data within each group should be normally distributed
Homogeneity of Variance: Groups should have equal variances
Equal Sample Sizes: Preferably, groups should have equal sample sizes

Practical Example

Step 1: State the Data

Comparing three fertilizer treatments on plant growth (cm):

Treatment ATreatment BTreatment C
254235
303833
284031
324534
294132
Step 2: Calculate Group Statistics
  • Treatment A: xΛ‰=28.8\bar{x} = 28.8, n=5n = 5
  • Treatment B: xΛ‰=41.2\bar{x} = 41.2, n=5n = 5
  • Treatment C: xΛ‰=33.0\bar{x} = 33.0, n=5n = 5
  • MSE (from ANOVA) = 5.35.3
Step 3: Calculate HSD

For Ξ±=0.05\alpha = 0.05, k=3k = 3 groups, df=3Γ—5βˆ’3=12df = 3 \times 5 - 3 = 12:

q0.05,3,12=3.77q_{0.05,3,12} = 3.77HSD=3.775.35=3.884HSD = 3.77\sqrt{\frac{5.3}{5}} = 3.884
Step 4: Compare Group Differences

∣Bβˆ’A∣=∣41.2βˆ’28.8∣=12.4>3.884|B - A| = |41.2 - 28.8| = 12.4 > 3.884 (significant)

∣Cβˆ’A∣=∣33.0βˆ’28.8∣=4.2>3.884|C - A| = |33.0 - 28.8| = 4.2 > 3.884 (significant)

∣Bβˆ’C∣=∣41.2βˆ’33.0∣=8.2>3.884|B - C| = |41.2 - 33.0| = 8.2 > 3.884 (significant)

Step 5: Draw Conclusions

All pairwise comparisons show significant differences at Ξ±=0.05\alpha = 0.05. Treatment B produced significantly higher growth than both A and C, and Treatment C produced significantly higher growth than Treatment A.

Alternative Tests

Consider these alternatives:

  • Bonferroni Test: More conservative, controls family-wise error rate
  • ScheffΓ©'s Test: More flexible for complex comparisons
  • Games-Howell Test: When variances are unequal

How to perform Tukeys HSD Test in R

Use TukeyHSD() function from base R or emmeans package for more advanced options including compact letter display (CLD).

R
library(emmeans)
library(tidyverse)
library(multcomp)


data <- tibble(
  group = rep(c("A", "B", "C"), each = 5),
  values = c(25, 30, 28, 32, 29,  # Group A
             42, 38, 40, 45, 41,  # Group B
             35, 33, 31, 34, 32)  # Group C
) |>
  mutate(group = as.factor(group))

data |>
  group_by(group) |>
  summarize(mean = mean(values), sd = sd(values), n = n())

aov_model <- aov(values ~ group, data = data)
summary(aov_model)

q <- qtukey(0.95, nmeans = 3, df = 12)
mse <- summary(aov_model)[[1]]["Residuals", "Mean Sq"]
hsd <- q * sqrt(mse / 5)
print(hsd)

emmeans_result <- emmeans(aov_model, "group")
pairs(emmeans_result, adjust = "tukey")

emmeans(aov_model, specs = ~ group) |>
  cld()

How to perform Tukeys HSD Test in Python

Use pairwise_tukeyhsd() function from statsmodels package to perform Tukey's HSD test in Python.

Python
import pandas as pd
from statsmodels.stats.multicomp import pairwise_tukeyhsd

# Example data
group1 = [25, 30, 28, 32, 29]
group2 = [42, 38, 40, 45, 41]
group3 = [35, 33, 31, 34, 32]

# Create DataFrame
data = pd.DataFrame({
    'values': group1 + group2 + group3,
    'group': ['A']*5 + ['B']*5 + ['C']*5
})

# Perform Tukey's HSD
tukey = pairwise_tukeyhsd(
    endog=data['values'],
    groups=data['group'],
    alpha=0.05
)

print(tukey)

# There is no package that provides CLD in Python similar to R's multcomp::cld()
# However, our calculator provides the same CLD output as R's multcomp::cld() with emmeans.

Verification