T-Test vs ANOVA Explained with a Clinical Example – A Complete Guide

t-test vs ANOVA clinical example: mean HbA1c reduction in three groups with one-way ANOVA and Tukey results

Comparing the mean of a continuous outcome between groups is one of the most frequent tasks in medical research. The two standard tools for this task are the t-test and the analysis of variance (ANOVA). The choice of t-test vs ANOVA depends mainly on the number of groups being compared. A common mistake is to run several t-tests when a study has three or more groups, which increases the chance of a false-positive result. This guide explains the difference between the two tests in simple steps, using one hypothetical clinical example from the beginning to the end.

T-Test vs ANOVA: What Is the Difference?

In the t-test vs ANOVA comparison, both tests compare means, and both assume a continuous outcome that is approximately normally distributed. The t-test compares two means only. In contrast, ANOVA compares two or more means in one test (Kim, 2017).

The Independent Samples t-Test

The independent samples t-test compares the means of two separate groups, such as a treatment group and a placebo group. For two groups of equal size n, the 2 sample t test formula is t = (x̄₁ − x̄₂) ÷ (sp × √(2/n)), where sp is the pooled standard deviation. The degrees of freedom equal n₁ + n₂ − 2. Our step-by-step t-test guide explains this calculation in more detail.

The Paired t-Test

The paired t-test compares two measurements taken from the same patients, for example before and after treatment. It analyzes the mean of the within-patient differences, so it should not be used for independent groups (Kim, 2015).

One-Way ANOVA

One-way ANOVA compares the means of three or more independent groups. It divides the total variation into variation between the groups and variation within the groups. The ratio of these two parts is the F statistic. A large F value indicates that at least one group mean differs from the others. Our guide to ANOVA in medical research describes other ANOVA designs.

Importance of Choosing Between T-Test vs ANOVA in Medical Research

Control of the Type I Error

Each t-test performed at α = 0.05 carries a 5% risk of a false-positive result. When several t-tests are performed on the same data, this risk accumulates. ANOVA tests all groups at once, so the overall type I error stays at 5% (Kim, 2017).

Efficient Use of All the Data

ANOVA estimates the within-group variance from all groups together. Therefore, the error term is based on more patients and more degrees of freedom than a single t-test that uses only two groups.

Meeting the Expectations of Peer Reviewers

Reviewers often ask why multiple t-tests were used in a study with three arms, so the t-test vs ANOVA decision should be described in the Methods. A clear justification of the selected test prevents this comment and improves the credibility of the manuscript.

Applications of T-Test and ANOVA in Clinical Studies

Randomized Controlled Trials

A two-arm trial with a continuous outcome, such as blood pressure or pain score, is usually analyzed with the independent samples t-test. A trial with three arms, for example two doses of a drug and a placebo, is analyzed with one-way ANOVA.

Observational and Epidemiological Studies

Researchers often compare a laboratory value across categories such as body mass index groups, smoking status or disease stage. When the variable has two categories, the t-test is used. When it has three or more categories, ANOVA is the suitable test, and the t-test vs ANOVA rule is the same as in trials.

Laboratory and Diagnostic Research

Experimental studies frequently compare a biomarker among healthy controls, patients with mild disease and patients with severe disease. In this setting, ANOVA followed by post hoc tests shows which groups differ from each other. Therefore, the t-test vs ANOVA question should be answered when the study groups are defined.

Assumptions of T-Test vs ANOVA

The two tests share the same assumptions, which should be checked before the analysis:

  • Continuous outcome: the dependent variable is measured on an interval or ratio scale.
  • Independent observations: each patient belongs to one group only and contributes one value. Repeated measurements require a paired t-test or repeated-measures ANOVA.
  • Approximate normality: the outcome follows an approximately normal distribution within each group. With larger samples, both tests are relatively robust to moderate departures.
  • Homogeneity of variance: the variance of the outcome is similar across groups. When this assumption is violated, Welch’s t-test or Welch’s ANOVA can be used (Kim, 2015).
  • No extreme outliers: outliers have a large influence on the mean and the variance, so they should be examined before testing.

How to Choose Between T-Test vs ANOVA: A Clinical Example

Consider a hypothetical randomized trial of 90 adults with type 2 diabetes. Patients were randomized equally to placebo, Drug A or Drug B (30 patients per group). The primary outcome was the reduction in HbA1c (%) after 12 weeks. The data were created for teaching purposes, and every value below was calculated from these data.

Step 1: Describe the Groups

The first step is to present the mean and the standard deviation of each group. The overall mean reduction was 0.80%.

Group n Mean HbA1c reduction (%) SD Shapiro-Wilk p
Placebo 30 0.40 0.60 0.773
Drug A 30 0.90 0.65 0.060
Drug B 30 1.10 0.70 0.486

Step 2: Count the Groups and Avoid Multiple t-Tests

The study has three groups, so three pairwise t-tests would be needed. The probability of at least one false-positive result equals 1 − 0.95³ = 14.3%, not 5%. With four groups (six comparisons), it rises to 26.5%, and with five groups (ten comparisons), it reaches 40.1%. Therefore, in the t-test vs ANOVA decision, ANOVA is the correct first test here.

Step 3: Check the Assumptions

The Shapiro-Wilk test showed no significant departure from normality in any group (all p > 0.05, Step 1 table). Moreover, Levene’s test showed equal variances across the three groups (F = 0.79, df = 2 and 87, p = 0.455). Consequently, the standard one-way ANOVA is appropriate.

Step 4: Run the One-Way ANOVA

The ANOVA table divides the total sum of squares into between-group and within-group parts:

Source Sum of squares df Mean square F p-value
Between groups 7.82 2 3.91 9.21 < 0.001
Within groups 36.92 87 0.424
Total 44.74 89

The F statistic equals 3.91 ÷ 0.424 = 9.21, with p < 0.001. Therefore, at least one group mean differs from the others. However, ANOVA does not show which groups differ, and a correct reading of the p-value requires the next step.

Step 5: Perform Post Hoc Comparisons

Tukey’s honestly significant difference (HSD) test compares every pair of groups while keeping the overall error rate at 5%:

Comparison Mean difference (%) 95% CI Adjusted p
Drug A vs placebo 0.50 0.10 to 0.90 0.011
Drug B vs placebo 0.70 0.30 to 1.10 < 0.001
Drug B vs Drug A 0.20 −0.20 to 0.60 0.461

Both drugs reduced HbA1c more than placebo. In contrast to three separate t-tests, these adjusted p-values protect against false-positive findings. However, the difference between Drug B and Drug A was not significant.

Step 6: Compare the t-Test and ANOVA for Two Groups

Suppose that the trial had included only placebo and Drug A. The independent samples t-test gives t = 3.10, df = 58, p = 0.003, with MD = 0.50%, 95% CI, 0.18 to 0.82. A one-way ANOVA on the same two groups gives F = 9.60, df = 1 and 58, p = 0.003. Notably, 3.098² = 9.60, so F = t². This step shows that for two groups, the t-test vs ANOVA choice gives the same answer, and the t-test is preferred because it also gives the direction and the confidence interval of the difference.

Step 7: Calculate the Effect Size

For ANOVA, eta squared equals SSbetween ÷ SStotal = 7.82 ÷ 44.74 = 0.175. Therefore, 17.5% of the variation in HbA1c reduction was explained by the treatment group. The less biased omega squared was 0.154. For the two-group comparison, Cohen’s d for Drug A vs placebo was 0.80, which is a large effect. Our guide on effect size explains these measures.

How to Report T-Test vs ANOVA Results in a Manuscript

The Methods section should name the test, the post hoc method and the software. The Results section should present the significant findings, as shown below:

Reduction in HbA1c According to Treatment Group
The mean reduction in HbA1c after 12 weeks differed significantly among the three groups (F = 9.21, df = 2 and 87, p < 0.001, η² = 0.175). Drug A was associated with a greater reduction compared to placebo (MD = 0.50%, 95% CI, 0.10 to 0.90, p = 0.011). Moreover, Drug B was associated with a greater reduction compared to placebo (MD = 0.70%, 95% CI, 0.30 to 1.10, p < 0.001). (Table 2)

Notably, possible explanations of these differences and comparisons with previous trials belong to the Discussion section, not to the Results.

Common Mistakes When Using T-Test vs ANOVA

Running Multiple t-Tests Instead of ANOVA

Step 2 showed that three t-tests raise the false-positive risk to 14.3%. Therefore, ANOVA should be used first whenever there are three or more groups (Kim, 2017).

Stopping at a Significant F Test

A significant F test only shows that the means are not all equal. Post hoc tests, such as Tukey or Bonferroni, are needed to identify the groups that differ.

Using an Independent Test for Paired Data

Before-and-after measurements on the same patients are not independent. They require a paired t-test or repeated-measures ANOVA, not the independent samples tests.

Ignoring Non-Normal Data or Unequal Variances

With small and skewed samples, non-parametric tests are safer. The Mann-Whitney U test replaces the t-test, and the Kruskal-Wallis test replaces one-way ANOVA. For unequal variances, Welch’s versions of both tests should be used.

Reporting p-Values Without Effect Sizes

Whatever the result of the t-test vs ANOVA choice, a p-value does not show the size of the difference. Mean differences with 95% CIs, eta squared or Cohen’s d should accompany every significant result.

Running T-Test vs ANOVA in SPSS and R

In SPSS, choose Analyze → Compare Means → Independent-Samples T Test for two groups. For three or more groups, choose Analyze → Compare Means → One-Way ANOVA, click Post Hoc and select Tukey, then click Options and select Homogeneity of variance test and Welch. In R, one line gives the ANOVA and the Tukey comparisons: TukeyHSD(aov(hba1c_change ~ group, data = d)). For two groups, use t.test(hba1c_change ~ group, data = d, var.equal = TRUE).

Conclusion

The decision on t-test vs ANOVA depends mainly on the number of groups. The t-test is suitable for two groups, while ANOVA with post hoc tests is the correct choice for three or more groups. Both tests require independent observations, approximate normality and similar variances. For help with choosing the right test, you can also read our guide to choosing the right statistical test. If you need support in analyzing your data or writing your Results section, the StatisMed team of biostatisticians provides statistical analysis services for medical studies. You can request a free quote today.

Frequently Asked Questions

1. Can I use ANOVA to compare only two groups?

Yes. In the t-test vs ANOVA comparison for two groups, ANOVA gives the same p-value as the t-test, because F = t². However, the t-test is usually reported because it shows the direction of the difference and its confidence interval.

2. Which post hoc test should I choose after ANOVA?

Tukey’s HSD is suitable when all pairs of groups are compared and the variances are equal. Dunnett’s test is suitable when each group is compared with one control group only, and the Games-Howell test is used when variances are unequal.

3. What if my outcome is not normally distributed?

With large groups, both tests are robust to mild departures from normality. With small or highly skewed samples, the Mann-Whitney U test or the Kruskal-Wallis test should be used instead. An adequate sample size also improves the robustness of the analysis.

References

Kim, T. K. (2015). T test as a parametric statistic. Korean Journal of Anesthesiology, 68(6), 540–546. https://doi.org/10.4097/kjae.2015.68.6.540

Kim, T. K. (2017). Understanding one-way ANOVA using conceptual figures. Korean Journal of Anesthesiology, 70(1), 22–26. https://doi.org/10.4097/kjae.2017.70.1.22

Related Posts