Statistical Stories - ANOVA (ANalysis Of VAriance)
Below is a story, the assumptions, alternative tests, the formula and some use cases to help you understand the ANOVA statistical test. Visit statisticalstories.xyz/anova to read all this and play with an interactive visualization to help you fully understand this statistical test.

The Story
Once upon a time, there was an orchard owner named Dave. His orchard was filled with three types of fruit-bearing trees: Apple, Orange, and Mango. Dave loved experimenting with his trees and was always curious to see if there were any significant differences between their yields.
One sunny day, Dave decided to explore a statistical tool called ANOVA, short for Analysis of Variance, to help him understand the differences in yield among his orchard trees.
To begin his investigation, Dave carefully selected ten random apple trees, ten orange trees, and ten mango trees. He carefully noted down all the data and organized it in a table.
To apply ANOVA to his data, Dave needed to calculate the average yield for each tree type. After calculating this, Dave discovered that the Apple trees had an average yield of 200 fruits, the Orange trees had an average yield of 180 fruits, and the Mango trees had an average yield of 220 fruits.
Curiosity piqued, Dave wondered if these differences were statistically significant or simply due to random chance. He knew that ANOVA could help him find out.
Dave learned that ANOVA compares two types of variability: the variability within each group and the variability between the groups.
Within-group variability measures how much the fruit yields vary within each type of tree. If there is a lot of variation within each group, it suggests that the fruit yields are not very similar for that type of tree.
Between-group variability, on the other hand, measures how much the average fruit yields differ between the three types of trees. If there is a large difference between the average yields of the different types of trees, it suggests that the groups themselves are different.
Dave knew that ANOVA could calculate these variabilities using a special formula that takes into account the number of trees in each group, the means, and the individual fruit yield measurements. By plugging in his data, he could obtain two crucial values: the between-group sum of squares (SSB) and the within-group sum of squares (SSW). The ratio of these two values creates a statistical measure called the F statistic, which determines if the results are significant.
If the SSB is significantly larger than the SSW, it indicates that there is a strong likelihood that the average fruit yields of the different types of trees are indeed different. Conversely, if the SSW is larger, it suggests that the differences between the groups are likely due to random chance, and the average fruit yields are not significantly different.
Excited to unveil the truth, Dave eagerly applied ANOVA to his orchard data. The results showed that the SSB was substantially larger than the SSW. This meant that there was a significant difference between the three groups of trees. In simpler terms, the average fruit yields of Apple, Orange, and Mango trees were not the same.
Delighted by his discovery, Dave concluded that ANOVA was a powerful tool for determining if there were any meaningful differences in fruit yields between different types of trees. It enabled him to make informed decisions based on the data he collected, guiding him to optimize his orchard’s productivity.
From that day forward, Dave continued to explore the world of statistics and used ANOVA to analyze various aspects of his orchard. He was always eager to uncover hidden insights and make data-driven choices to nurture his trees and achieve bountiful harvests year after year.
Assumptions
1. Independence: Measurements or data points collected from one group should not be influenced by or dependent on the measurements from another group.
2. Normality: The data within each group should follow a normal distribution. Normality can be assessed through graphical methods like histograms or quantile-quantile (Q-Q) plots, or through statistical tests such as the Shapiro-Wilk test.
3. Homogeneity of Variance: The variability, or spread, of data within each group should be roughly equal across all groups. This assumption can be evaluated by examining the variability within each group or formally tested using statistical tests like Levene’s test or Bartlett’s test.
Alternative tests
Kruskal-Wallis Test: A non-parametric alternative when the assumption of normality is violated. It compares the medians of two or more groups by ranking the data and testing if the distribution of ranks differ significantly among the groups.
Friedman Test: A non-parametric alternative when the assumption of normality is violated. It comparesd three or more groups by ranking the data within each group and testing if the rankings differ significantly among the groups.
Brown-Forsythe Test: Can be used when the assumption of homogeneity of variance is violated. It works by measuring the spread in each group by performing an ANOVA on a transformation of the response variable and is more robust to unequal sample sizes than Welch’s F-test.
The Formula

Where:
- F: The F-statistic is the test statistic used in ANOVA. It represents the ratio of the between-group variability to the within-group variability. By comparing the F-statistic to the critical value from the F-distribution, we can determine if the differences between the group means are statistically significant.
- SSB: The Sum of Squares Between groups represents the variability or differences between the group means. It measures how much the group means deviate from the overall mean.
- SSW: The Sum of Squares Within groups represents the variability or differences within each group. It measures how much the individual observations deviate from their respective group means.
- k: The number of groups (or treatment levels). k−1 is the degrees of freedom for SSB.
- n: The total number of observations. n−k is the degrees of freedom for SSW.
- nᵢ: The number of observations in group i.
- X̄ᵢ: The mean of group i.
- X̄: The overall mean across all groups.
- Xᵢⱼ: The j^th observation in group i.
Example use cases
- Compare the effects of different fertilizers, pesticides, or irrigation methods on crop yields.
- Compare the effectiveness of different teaching methods, curriculum approaches, or interventions on student learning outcomes
- Compare the preferences or perceptions of different consumer groups towards products or advertisements.
- Compare the effects of different treatments or interventions on patient outcomes.
- Compare the impact of different factors (such as pollution levels, temperature variations, or habitat types) on biodiversity or ecological parameters