Knowledge / Statistics / Analysis of variance (ANOVA)

Analysis of variance (ANOVA)

Statistics (B.Sc) · Inference · free study notes for exams, placements and interviews

In short

Analysis of variance (ANOVA) tests whether the means of three or more populations are equal by splitting the total variability in the data into a part explained by the groups (treatments) and a part left as random error, then comparing the two with an F ratio. It avoids the inflated Type I error that repeated t-tests would create. ANOVA is a core unit of the Inference paper in every B.Sc Statistics CBCS syllabus and appears in GATE Statistics (ST), ISS, CSIR-UGC NET, ICAR-ASRB and university practicals. In industry it is the standard tool for A/B and multi-arm testing, Six Sigma quality projects, agricultural and pharmaceutical trials, and analytics interviews at Indian firms.

Explained

Idea, model and assumptions

Partition of variability (the algebra)

One-way ANOVA: step-by-step

  1. Compute the grand total G = ΣΣ y_ij, N, and the correction factor CF = G²/N.
  2. Raw sum of squares = ΣΣ y_ij². Then SST = ΣΣ y_ij² − CF.
  3. SSTr = Σ (T_i²/n_i) − CF, where T_i is the total of treatment i.
  4. SSE = SST − SSTr (obtained by subtraction, never computed first).
  5. Fill the ANOVA table, compute F = MSTr/MSE, compare with the table value, and state the conclusion in words.
  6. If H₀ is rejected, run a post-hoc test to find which pairs differ.
SourceSSdfMSF
Between treatmentsSSTrk − 1MSTrMSTr/MSE
Within (error)SSEN − kMSE
TotalSSTN − 1

Two-way ANOVA and higher layouts

Post-hoc and multiple comparisons

Alternatives, limitations and Indian practice

Key points

Formulas and examples

Grand total G = ΣΣ y_ij; N = Σ n_i; Correction factor CF = G² / N (same units as y²)
SST = ΣΣ y_ij² − CF (total sum of squares, df = N − 1)
SSTr = Σ (T_i² / n_i) − CF (between-treatment SS, df = k − 1); T_i = total of treatment i
SSE = SST − SSTr (error SS, df = N − k)
MSTr = SSTr/(k−1); MSE = SSE/(N−k); F = MSTr / MSE ~ F(k−1, N−k)
Two-way, no replication: SSBl = Σ(B_j²/k) − CF; SSE = SST − SSTr − SSBl, df = (k−1)(b−1)
Two-way with r replicates: SSAB = Σ(C_ij²/r) − CF − SSA − SSB; SSE df = ab(r−1)
Fisher's LSD = t_(α/2, N−k) √(MSE (1/n_i + 1/n_j)); Tukey HSD = q_(α,k,N−k) √(MSE/n)
Effect size η² = SSTr / SST (dimensionless, 0 to 1); ω² = (SSTr − (k−1)MSE)/(SST + MSE)
E(MSTr) = σ² + Σ n_i α_i² /(k−1); E(MSE) = σ²
Random model: E(MSTr) = σ² + n σ²_α; estimate σ̂²_α = (MSTr − MSE)/n
Symbols: y_ij = observation (units of the response, e.g. kg, ₹, seconds); k = number of treatments; b = blocks; r = replicates per cell; N = total observations; σ² = error variance.

Example 1 — One-way ANOVA, three machines (output in units/shift). Machine A: 20, 22, 24, 26 (T₁ = 92); B: 28, 30, 32, 30 (T₂ = 120); C: 18, 20, 22, 24 (T₃ = 84). n = 4 each, k = 3, N = 12.

SourceSSdfMSF
Machines178.667289.33316.75
Error48.00095.333
Total226.66711

Example 2 — Two-way ANOVA without replication (RBD): 3 fertilisers × 4 plots, yield in quintals.

Plot (block)F1F2F3Block total
I8121030
II10141236
III610824
IV8121030
Treatment total324840G = 120
SourceSSdfMSF
Fertilisers32216∞
Blocks2438∞
Error060
Total5611

Example 3 — Reading an ANOVA table backwards (common exam format). Given: k = 4 treatments, n = 6 per treatment, SSTr = 150, SST = 450.

Example 4 — F = t² check. Two groups of 5: A = 4, 6, 8, 10, 12 (mean 8); B = 9, 11, 13, 15, 17 (mean 13). Each group's Σ(y−ȳ)² = 40, so SSE = 80, MSE = 80/8 = 10. SSTr = 5(8−10.5)² + 5(13−10.5)² = 31.25 + 31.25 = 62.5. F = 62.5/10 = 6.25. Pooled t = (13−8)/√(10(1/5+1/5)) = 5/2 = 2.5, and 2.5² = 6.25 — confirming F = t².

# One-way ANOVA with post-hoc test in R
out  <- c(20,22,24,26, 28,30,32,30, 18,20,22,24)
mach <- factor(rep(c("A","B","C"), each = 4))
fit  <- aov(out ~ mach)
summary(fit)            # F = 16.75 on 2 and 9 df
bartlett.test(out ~ mach)   # equality of variances
TukeyHSD(fit)               # which pairs differ
DesignModelError dfUse
One-way (CRD)μ + α_iN − kHomogeneous material, k treatments
Two-way, no replication (RBD)μ + α_i + β_j(k−1)(b−1)One known source of nuisance variation
Two-way with replication+ (αβ)_ijab(r−1)Two factors and their interaction
Latin square+ row + column(k−1)(k−2)Two nuisance factors, k treatments

Where it is used

Interview questions

Common mistakes

Related topics

Hypothesis testing · Design of experiments · Non-parametric tests · Estimation theory · Regression analysis · Sampling methods and survey design

Open in the Knowledge reader →Find jobs →