This calculator helps you perform multiple comparisons between group means after getting a significant ANOVA result. It identifies which specific groups differ significantly from each other while controlling Type I error rate for multiple comparisons. The calculator provides group statistics, an ANOVA table, assumption checks (normality and homogeneity of variance), visualizations (box and mean plots), and an APA-formatted interpretation. Click here to populate the sample data for a quick example.
Important considerations before using Tukey's HSD Test:
- Tukey's HSD test should only be performed after a significant one-way ANOVA result.
- Each group must have at least 2 samples for the test to work.
- Groups with zero variance (all identical values) will cause the test to fail.
Calculator
1. Load Your Data
2. Select Columns & 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:
Where:
- = studentized range statistic
- = Mean Square Error from ANOVA, which is equivalent to Mean Square Within ()
- = sample size per group
- = number of groups
- = total sample size
Key Assumptions
Practical Example
Step 1: State the Data
Comparing three fertilizer treatments on plant growth (cm):
Treatment A | Treatment B | Treatment C |
---|---|---|
25 | 42 | 35 |
30 | 38 | 33 |
28 | 40 | 31 |
32 | 45 | 34 |
29 | 41 | 32 |
Step 2: Calculate Group Statistics
- Treatment A: ,
- Treatment B: ,
- Treatment C: ,
- MSE (from ANOVA) =
Step 3: Calculate HSD
For , groups, :
Step 4: Compare Group Differences
(significant)
(significant)
(significant)
Step 5: Draw Conclusions
All pairwise comparisons show significant differences at . Treatment B produced significantly higher growth than both A and C, and Treatment C produced significantly higher growth than Treatment A.
Code Examples
library(emmeans)
library(tidyverse)
# Example data
data <- data.frame(
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
)
data |>
group_by(group) |>
summarize(mean = mean(values), sd = sd(values), n = n())
# Fit ANOVA model
model <- aov(values ~ group, data = data)
summary(model)
q <- qtukey(0.95, nmeans = 3, df = 12)
mse <- summary(model)[[1]]["Residuals", "Mean Sq"]
hsd <- q * sqrt(mse / 5)
print(hsd)
# Get emmeans and perform Tukey's HSD
emmeans_result <- emmeans(model, "group")
pairs(emmeans_result, adjust = "tukey")
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)
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