← All resources

Post Hoc Test for ANOVA: What It Is and Which One to Use

19 min read
Post Hoc Test for ANOVA: What It Is and Which One to Use

A post hoc test for ANOVA is a follow-up comparison that you run after a significant ANOVA to find out which specific groups differ. ANOVA only tells you that at least one group mean is different from the others. A post hoc test such as Tukey's HSD compares the groups pair by pair while keeping the overall false positive rate at your chosen level, usually 5%.

The choice matters more than most tutorials admit. Run the wrong test, or skip the correction, and a tidy p-value can describe a difference that does not exist. This guide explains why post hoc tests are needed, how to run one step by step, how Tukey, Bonferroni, Scheffé, Dunnett and Games-Howell differ, and how to read and report the output, with a worked example.

PlotStudio AI, a desktop analysis workspace for researchers, runs ANOVA and its follow-up tests in Python code that you can inspect and approve. The last section shows what that workflow looks like. Everything before it works in any software you already use.

Why you need a post hoc test after a significant ANOVA

You need a post hoc test because a significant ANOVA says only that the group means are not all equal. Testing pairs without correction pushes your real false positive rate far above 5%. The follow-up test answers the question that the omnibus test leaves open, which groups differ, and it does so with the error rate under control.

What the omnibus F-test leaves unanswered

ANOVA's null hypothesis is that all group means are equal. The alternative is that at least one mean differs. With three or more groups, rejecting the null leaves you without a map. Groups A and B might be identical while C sits far above both, or every group might have its own level. The F-statistic compares between-group variance with within-group variance, and it cannot say where the gap lies.

That is the difference between ANOVA and a post hoc test. ANOVA asks one overall question: is there any difference? A post hoc test asks many specific questions: does A differ from B, A from C, B from C, and so on. It adjusts every answer for the fact that you asked many. "Post hoc" is Latin for "after this," which is why these tests follow a significant omnibus result.

A significant ANOVA tells you that a difference exists, and a post hoc test tells you where it is.

How multiple comparisons inflate false positives

Every test at α = 0.05 carries a 5% chance of a false positive when no true effect exists. Run several tests and those chances stack up. The number of pairs among k groups is k(k − 1) / 2, and the chance of at least one false positive across m comparisons is roughly 1 − (1 − α)^m.

Bar chart showing false positive chance rising from 14.3% with three groups to 90.1% with ten groups.

Number of groups Pairwise comparisons Chance of at least one false positive
3 3 14.3%
4 6 26.5%
5 10 40.1%
10 45 90.1%

These figures are approximations, because pairwise comparisons share data and are not fully independent. The pattern is real, though. With four groups, six uncorrected t-tests give you about one chance in four of declaring a difference that is not there. A larger sample does not fix this, because the problem comes from the number of tests and not from the amount of data.

Post hoc tests solve it by controlling the familywise error rate, the probability of at least one false positive across the whole set of comparisons. You set that rate once, usually at 0.05, and the test makes each individual comparison stricter so the total stays at 0.05.

When you can skip the post hoc test

Not every ANOVA needs a follow-up. You can skip it in three situations:

  • You compared only two groups. There is only one pair, so a two-sample t-test already answers the question.
  • The omnibus test was not significant. By convention you stop there. Digging for pairs after a null omnibus result is a common route to false findings.
  • You planned specific contrasts before collecting data. A hypothesis such as "the average of the two drug groups differs from placebo" is a planned contrast, not a post hoc search. It still needs a multiplicity adjustment if you test several of them.

How to run a post hoc test after ANOVA

To run a post hoc test after ANOVA, confirm that the omnibus test is significant, check the assumptions, pick the test that matches your question, run it at a familywise α of 0.05, and read the adjusted results. The order matters, because the choice of test should never depend on which pairs came out significant.

The six-step workflow

Follow this sequence for a one-way design:

  1. Run the omnibus test. Use the classic F-test, or Welch's ANOVA if variances differ. Continue only if the p-value is below your α.
  2. Check the assumptions. Observations should be independent, residuals roughly normal, and variances similar across groups. Levene's test and a residual plot cover the last two.
  3. Choose the post hoc test before looking at pair results. Match it to your question: all pairs, each group against a control, or the best group.
  4. Set the familywise α. Keep 0.05 unless your field's convention says otherwise.
  5. Run the test and read the adjusted output. Look at adjusted p-values and simultaneous confidence intervals, not raw pairwise p-values.
  6. Report effect sizes. Give each mean difference with its confidence interval, plus an overall effect size such as eta squared.

Steps 3 and 4 are where most mistakes begin. Decide the test in your analysis plan, so the data cannot steer the decision.

Choose the post hoc test before you see the pairwise results, because the choice itself can be a source of bias.

Running Tukey HSD in Python and R

Most statistical software has a built-in Tukey routine. In Python, the statsmodels package takes a column of outcomes and a column of group labels. Copy the snippet and swap in your own file and column names:

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

df = pd.read_csv("trial.csv")  # columns: group, outcome
result = pairwise_tukeyhsd(endog=df["outcome"], groups=df["group"], alpha=0.05)
print(result.summary())

In R, fit the ANOVA with aov() and pass the model to TukeyHSD():

fit <- aov(outcome ~ group, data = df)
summary(fit)
TukeyHSD(fit, conf.level = 0.95)

Both return one row per pair, with the mean difference, an adjusted p-value or confidence interval, and a flag for whether the pair differs at your familywise level. SPSS, Stata, SAS and GraphPad Prism offer the same test through their ANOVA dialogs and commands.

Which post hoc test to choose

Use Tukey's HSD when you want to compare every pair of groups and variances are similar. Use Dunnett when you compare several treatments only with one control. Use Games-Howell when variances are unequal. Use Bonferroni or Holm when you have a specific list of comparisons, or when you are adjusting tests that are not part of one ANOVA.

A side-by-side comparison of common tests

The tests differ in what they compare and how much power they give up for protection. This table sets the common options next to each other:

Test Best for Equal variances needed? Main trade-off
Tukey HSD All pairwise comparisons Yes Standard choice. Tukey-Kramer handles unequal group sizes
Bonferroni A chosen set of comparisons Depends on the underlying t-tests Power drops fast as comparisons increase
Holm Same uses as Bonferroni Same as Bonferroni Stepwise. Never less powerful than Bonferroni
Šidák Same uses as Bonferroni Same as Bonferroni Slightly less conservative than Bonferroni
Scheffé Complex contrasts, such as two groups pooled against a third Yes Widest intervals, so lowest power for simple pairs
Dunnett Each treatment against one control Yes Fewer comparisons, so more power than Tukey
Hsu's MCB Identifying the best group Yes Not designed for all pairs
Games-Howell All pairs when variances differ No Pairs with Welch's ANOVA. Can be unreliable with very small groups
Dunn's test Follow-up to Kruskal-Wallis Not applicable Rank-based. Needs a Holm or Bonferroni adjustment

Fisher's LSD runs unadjusted t-tests after a significant F-test. It is widely accepted only when you have exactly three groups, and you should avoid it beyond that.

Tukey or Bonferroni

For all pairwise comparisons in a one-way ANOVA, Tukey is the better default because it is more powerful than Bonferroni. Both control the familywise error rate. Tukey is built for exactly this family of comparisons, so it does not waste protection.

Bonferroni earns its place elsewhere. Its rule is simple: divide α by the number of comparisons m. With four groups and six pairs, each comparison uses 0.05 / 6 ≈ 0.0083. That works for any subset of comparisons, for mixed tests such as t-tests and chi-square tests, and for results you can adjust by hand. The price is conservatism. As comparisons grow, Bonferroni demands smaller and smaller p-values. If you want Bonferroni's flexibility with better power, use Holm, which orders the p-values and relaxes the threshold step by step.

The formulas behind both are short:

  • Tukey HSD: a pair differs when its mean difference exceeds q × √(MSE / n), where q is the studentized range value for your group count and error degrees of freedom, and n is the group size.
  • Bonferroni: compare each p-value with α / m, or multiply each p-value by m and compare it with α.
  • Šidák: use an individual α of 1 − (1 − α)^(1/m).

A short decision guide

Work through these questions in order and stop at the first yes:

  • Do you only care how each treatment compares with one control? Use Dunnett.
  • Do you want to find the best group and the groups that cannot be told apart from it? Use Hsu's MCB.
  • Are variances clearly unequal? Use Welch's ANOVA with Games-Howell.
  • Are your data ordinal or strongly non-normal? Use Kruskal-Wallis with Dunn's test.
  • Do you want every pair? Use Tukey HSD.
  • Do you have a short, pre-specified list of comparisons? Use Holm, or Bonferroni if you must adjust by hand.

Match the test to the family of comparisons you planned, not to the one that gives the smallest p-value.

How to interpret post hoc results with an example

Read a post hoc result by asking whether each pair's adjusted confidence interval excludes zero, or equivalently whether its adjusted p-value is below your familywise α. If the interval excludes zero, that pair differs. If it contains zero, you lack enough evidence to call the pair different, which is not the same as proving they are equal.

A four-group example

The numbers below are illustrative, not from a real trial. Suppose 60 patients are split into four groups of 15: placebo and three blood pressure drugs. The outcome is the drop in systolic pressure in mmHg, with a pooled standard deviation of 6.

A blood pressure cuff and gauge beside four medication bottles and a clipboard.

Group Mean reduction (mmHg)
Placebo 4.0
Drug A 8.5
Drug B 12.0
Drug C 13.0

The one-way ANOVA gives F(3, 56) = 6.90, p < 0.001, with eta squared of about 0.27. That is significant, so a post hoc test is justified. With a mean square error of 36 and 15 per group, the Tukey margin is about 3.75 × √(36 / 15) ≈ 5.8 mmHg. Every pair's interval is its mean difference plus or minus that margin:

Comparison Mean difference 95% Tukey interval Different?
Drug A vs placebo 4.5 (−1.3, 10.3) No
Drug B vs placebo 8.0 (2.2, 13.8) Yes
Drug C vs placebo 9.0 (3.2, 14.8) Yes
Drug B vs Drug A 3.5 (−2.3, 9.3) No
Drug C vs Drug A 4.5 (−1.3, 10.3) No
Drug C vs Drug B 1.0 (−4.8, 6.8) No

With Bonferroni on the same data, the margin would be roughly 6.0 mmHg instead of 5.8. The conclusions would not change here, but the intervals would be slightly wider.

Reading intervals, adjusted p-values, and letters

Software shows the same result in three forms. The confidence interval is the most informative, because it gives the size of the difference and the precision of the estimate. Drug B versus placebo is 8.0 mmHg, and the plausible range is 2.2 to 13.8. The adjusted p-value carries the same decision. Compare it directly with 0.05, because the adjustment has already been applied for you.

The third form is the compact letter display. Groups that share a letter are not significantly different. Here placebo gets "a," Drug A gets "ab," and Drugs B and C get "b." Drug A shares a letter with both sides because it cannot be separated from placebo or from the stronger drugs. That is a normal result, and it is more honest than forcing every group into a clean bin.

Statistical significance is not the same as practical importance. A pair can pass the test while the interval includes differences too small to matter clinically. Judge the interval against the smallest difference that would matter in your field.

What to do when ANOVA is significant but no pair is

This happens, and it is not an error. The omnibus test and the pairwise tests are different tests with different power, and the pairwise tests pay a price for correction. When the omnibus p-value is only just below 0.05, the data may be strong enough to show that the means are not all equal but too weak to say which ones differ.

Report exactly that. If you can repeat the study, collect a larger sample. Do not switch to a more lenient post hoc test to find a significant pair, because that is p-hacking. If you did not plan a narrower comparison in advance, the honest answer is the omnibus result plus the pairwise intervals as they stand.

A template for reporting the result

Copy this sentence structure and replace the figures with your own:

A one-way ANOVA showed a significant effect of treatment on systolic
blood pressure reduction, F(3, 56) = 6.90, p < .001, eta squared = 0.27.
Tukey HSD post hoc comparisons (familywise alpha = .05) showed that
Drug B (mean difference vs placebo = 8.0 mmHg, 95% CI [2.2, 13.8]) and
Drug C (9.0 mmHg, 95% CI [3.2, 14.8]) reduced pressure more than placebo.
No other pair differed significantly.

Report the mean difference and its interval for every pair you discuss, not just the p-value.

Post hoc tests when ANOVA assumptions break

When variances are unequal, switch to Welch's ANOVA with Games-Howell. When data are ordinal or strongly non-normal, use Kruskal-Wallis with Dunn's test. Repeated measures and two-way designs need different follow-up logic. Tukey's HSD assumes equal variances, so using it on data that violate that assumption quietly weakens the protection you wanted.

Unequal variances: Welch's ANOVA and Games-Howell

If Levene's test or a residual plot shows clearly different spreads, use Welch's ANOVA for the omnibus test. It does not assume equal variances, and many analysts use it by default because it costs little when variances turn out equal. The matching post hoc test is Games-Howell, which also does not assume equal variances.

A printed scatter plot with points spreading unevenly, lying next to a ruler and a pencil.

Unequal variances combined with unequal group sizes is where the classic F-test performs worst, so this pairing matters most then. In Python, the pingouin package offers pairwise_gameshowell(), and R packages such as rstatix offer games_howell_test(). Be cautious with very small groups. With a handful of observations per group, no post hoc test gives dependable answers, and the right framing is exploratory.

Non-normal or ordinal data: Dunn's test

For ordinal scales or skewed data that transformations cannot fix, the rank-based Kruskal-Wallis test replaces one-way ANOVA. Its follow-up is Dunn's test, which compares mean ranks between pairs. Apply a Holm or Bonferroni adjustment to the p-values, since Dunn's test itself does not control the familywise rate.

Remember that this test compares rank distributions, not means. Describe the results with medians and interquartile ranges so your wording matches what was tested.

Repeated measures and two-way designs

Designs with repeated measurements on the same people need post hoc comparisons that respect the pairing. A common approach is paired t-tests with a Holm or Bonferroni adjustment, or a Tukey routine that uses the correct within-subject error term in your software. Do not apply an independent-groups routine to paired data.

In a two-way ANOVA, look at the interaction first. If the interaction is significant, the effect of one factor depends on the other, so compare groups through simple effects, meaning comparisons of one factor at each level of the other. If there is no important interaction, a post hoc test on a main effect is reasonable when that factor has three or more levels. A factor with two levels needs no follow-up, because the ANOVA already compares those two.

Check the assumptions before you pick the post hoc test, because the right test depends on whether the variances and the design allow it.

Mistakes that weaken post hoc results

The most damaging mistakes are choosing the test after seeing the results, reading a non-significant pair as proof of equality, and reporting only p-values. Each one produces a conclusion that looks rigorous and is not. They are easy to avoid once you know them.

Choosing the test after seeing the data

Running Tukey, then Scheffé, then Bonferroni, and reporting whichever one gives you the significant pair is p-hacking. The methods give similar answers in most datasets, but in borderline cases they split, and picking the winner inflates your error rate again. Write the post hoc method into your analysis plan before you open the data.

If you forgot to plan one, imagine you were designing the study from scratch. Ask which comparisons your question needed, and choose the test that serves them. When no narrower question exists, all pairwise comparisons with Tukey is the safe default.

Treating "not significant" as "equal"

A pair that fails the test has not been shown to be the same. It has only failed to show a difference with the data you have. In the example above, Drug A versus placebo has an interval of (−1.3, 10.3). That range includes zero, but it also includes a 10 mmHg benefit that would matter clinically.

Wide intervals mean imprecise estimates, usually from small samples. Write "no significant difference was detected," not "Drug A had no effect," and let the interval show readers how much uncertainty remains.

Reporting only p-values or skipping the correction

Two habits cause trouble here. The first is running a pile of unadjusted t-tests after ANOVA and calling them a post hoc analysis. That reproduces the inflation shown in the first table. The second is reporting only p-values and leaving out the size of each difference.

Give the mean difference with its interval for every pair you discuss, plus an effect size for the overall model. Then reviewers can judge importance, not only significance.

A post hoc result without effect sizes tells readers that a difference exists but not whether it matters.

Running ANOVA with post hoc tests in PlotStudio AI

In PlotStudio AI, you describe the analysis in plain English, review the plan, and the app runs ANOVA and the post hoc test as Python code on your own machine. It does not replace your judgment about which test fits your design, so treat it as an assistant that does the mechanical work while you keep the decisions.

What to ask and what to verify

Upload your dataset and ask for the whole sequence in one request. A prompt like this works as a starting point:

Run a one-way ANOVA of systolic_reduction by group. Check normality of
residuals and equal variances. If the ANOVA is significant, run Tukey HSD
with familywise alpha 0.05 and report mean differences with 95% confidence
intervals, plus eta squared.

Use Verification Mode to review the proposed plan before anything executes. You can question the plan, change the method, for example to Welch's ANOVA with Games-Howell, and approve the assumptions. Choosing the test before seeing results is exactly what this step supports. Then check the output against what you learned above: adjusted intervals, the direction of each difference, and whether the effect sizes make sense in your field.

Keeping the analysis reproducible

Each question produces an analysis page with tables, figures, test results and interpretation, and you can inspect the generated code at every step. Dataset processing and Python execution happen locally. If your data are clinical or otherwise regulated, still check your institution's privacy and ethics requirements, because information sent to model providers follows the provider you configure.

For your methods section, you can export the analysis as a PDF report with embedded figures and tables, or as a Jupyter notebook that reproduces the results when you run all cells. The free trial starts with 30 credits and needs no credit card.

Choose the test before you see the data

A significant ANOVA tells you that some groups differ, and a post hoc test finds which ones without letting your false positive rate balloon. Use Tukey's HSD for all pairs with similar variances, Dunnett for treatments against a control, Games-Howell when variances differ, and Holm or Bonferroni for a short list of planned comparisons. Then read the adjusted intervals, report the size of each difference, and never treat a non-significant pair as proof of equality.

The habit that protects your results most is simple. Pick the post hoc test in your analysis plan, run it once, and report what it shows. If you want the mechanics handled while you keep control of the method, you can try PlotStudio AI on your own dataset and review every step of the analysis before it runs.

Post Hoc Test for ANOVA: What It Is and Which One to Use | PlotStudio AI