Foundations of Analysis of Variance (ANOVA)
From the Biometry curriculum
TL;DR
ANOVA helps you compare the average values (means) of three or more groups to see if they're significantly different from each other. It works by breaking down the total variation in your data into different sources, allowing you to assess if group differences are greater than random chance. The core idea is to compare variance between groups to variance within groups.
1. The Mental Model
Imagine you have several baskets of apples, and you want to know if the average weight of apples is truly different across the baskets, or if any differences you see are just random. ANOVA is like a careful scale that helps you weigh these differences, separating true group effects from everyday variation.
2. The Core Material
ANOVA, or Analysis of Variance, is a statistical test used to determine if there are significant differences between the means of three or more independent groups. It's an extension of the independent samples t-test, which only compares two groups.
The fundamental principle of ANOVA is to partition the total variability in your data into different components:
- Between-group variability: This measures how much the means of your different groups vary from the overall mean of all data. It reflects the effect of your treatment or factor.
- Within-group variability: This measures the natural variation or random error within each group. It's the variability that's not explained by your grouping factor.
If the between-group variability is significantly larger than the within-group variability, it suggests that at least one group mean is different from the others.
The Null and Alternative Hypotheses

Photo by Tara Winstead on Pexels
- Null Hypothesis (H₀): All group means are equal. (e.g., μ₁ = μ₂ = μ₃)
- Alternative Hypothesis (H₁): At least one group mean is different from the others. (e.g., μ₁ ≠ μ₂ or μ₁ ≠ μ₃ or μ₂ ≠ μ₃)
The F-statistic

Photo by Linken Van Zyl on Pexels
ANOVA uses an F-statistic to test these hypotheses. The F-statistic is essentially a ratio:
$F = \frac{\text{Variance Between Groups}}{\text{Variance Within Groups}}$
- If F is close to 1: The variance between groups is similar to the variance within groups. This suggests no significant difference between group means.
- If F is much greater than 1: The variance between groups is much larger than the variance within groups. This suggests significant differences between at least some group means.
You then compare this calculated F-statistic to a critical F-value (from an F-distribution table or statistical software) or, more commonly, use the p-value associated with your calculated F-statistic. If the p-value is less than your chosen significance level (e.g., 0.05), you reject the null hypothesis.
Assumptions of ANOVA

Photo by Jon Eliya on Pexels
ANOVA is robust, but it relies on a few key assumptions:
- Independence of Observations: Data points within and between groups must be independent.
- Normality: The data within each group should be approximately normally distributed. This assumption is less critical with larger sample sizes due to the Central Limit Theorem.
- Homogeneity of Variances: The variance within each group should be roughly equal (homoscedasticity). You can check this using tests like Levene's test.
Post-Hoc Tests

Photo by Linken Van Zyl on Pexels
If your ANOVA yields a significant result (you reject H₀), it only tells you that at least one group mean is different. It doesn't tell you which specific groups differ. To find this out, you need to perform post-hoc tests (e.g., Tukey's HSD, Bonferroni correction). These tests make pairwise comparisons between groups while controlling for the increased chance of Type I errors (false positives) when doing multiple comparisons.
graph TD
A["Start: Want to compare 3+ group means?"] --> B{"Is ANOVA appropriate?"}
B -- Yes --> C["Collect your data (Factor: independent variable, Levels: groups)"]
C --> D{"Check Assumptions:"}
D -- "Independent Observations" --> D
D -- "Normality within groups" --> D
D -- "Homogeneity of Variances" --> D
D -- All good --> E["Calculate Sum of Squares (Total, Between, Within)"]
E --> F["Calculate Mean Squares (Between, Within)"]
F --> G["Calculate F-statistic"]
G --> H{"Compare F-statistic to critical F or p-value"}
H -- p < alpha (e.g., 0.05) --> I["Reject H₀: At least one group mean is different"]
I --> J["Perform Post-Hoc Tests (e.g., Tukey HSD)"]
J --> K["Identify specific group differences"]
H -- p >= alpha --> L["Fail to Reject H₀: No significant difference between group means"]
K --> M["Conclude & Report"]
L --> M
3. Worked Example
Let's say you're a plant scientist testing the effect of three different fertilizers (A, B, C) on plant growth (measured in cm after 4 weeks). You grow 5 plants for each fertilizer.
Here's some hypothetical data:
- Fertilizer A: 18, 20, 22, 19, 21 (Mean = 20)
- Fertilizer B: 15, 17, 16, 14, 18 (Mean = 16)
- Fertilizer C: 23, 25, 24, 22, 26 (Mean = 24)
We want to use R to perform a one-way ANOVA.
# Sample data
fertilizer_A <- c(18, 20, 22, 19, 21)
fertilizer_B <- c(15, 17, 16, 14, 18)
fertilizer_C <- c(23, 25, 24, 22, 26)
# Combine data into a single vector
plant_growth <- c(fertilizer_A, fertilizer_B, fertilizer_C)
# Create a factor variable for fertilizer type
fertilizer_type <- factor(c(rep("A", 5), rep("B", 5), rep("C", 5)))
# Create a data frame
plant_data <- data.frame(plant_growth, fertilizer_type)
# Perform One-Way ANOVA
anova_result <- aov(plant_growth ~ fertilizer_type, data = plant_data)
# Print the ANOVA summary
summary(anova_result)
# If significant, perform a post-hoc test (Tukey HSD)
# TukeyHSD(anova_result) # Uncomment to run this if you install `agricolae` or `stats` for base R
Output of summary(anova_result) might look something like this:
Df Sum Sq Mean Sq F value Pr(>F)
fertilizer_type 2 160.0 80.00 40.00 4.09e-05 ***
Residuals 12 24.0 2.00
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Here's how to interpret it:
- Df (Degrees of Freedom): 2 for
fertilizer_type(3 groups - 1), 12 forResiduals(Total observations - number of groups = 15 - 3). - Sum Sq (Sum of Squares): Measures variation.
fertilizer_type(Between-group) is 160.0;Residuals(Within-group) is 24.0. - Mean Sq (Mean Squares): Sum Sq divided by Df.
fertilizer_typeis 80.00;Residualsis 2.00. - F value: The ratio of Mean Sq (Between / Within) = 80.00 / 2.00 = 40.00.
- Pr(>F) (p-value): This is 4.09e-05 (which is 0.0000409).
Since the p-value (0.0000409) is much smaller than a common significance level like 0.05, we reject the null hypothesis. This means there is a statistically significant difference in plant growth among the three fertilizer types. To find out which specific fertilizers differ, you would then run a post-hoc test like TukeyHSD.
4. Key Takeaways
- ANOVA compares means of three or more groups by analyzing variances.
- It tests if group differences are larger than natural variation within groups.
- The F-statistic is the core ratio: Variance Between Groups / Variance Within Groups.
- A significant F-value (small p-value) indicates at least one group mean is different.
- Always check ANOVA's assumptions: independence, normality, and homogeneity of variances.
- If ANOVA is significant, use post-hoc tests to pinpoint which specific group means differ.
- ANOVA does not tell you the direction or magnitude of differences, only if they exist.
Common Mistakes to Avoid:
- Don't use ANOVA for only two groups; a t-test is more appropriate and simpler.
- Never skip post-hoc tests after a significant ANOVA if you need to know specific differences.
- Don't interpret a significant ANOVA as meaning all groups are different from each other.
- Forgetting to check assumptions can lead to unreliable results.
5. Now Try It
You're a quality control manager comparing the average breaking strength of ropes from four different suppliers (A, B, C, D). You test 6 ropes from each supplier.
1. Hypothesize: State the null and alternative hypotheses for this scenario.
2. Plan: Describe in one sentence what a significant ANOVA result would tell you and what your next step would be.
3. Reflect: What would it mean if your ANOVA was not significant (p-value > 0.05)?
Success looks like clearly stating the hypotheses, outlining the interpretation of results, and correctly explaining the implication of a non-significant finding.
Frequently asked about Foundations of Analysis of Variance (ANOVA)
Study this next
Get the full Biometry curriculum
Clone the complete plan to your dashboard for unlimited AI-generated notes, practice quizzes, and a personalised revision schedule.
Save this course free