GARETH GRANTTECHNOLOGY · DATA · INNOVATION
Explore

23 / Inference

One-way ANOVA for several group means

One-way analysis of variance compares several group means in one overall test. It separates between-group differences from within-group variation, helping a business decide whether a factor deserves further investigation while controlling the initial comparison more coherently than many unplanned t-tests.

IntermediateLive exploration + Python

The business question

Do several production lines, branches or treatments have the same average outcome?

  • Compare average accepted output across several production lines.
  • Screen average service duration across three or more training methods.
  • Investigate a categorical factor before planned follow-up comparisons or an experiment.

How the method works

The word variance refers to the calculation, although the null hypothesis concerns equal population means. ANOVA measures how far group means sit from the overall mean, weighting by group size. It separately measures how far observations sit from their own group means. The between-group and within-group sums of squares quantify these different sources of variation.

Dividing each sum of squares by its degrees of freedom produces mean squares. The F statistic is the between-group mean square divided by the within-group mean square. If group means differ little compared with ordinary within-group variation, this ratio tends to be modest. A large ratio is evidence against equal means under the model; it does not reveal which specific pair differs.

The ordinary one-way version assumes a common within-group variance. Welch’s ANOVA relaxes that restriction; repeated measures and nested shifts require other designs. Report the group means, uncertainty and an effect-size summary, such as eta-squared, alongside the overall test. Planned contrasts or appropriately adjusted post-hoc comparisons can answer the particular operational question after the omnibus analysis.

The calculation

SS_between = Σ n_g(mean_g−grand_mean)²; SS_within = ΣΣ(y_ig−mean_g)²; F = [SS_between/(k−1)]/[SS_within/(N−k)]
Read the symbols
SymbolMeaning
kNumber of groups.
NTotal number of observations.
n_gNumber of observations in group g.
η²SS_between divided by total SS; a sample effect-size summary.

A worked business example

ILLUSTRATIVE SCENARIO

Illustrative accepted units per hour measured on three independent packing lines under comparable work.

Inputs

  • A: 48, 50, 49, 51, 52 units/hour.
  • B: 55, 54, 56, 53, 57 units/hour.
  • C: 50, 52, 51, 49, 53 units/hour.

Work through the numbers

  1. Group means are 50, 55 and 51; the grand mean is 52.
  2. Between-group SS = 5×[(50−52)²+(55−52)²+(51−52)²] = 70.
  3. Within-group SS = 10+10+10 = 30; df are 2 and 12.
  4. F = (70/2)/(30/12) = 14; p≈0.000729 and η² = 70/100 = 0.70.
The illustrative data provide evidence that not all three population means are equal under the ordinary ANOVA assumptions.

The test does not establish that B differs from both other lines or that buying B’s equipment would reproduce the result. Operator, product and scheduling differences need to be controlled before making that investment.

Explore the decision

Compare several independent means. The live explorer has its own example inputs; it is separate from the worked calculation above.

Enable JavaScript to use this calculator. The worked example and executable Python remain available.

Apply it at work

  1. Define the factor, response and business-relevant comparisons before collecting data.
  2. Sample comparable independent work and record operator, product, shift and measurement context.
  3. Inspect within-group variation and model residuals; choose ordinary, Welch or another suitable design.
  4. Report the overall result, effect size and group summaries, then evaluate planned adjusted comparisons and operating costs.

Check these assumptions

  • Groups contain independent observations; serial hours from one shift can violate this assumption.
  • For the ordinary test, errors have a common variance across groups.
  • Within-group errors are sufficiently compatible with normality for the sample sizes, particularly when samples are small.
  • The design separates the intended factor from important confounding variables or clearly acknowledges those limitations.

Common mistakes and how to avoid them

  • Running many unadjusted pairwise t-tests changes the overall false-positive risk.
  • Reporting only F and p hides the size, direction and operational relevance of group differences.
  • Treating observational group labels as randomised treatments turns an association into an unsupported causal claim.

How this can help the business

  • A manager can identify a factor worth controlled investigation before standardising equipment or training.
  • Effect-size and cost analysis can distinguish a statistically visible difference from one large enough to improve accepted output.
A decision rule to adapt

Use the overall test to decide whether further planned comparison is warranted, then require a practical improvement and a credible design before changing the business.

When to use another approach

Consider Welch’s ANOVA for unequal variances, Kruskal–Wallis for suitable distributional comparisons, or regression and mixed models for more complex structures.

Reproduce the worked example in Python

The code is self-contained for this example. Dependencies and run instructions are included with the downloadable notebook.

Show executable code and recorded output
import numpy as np
from scipy import stats
groups = [np.array([48,50,49,51,52]), np.array([55,54,56,53,57]), np.array([50,52,51,49,53])]
test = stats.f_oneway(*groups)
grand_mean = np.concatenate(groups).mean()
between = sum(len(g)*(g.mean()-grand_mean)**2 for g in groups)
within = sum(((g-g.mean())**2).sum() for g in groups)
eta_squared = between/(between+within)
print("Group means:", [round(float(g.mean()), 2) for g in groups])
print("Between and within SS:", round(between, 3), round(within, 3))
print("F and p:", round(test.statistic, 3), round(test.pvalue, 6))
print("Eta-squared:", round(eta_squared, 3))

Recorded output

Group means: [50.0, 55.0, 51.0]
Between and within SS: 70.0 30.0
F and p: 14.0 0.000729
Eta-squared: 0.7
Download all worked examples

Sources and further reading

Concepts are linked to primary teaching or technical sources. The business examples are illustrative applications, not reported client results.