B Basira Blog

One-Way ANOVA: Comparing Three or More Groups

Basira Team · · 1 min read

  • #anova
  • #hypothesis-testing
  • #analysis-of-variance

To compare the means of two groups we use a t-test. But what if we have three, four, or more groups? This is where one-way ANOVA (Analysis of Variance) comes in.

Why not multiple t-tests?

Running several pairwise t-tests inflates the Type I error rate. With α=0.05\alpha = 0.05 per test, the chance of finding at least one false significant result across three comparisons climbs to about 14%.

The F statistic

ANOVA compares between-group variance to within-group variance:

F=Between-group varianceWithin-group variance=MSbetweenMSwithinF = \frac{\text{Between-group variance}}{\text{Within-group variance}} = \frac{MS_{\text{between}}}{MS_{\text{within}}}

When the differences between groups are large relative to the random variation within groups, FF grows and the pp value shrinks.

Box plot showing the score distributions of three methods
Figure 1 — Score distributions of three different methods. ANOVA tests whether their means are equal.

Assumptions

A quick look with Python

from scipy import stats

group_a = [82, 85, 88, 90, 86]
group_b = [78, 81, 84, 80, 83]
group_c = [91, 94, 89, 95, 92]

f_stat, p_value = stats.f_oneway(group_a, group_b, group_c)
print(f"F = {f_stat:.2f}, p = {p_value:.4f}")

When you find a significant result (p<0.05p < 0.05), move on to post-hoc tests (such as Tukey HSD) to see which groups differ.

Run it in Basira

Try the steps above on your own data in one click — assumption checks, post-hoc tests, and effect size are computed automatically.

Run in Basira

Upload your data, pick the grouping variable, and let Basira produce the F statistic, post-hoc tests, and effect size for you.

Related Basira modules