The Tukey t test is the common name for Tukey's honest significant difference (HSD) test. It is a post hoc procedure that compares every pair of group means after an ANOVA finds a significant overall effect. It is not a t-test in the strict sense. It resembles one, but it uses the studentized range distribution, so the chance of at least one false positive across all your comparisons stays at the level you chose, usually 5%.
John Tukey introduced the method in 1949 for groups of equal size, and the Tukey-Kramer extension later covered unequal sizes. This article explains why the test matters, how to calculate it by hand with a worked example, and how to read and report the output from R, Python, or a spreadsheet workflow. It also covers how Tukey compares with Bonferroni and other post hoc tests.
Post hoc testing is a step where a wrong choice is easy to make. At PlotStudio AI, we build a research analysis workspace, so the last section shows how to check a Tukey analysis, whichever tool runs it.
Why the Tukey test matters after an ANOVA
The Tukey test matters because an ANOVA tells you that at least one group mean differs, but not which ones. Tukey answers that question without inflating your error rate.
What ANOVA leaves unanswered
An ANOVA's F-test compares all group means at once. A significant result means at least one mean differs from the others. It does not say whether treatment A beats B, or whether only treatment D is the odd one out.
Tukey's HSD fills that gap by comparing every possible pair of means. The usual workflow is simple. Run the ANOVA first, and if the F-test is significant, run Tukey to locate the differences.
ANOVA tells you that something differs. Tukey tells you where.
Why repeated t-tests fail and Tukey does not
Running a separate t-test for each pair fails because every test at α = 0.05 carries its own 5% false-positive risk, and those risks stack. With k groups you have k(k − 1) / 2 pairs. The table below shows how fast the family-wise error rate grows, using 1 − 0.95^m. The figures treat the tests as independent, so they are approximate.

| Groups | Pairwise comparisons | Chance of at least one false positive |
|---|---|---|
| 3 | 3 | 14.3% |
| 4 | 6 | 26.5% |
| 5 | 10 | 40.1% |
| 6 | 15 | 53.7% |
Tukey fixes this by judging the gap between the largest and smallest means against the studentized range distribution. The critical value is larger than an ordinary t critical value, so the family-wise error rate stays at 5%. A standard t-test compares two means with no correction for how many comparisons you make. Tukey's test behaves like a t-test with that correction built in, which is why its confidence intervals are wider.
How to calculate the Tukey test step by step
To calculate a Tukey test, find the critical difference (HSD) from the studentized range table, then flag every pair of means that differs by more than it.
The formula and the five steps
The formula is HSD = q × √(MSE / n). Each part comes straight from your ANOVA:
- q is the critical value from the studentized range table for your α, the number of groups (k), and the error degrees of freedom.
- MSE is the mean square error (within groups) from the ANOVA table.
- n is the number of observations per group.
Then follow these steps:
- Run the ANOVA and confirm the F-test is significant.
- Record MSE, the error degrees of freedom, k, and n.
- Look up q in the studentized range table.
- Compute HSD with the formula above.
- Compare each pairwise difference in means with HSD. A larger difference is significant.
The test assumes independent observations, roughly normal data within each group, and equal variances across groups. With unequal group sizes, use the Tukey-Kramer method. It estimates the standard error separately for each pair, and most statistical software does this automatically.
A worked example with four groups
Take a greenhouse experiment with four treatments and six replications each. The ANOVA gives MSE = 3.052 with 20 error degrees of freedom. The table value is q(0.05; 4, 20) = 3.96, so HSD = 3.96 × √(3.052 / 6) = 3.96 × 0.7132 = 2.824.

| Pair | Difference in means | Larger than 2.824? |
|---|---|---|
| A (29.20) vs B (28.60) | 0.60 | No |
| A vs C (25.87) | 3.33 | Yes |
| A vs D (21.00) | 8.20 | Yes |
| B vs C | 2.73 | No |
| B vs D | 7.60 | Yes |
| C vs D | 4.87 | Yes |
Writing letters for groups that do not differ gives A = a, B = ab, C = b, D = c. B and C differ by 2.73, just under 2.824, which is why their letters overlap.
Running it in R, Python, or Excel
In R and Python the test is one function call. Excel is the exception.
# R
TukeyHSD(aov(response ~ group, data = df))
# Python
from statsmodels.stats.multicomp import pairwise_tukeyhsd
print(pairwise_tukeyhsd(df["response"], df["group"], alpha=0.05))
Excel's Data Analysis ToolPak runs a one-way ANOVA but has no Tukey option. Take the MSE and degrees of freedom from its output, then apply the formula above with a q value from a table.
The whole test comes down to one number: any gap between means larger than HSD is significant.
How to read Tukey results in your output
Read a Tukey result by checking whether each pair's adjusted p-value is below 0.05, or equivalently whether its confidence interval excludes zero.
Adjusted p-values and confidence intervals
Most software lists one row per pair with the difference in means, a lower and upper bound, and an adjusted p-value. If the interval excludes zero, that pair differs at the family-wise level. If it contains zero, you have no evidence of a difference for that pair.

A guinea pig tooth growth dataset with six groups produces 15 pairs. For vitamin C versus orange juice at 0.5 mg, the 95% interval runs from −10.05 to −0.45 mm. Zero lies outside it, so those two groups differ. These intervals are simultaneous, so you can be 95% confident that all of them contain their true differences.
A Tukey interval that excludes zero is a significant pair, and the 5% error rate covers the whole set.
Compact letter display and reporting
Many papers summarize all pairs with a compact letter display. Groups sharing a letter show no detectable difference, and groups with no shared letter differ. A shared letter does not prove the means are equal. It only means you lack evidence of a difference.
When you report results, give the mean difference, its interval, and the adjusted p-value for each pair you discuss. This template works for most manuscripts:
A one-way ANOVA showed a significant effect of treatment, F(df1, df2) = X, p = Y. Tukey HSD post hoc comparisons (family-wise alpha = 0.05) showed that group A differed from group B (mean difference = X, 95% CI [L, U], adjusted p = Z).
Tukey versus Bonferroni and other post hoc tests
Use Tukey when you want every pairwise comparison and your variances are similar. Choose another test when your question or your data differ.
Tukey or Bonferroni
For all pairwise comparisons, Tukey is usually the better choice. It is built for exactly that family of tests and has more power than Bonferroni, which simply divides α by the number of tests. Bonferroni suits a small, planned set of comparisons, such as two or three, because it works with any test. Decide on those comparisons before you see the data.
Other options when assumptions fail
Tukey is one option among several. The table lists the common alternatives by situation.
| Situation | Test | Why |
|---|---|---|
| All pairs, equal variances, equal n | Tukey HSD | Controls family-wise error across all pairs |
| All pairs, unequal n | Tukey-Kramer | Adjusts the standard error per pair |
| Each group against one control | Dunnett | Fewer comparisons, more power |
| Unequal variances | Games-Howell | Does not assume equal variances |
| Non-normal data | Kruskal-Wallis, then Dunn's test | Rank-based |
| Small planned set | Bonferroni | Simple and flexible |
Pick the post hoc test from your question and your data, not from habit.
Checking a Tukey analysis in PlotStudio AI
You can run ANOVA with Tukey post hoc comparisons in PlotStudio AI by describing the comparison in plain English, then reviewing the plan before anything executes.
Ask in plain English and review the plan
Upload your dataset and ask for a group comparison with ANOVA and Tukey HSD. PlotStudio's AI agents plan the analysis, write Python, and run it locally on your machine. In Verification Mode, you can review the plan, question it, and approve the methods and assumptions before execution. The result page holds the tables, charts, and interpretation, and you can inspect the code.
A generated Tukey result is only as sound as the plan you approved.
What to verify before you report it
Before you report any Tukey result, confirm these points:
- The plan checked normality and equal variances, or chose a robust alternative.
- Group sizes are shown, and unequal sizes use Tukey-Kramer.
- The family-wise α is 0.05, or the level you set.
- Shared letters are read as "no detected difference," not "equal."
The conclusions remain your call as the researcher.
Putting the Tukey test to work
The Tukey t test finds which group means differ after a significant ANOVA while keeping the overall false-positive rate at your chosen level. Calculate the HSD from q, MSE, and n, compare each gap against it, and report the mean differences with their intervals. Use Tukey-Kramer for unequal groups, and move to Games-Howell or Dunn's test when your assumptions fail.
If you want to run an ANOVA with Tukey post hoc tests on your own data and inspect every step, try PlotStudio AI free with 30 credits and no credit card.
