What Is ANOVA?
The logic behind ANOVA is straightforward: if all group means were equal (the null hypothesis), random sampling would still produce some variation between groups — but that variation should be roughly the same magnitude as the natural variation within each group. The F statistic measures the ratio. When groups truly differ, the between-group variation grows while within-group variation stays the same, pushing F upward. A large F means a small p-value, which means strong evidence against the null hypothesis.
ANOVA was developed by Ronald Fisher in the early 1920s as a way to analyze agricultural field experiments — comparing crop yields across different fertilizer treatments simultaneously. The name "Analysis of Variance" can be misleading: the test is about means, not variances. The variances are the tool used to test whether the means differ.
Comparing three groups with three separate t-tests inflates the Type I error rate. With α = 0.05, each test carries a 5% false-positive risk. Three tests together give a 1 − (0.95)³ ≈ 14.3% chance of at least one false positive. ANOVA tests all groups simultaneously, keeping the error rate at exactly α. See the full explanation in the ANOVA vs t-test comparison.
Types of ANOVA
Choosing the right type of ANOVA depends on how many independent variables you have, whether your measurements are independent, and the structure of your study design. The three most common types are described below.
| Feature | One-Way ANOVA | Two-Way ANOVA | Repeated Measures ANOVA |
|---|---|---|---|
| Independent variables | 1 (factor with ≥3 levels) | 2 (each with ≥2 levels) | 1 (time or condition) |
| Subjects measured | Once each | Once each | Multiple times each |
| Tests for | Main effect of Factor A | Main effects of A, B + interaction (A×B) | Changes over time / conditions |
| Classic example | 3 fertilizers → crop yield | Fertilizer × irrigation → crop yield | Drug scores at 3 time points |
| Nonparametric alternative | Kruskal-Wallis test | Aligned Ranks Transform | Friedman test |
When the same person is measured more than once, a standard one-way ANOVA is inappropriate because the observations are not independent. Repeated measures ANOVA accounts for the correlation between a subject's repeated scores by partitioning out individual subject variation from the error term, which increases statistical power. If you have more than one continuous dependent variable, the multivariate extension is MANOVA; if you want to control for a continuous covariate, the extension is ANCOVA.
Assumptions of ANOVA
- Independence: Each observation is independent of every other. Violated when the same subject appears in more than one group (use repeated measures ANOVA instead).
- Normality: Scores within each group are approximately normally distributed. ANOVA is fairly robust to this when group sizes are equal and n ≥ 20. Check with a Q-Q plot or the Shapiro-Wilk test.
- Homogeneity of Variance: The population variance is the same in all groups (homoscedasticity). Levene's test is the standard check. If violated, use Welch ANOVA.
- Random Sampling: Data should come from random samples of the relevant populations.
Of the four assumptions, homogeneity of variance receives the most scrutiny in practice. Levene's test produces its own F statistic; if that F is significant (p < 0.05), the variance assumption is violated and Welch ANOVA is the preferred remedy. The assumptions testing guide on Statistics Fundamentals walks through each check with worked examples. ANOVA is also more robust to normality violations when sample sizes across groups are equal — a design feature worth planning for when running experiments.
The ANOVA Formula
Every ANOVA calculation starts by partitioning the total variance in the dataset. The fundamental relationship is:
SS_Total = Total Sum of Squares
SS_Between = Between-Group Sum of Squares
SS_Within = Within-Group Sum of Squares
MS_Between = SS_Between / (k−1)
MS_Within = SS_Within / (N−k)
k = number of groups
N = total sample size
The ANOVA Table — Every Cell Explained
The results of every ANOVA are reported in a standardized table. Here is the template, with each cell described:
| Source of Variation | Sum of Squares (SS) | df | Mean Square (MS) | F | p-value |
|---|---|---|---|---|---|
| Between Groups (Treatment) | SS_B = Σnⱼ(x̄ⱼ − x̄)² | k − 1 | SS_B / (k−1) | MS_B / MS_W | From F-distribution |
| Within Groups (Error) | SS_W = ΣΣ(xᵢⱼ − x̄ⱼ)² | N − k | SS_W / (N−k) | — | — |
| Total | SS_T = ΣΣ(xᵢⱼ − x̄)² | N − 1 | — | — | — |
The Mean Square (MS) is simply the Sum of Squares divided by its degrees of freedom — it is a variance estimate. MS_Between estimates the population variance only if H₀ is true. MS_Within estimates the population variance regardless of whether H₀ is true. When the ratio F = MS_Between / MS_Within is close to 1, the group means are not more spread out than random chance would predict. When F is much larger than 1, the group means are spread out beyond what chance can explain, and the null hypothesis becomes untenable.
One-Way ANOVA Example 1 — Teaching Methods (Education)
This example tests whether three different teaching methods produce different exam scores. It is the most common type of ANOVA encountered in statistics courses and research methods classes.
Problem: A statistics instructor tests three teaching methods — Traditional Lecture (A), Flipped Classroom (B), and Problem-Based Learning (C) — on 15 students (5 per group). Exam scores (out of 100) are recorded. At α = 0.05, does teaching method affect exam performance?
| Student | Method A (Lecture) | Method B (Flipped) | Method C (PBL) |
|---|---|---|---|
| 1 | 78 | 88 | 72 |
| 2 | 82 | 91 | 68 |
| 3 | 85 | 87 | 74 |
| 4 | 79 | 93 | 70 |
| 5 | 76 | 85 | 71 |
| Group Mean | 80.0 | 88.8 | 71.0 |
State Hypotheses:
H₀: μ_A = μ_B = μ_C (all teaching method means are equal)
H₁: At least one teaching method mean differs
Calculate Grand Mean (x̄):
All scores: 78+82+85+79+76+88+91+87+93+85+72+68+74+70+71 = 1,179
Grand mean = 1,179 / 15 = 78.6
Calculate SS_Between (Between-Group Sum of Squares):
SS_B = Σ nⱼ(x̄ⱼ − x̄)²
SS_B = 5(80.0 − 78.6)² + 5(88.8 − 78.6)² + 5(71.0 − 78.6)²
SS_B = 5(1.96) + 5(104.04) + 5(57.76)
SS_B = 9.8 + 520.2 + 288.8 = 818.8
Calculate SS_Within (Within-Group Sum of Squares):
Method A: (78−80)²+(82−80)²+(85−80)²+(79−80)²+(76−80)² = 4+4+25+1+16 = 50
Method B: (88−88.8)²+(91−88.8)²+(87−88.8)²+(93−88.8)²+(85−88.8)² = 0.64+4.84+3.24+17.64+14.44 = 40.8
Method C: (72−71)²+(68−71)²+(74−71)²+(70−71)²+(71−71)² = 1+9+9+1+0 = 20
SS_W = 50 + 40.8 + 20 = 110.8
Degrees of Freedom:
df_Between = k − 1 = 3 − 1 = 2
df_Within = N − k = 15 − 3 = 12
df_Total = N − 1 = 15 − 1 = 14
Calculate Mean Squares and F:
MS_Between = 818.8 / 2 = 409.4
MS_Within = 110.8 / 12 = 9.23
F = 409.4 / 9.23 = 44.36
Complete ANOVA Table
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Between Groups | 818.8 | 2 | 409.4 | 44.36 | < 0.001 |
| Within Groups | 110.8 | 12 | 9.23 | — | — |
| Total | 929.6 | 14 | — | — | — |
✅ Decision: F(2, 12) = 44.36, p < 0.001. The critical value from the F-table at α = 0.05 with df(2, 12) is F* = 3.89. Since 44.36 > 3.89, reject H₀. There is strong evidence that teaching method significantly affects exam scores. Effect size: η² = 818.8 / 929.6 = 0.88 (very large — teaching method explains 88% of the total variance).
One-Way ANOVA Example 2 — Fertilizer Types (Agriculture)
Agricultural experiments were the original motivation for ANOVA. Ronald Fisher developed the method at Rothamsted Experimental Station to compare crop yields across different treatment conditions. This example follows that tradition.
Problem: An agronomist tests four fertilizer formulations (Control, Nitrogen, Phosphorus, Combined N+P) on wheat yield (bushels/acre). Each treatment is applied to 4 plots. At α = 0.05, does fertilizer type affect yield?
| Plot | Control | Nitrogen (N) | Phosphorus (P) | Combined N+P |
|---|---|---|---|---|
| 1 | 32 | 38 | 35 | 45 |
| 2 | 30 | 40 | 36 | 48 |
| 3 | 28 | 37 | 34 | 46 |
| 4 | 34 | 41 | 37 | 47 |
| Mean | 31.0 | 39.0 | 35.5 | 46.5 |
Hypotheses: H₀: μ_Ctrl = μ_N = μ_P = μ_NP | H₁: At least one fertilizer mean differs
Grand Mean:
Total = (32+30+28+34)+(38+40+37+41)+(35+36+34+37)+(45+48+46+47) = 124+156+142+186 = 608
Grand mean = 608 / 16 = 38.0
SS_Between:
SS_B = 4(31−38)² + 4(39−38)² + 4(35.5−38)² + 4(46.5−38)²
SS_B = 4(49) + 4(1) + 4(6.25) + 4(72.25)
SS_B = 196 + 4 + 25 + 289 = 514.0
SS_Within:
Control: (32−31)²+(30−31)²+(28−31)²+(34−31)² = 1+1+9+9 = 20
Nitrogen: (38−39)²+(40−39)²+(37−39)²+(41−39)² = 1+1+4+4 = 10
Phosphorus: (35−35.5)²+(36−35.5)²+(34−35.5)²+(37−35.5)² = 0.25+0.25+2.25+2.25 = 5
Combined: (45−46.5)²+(48−46.5)²+(46−46.5)²+(47−46.5)² = 2.25+2.25+0.25+0.25 = 5
SS_W = 20 + 10 + 5 + 5 = 40.0
df and Mean Squares:
df_Between = 4 − 1 = 3 | df_Within = 16 − 4 = 12
MS_Between = 514.0 / 3 = 171.33 | MS_Within = 40.0 / 12 = 3.33
F = 171.33 / 3.33 = 51.44
ANOVA Table
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Between Groups | 514.0 | 3 | 171.33 | 51.44 | < 0.001 |
| Within Groups | 40.0 | 12 | 3.33 | — | — |
| Total | 554.0 | 15 | — | — | — |
✅ Decision: F(3, 12) = 51.44, p < 0.001. Critical value at α = 0.05 with df(3,12) is F* = 3.49. Since 51.44 > 3.49, reject H₀. Fertilizer type significantly affects wheat yield. η² = 514/554 = 0.928 — fertilizer type accounts for 92.8% of the variance in yield. Post hoc testing is required to identify which fertilizer pairs differ significantly.
Post Hoc Tests After Significant ANOVA
A significant ANOVA result tells you that at least one group mean differs — but not which pairs of groups are responsible. Post hoc tests answer that question. They compare all possible pairs of group means while controlling the family-wise error rate.
Post hoc tests are follow-up procedures for a significant F. Running them without a significant F inflates Type I error, because you're effectively running multiple comparisons without adequate justification.
Tukey HSD Test — Worked Example
The Tukey Honestly Significant Difference (HSD) test, developed by John Tukey, compares all pairwise mean differences against a single critical value. It is the most widely recommended post hoc test when sample sizes are equal and all pairwise comparisons are desired.
Using the results from Example 1 (k=3, n=5, MS_Within = 9.23), test all pairwise differences at α = 0.05.
Calculate the Standard Error for Tukey HSD:
SE = √(MS_Within / n) = √(9.23 / 5) = √(1.846) = 1.358
Find the critical q value:
From the Tukey's q-table with k=3 groups and df_Within=12: q* = 3.77 at α = 0.05
HSD = q* × SE = 3.77 × 1.358 = 5.12
Any pair with |mean difference| > 5.12 is statistically significant.
Compare all pairs:
| Comparison | Mean Difference | HSD = 5.12 | Significant? |
|---|---|---|---|
| Method A vs Method B | |80.0 − 88.8| = 8.8 | 8.8 > 5.12 | Yes ✓ |
| Method A vs Method C | |80.0 − 71.0| = 9.0 | 9.0 > 5.12 | Yes ✓ |
| Method B vs Method C | |88.8 − 71.0| = 17.8 | 17.8 > 5.12 | Yes ✓ |
✅ All three pairwise comparisons are significant. Method B (Flipped Classroom, x̄ = 88.8) outperforms both Method A (Lecture, x̄ = 80.0) and Method C (PBL, x̄ = 71.0). Method A also significantly outperforms Method C. Conclusion: the Flipped Classroom method produces the highest exam scores.
Choosing a Post Hoc Test
Tukey HSD
Best for: equal sample sizes, all pairwise comparisons. Controls family-wise error rate at exactly α. The go-to default in most research contexts. Referenced in the statsmodels pairwise_tukeyhsd function (Python) and R's TukeyHSD().
Bonferroni Correction
Best for: a small number of planned comparisons (not all pairs). Divides α by the number of comparisons: α' = α / m. More conservative than Tukey but straightforward to apply. See the full guide at Bonferroni Correction on Statistics Fundamentals.
Scheffé Test
Best for: complex contrasts, not just pairwise comparisons. The most conservative post hoc test — appropriate when you want to compare combinations of groups (e.g., average of A and B vs. C). Available as part of R's multcomp package and the Scheffé critical values table.
Dunnett's Test
Best for: comparing multiple treatment groups against a single control group (not all pairs). More powerful than Tukey when only control comparisons are needed. See the Dunnett's test guide and corresponding Dunnett's table.
Two-Way ANOVA Example — Drug Dose and Gender (Medicine)
Two-way ANOVA tests the effect of two independent variables (factors) simultaneously. It produces three F statistics: one for each main effect and one for their interaction. The interaction is often the most scientifically interesting result — it tells you whether the effect of one factor changes depending on the level of the other.
Problem: A pharmaceutical researcher examines whether drug dose (Low, High) and patient sex (Male, Female) affect systolic blood pressure reduction (mmHg). Two subjects per cell (n = 8 total). At α = 0.05, test the main effect of Dose, the main effect of Sex, and the Dose × Sex interaction.
| Male | Female | Row Mean | |
|---|---|---|---|
| Low Dose | 6, 8 (mean: 7) | 4, 6 (mean: 5) | 6.0 |
| High Dose | 12, 14 (mean: 13) | 10, 12 (mean: 11) | 12.0 |
| Column Mean | 10.0 | 8.0 | GM = 9.0 |
Three sets of hypotheses:
Dose: H₀: μ_Low = μ_High | H₁: μ_Low ≠ μ_High
Sex: H₀: μ_Male = μ_Female | H₁: μ_Male ≠ μ_Female
Interaction: H₀: No Dose × Sex interaction | H₁: Interaction exists
SS_Dose (Main Effect — rows):
n per row = 4 (2 cells × 2 subjects)
SS_Dose = 4[(6 − 9)² + (12 − 9)²] = 4[9 + 9] = 72.0
SS_Sex (Main Effect — columns):
n per column = 4
SS_Sex = 4[(10 − 9)² + (8 − 9)²] = 4[1 + 1] = 8.0
SS_Interaction:
n per cell = 2
Cell means: LL_Male=7, Low_Female=5, High_Male=13, High_Female=11
SS_Cells = 2[(7−9)²+(5−9)²+(13−9)²+(11−9)²] = 2[4+16+16+4] = 80
SS_Interaction = SS_Cells − SS_Dose − SS_Sex = 80 − 72 − 8 = 0.0
(No interaction: both dose levels show the same male–female gap of 2 mmHg)
SS_Within (Error):
Low-Male: (6−7)²+(8−7)² = 2 | Low-Female: (4−5)²+(6−5)² = 2
High-Male: (12−13)²+(14−13)² = 2 | High-Female: (10−11)²+(12−11)² = 2
SS_W = 2+2+2+2 = 8.0
Degrees of Freedom and F statistics:
df_Dose = 1 | df_Sex = 1 | df_Interaction = 1 | df_Within = N − ab = 8 − 4 = 4
MS_Within = 8.0 / 4 = 2.0
F_Dose = (72.0/1) / 2.0 = 36.0
F_Sex = (8.0/1) / 2.0 = 4.0
F_Interaction = (0.0/1) / 2.0 = 0.0
Two-Way ANOVA Table
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Dose (A) | 72.0 | 1 | 72.0 | 36.0 | 0.004 |
| Sex (B) | 8.0 | 1 | 8.0 | 4.0 | 0.116 |
| Dose × Sex | 0.0 | 1 | 0.0 | 0.0 | 1.000 |
| Within (Error) | 8.0 | 4 | 2.0 | — | — |
| Total | 88.0 | 7 | — | — | — |
✅ Dose is significant (F = 36.0, p = 0.004): high dose reduces blood pressure more than low dose. Sex is not significant (F = 4.0, p = 0.116) at α = 0.05. The Dose × Sex interaction is not significant (F = 0.0, p = 1.000): the dose effect is the same for both males and females. The drug's dose effect is consistent across patient sex. Partial η² for Dose = 72.0 / (72.0 + 8.0) = 0.90.
Repeated Measures ANOVA Example — Anxiety Scores (Psychology)
Repeated measures ANOVA is used when the same participants are measured at multiple time points or under multiple conditions. Because each person serves as their own control, individual differences are removed from the error term, making the test more sensitive than a standard one-way ANOVA on different subjects.
Problem: Five patients are measured for anxiety (GAD-7 scale) at three time points: Before therapy (T1), 4 weeks into therapy (T2), and 8 weeks into therapy (T3). At α = 0.05, does anxiety change significantly over time?
| Patient | T1 (Before) | T2 (4 weeks) | T3 (8 weeks) | Subject Mean |
|---|---|---|---|---|
| P1 | 18 | 14 | 10 | 14.0 |
| P2 | 16 | 12 | 8 | 12.0 |
| P3 | 20 | 15 | 11 | 15.3 |
| P4 | 14 | 11 | 7 | 10.7 |
| P5 | 17 | 13 | 9 | 13.0 |
| Time Mean | 17.0 | 13.0 | 9.0 | GM = 13.0 |
Hypotheses:
H₀: μ_T1 = μ_T2 = μ_T3 (no change in anxiety over time)
H₁: At least one time point mean differs
SS_Time (Treatment Effect):
SS_Time = n × Σ(x̄_t − GM)²
SS_Time = 5[(17−13)² + (13−13)² + (9−13)²] = 5[16+0+16] = 160.0
SS_Subjects (Between-Subjects):
SS_Subjects = k × Σ(x̄_s − GM)²
SS_Subjects = 3[(14−13)²+(12−13)²+(15.3−13)²+(10.7−13)²+(13−13)²]
SS_Subjects = 3[1+1+5.29+5.29+0] = 3[12.58] = 37.74
SS_Total and SS_Error:
SS_Total = Σ(x − GM)²: calculating for all 15 scores...
SS_Total = (18−13)²+(16−13)²+...+(9−13)² = 25+9+49+1+16+1+1+4+5.29+0+9+25+4+36+16 =
T1: 25+9+49+1+16=100 | T2: 1+1+4+4+0=10 | T3: 9+25+4+36+16=90 → SS_Total = 200.0
SS_Error = SS_Total − SS_Time − SS_Subjects = 200.0 − 160.0 − 37.74 = 2.26
Degrees of Freedom:
df_Time = k − 1 = 2 | df_Subjects = n − 1 = 4 | df_Error = (k−1)(n−1) = 2×4 = 8
MS_Time = 160 / 2 = 80.0 | MS_Error = 2.26 / 8 = 0.2825
F = 80.0 / 0.2825 = 283.2
| Source | SS | df | MS | F | p-value |
|---|---|---|---|---|---|
| Time (Treatment) | 160.0 | 2 | 80.0 | 283.2 | < 0.001 |
| Subjects | 37.74 | 4 | 9.44 | — | — |
| Error (Residual) | 2.26 | 8 | 0.28 | — | — |
| Total | 200.0 | 14 | — | — | — |
✅ F(2, 8) = 283.2, p < 0.001. The critical value at α = 0.05 with df(2,8) is F* = 4.46. Reject H₀: anxiety scores decrease significantly over the three time points. Partial η² = SS_Time / (SS_Time + SS_Error) = 160.0 / 162.26 = 0.986 — time accounts for 98.6% of the residual variance, confirming a very large treatment effect. Note: Mauchly's test of sphericity should be checked before interpreting these results. If sphericity is violated, use the Greenhouse-Geisser correction to adjust the degrees of freedom.
Real-World Applications of ANOVA
ANOVA appears across a broad range of fields wherever researchers need to compare three or more groups on a continuous outcome. Below are the most common domains, each with a concrete example of the research question ANOVA would answer.
Healthcare & Clinical Trials
Comparing three dosage levels of an antidepressant. Testing whether four surgical techniques produce different recovery times. Analyzing patient outcomes across hospital wards. See how statistics powers clinical trials.
Agriculture & Biology
The original Fisher use case: comparing fertilizer formulas, irrigation methods, or seed varieties on crop yield. Also used in ecology to compare species counts across habitats.
Business & Marketing
A/B/C testing to compare three landing page designs. Testing whether sales figures differ across five regional offices. Comparing customer satisfaction scores across product lines. See the guide on A/B testing statistics.
Education Research
Comparing exam scores across different curricula, class sizes, or instructor experience levels. Testing whether reading intervention programs differ in effectiveness across grade levels.
Psychology
Repeated measures ANOVA for therapy outcome studies — measuring anxiety or depression scores at baseline, mid-treatment, and post-treatment. Between-groups ANOVA for comparing cognitive training programs.
Manufacturing
Quality control: comparing defect rates across three production shifts. Testing whether four machine settings produce different output tolerances. Optimizing process variables using factorial designs.
ANOVA vs Other Tests — Decision Guide
Which Test Should I Use? — Decision Guide
| Feature | ANOVA | Multiple t-Tests | Kruskal-Wallis |
|---|---|---|---|
| Groups compared | 3 or more | Any (pair by pair) | 3 or more |
| Type I error control | Maintained at α | Inflated across tests | Maintained at α |
| Normality required | Yes (robust to violations) | Yes | No (rank-based) |
| Effect size measure | η², partial η² | Cohen's d | ε² (epsilon-squared) |
| Post hoc available | Yes (Tukey, Bonferroni, Scheffé) | N/A (is the post hoc) | Yes (Dunn's test) |
Effect Size — η² and Partial η²
The F statistic tells you whether a difference exists. Effect size tells you how large that difference is in practical terms. A very large sample can produce a statistically significant F for a tiny, meaningless effect. Always report effect size alongside the F statistic and p-value. The full effect size guide on Statistics Fundamentals covers Cohen's d, eta squared, and more.
| Measure | Formula | Small | Medium | Large | When to Use |
|---|---|---|---|---|---|
| η² (Eta Squared) | SS_Between / SS_Total | 0.01 | 0.06 | 0.14 | One-way ANOVA; proportion of total variance explained |
| Partial η² (Partial Eta Squared) | SS_Effect / (SS_Effect + SS_Error) | 0.01 | 0.06 | 0.14 | Multi-factor ANOVA; variance explained by each factor ignoring others |
| ω² (Omega Squared) | (SS_B − (k−1)MS_W) / (SS_T + MS_W) | 0.01 | 0.06 | 0.14 | Less biased estimate of population effect; preferred in small samples |
For Example 1 (teaching methods), η² = 818.8 / 929.6 = 0.88 is a very large effect — teaching method alone explains 88% of the variance in exam scores. For Example 3 (two-way ANOVA), partial η² for Dose = 72.0 / (72.0 + 8.0) = 0.90. The distinction matters in multi-factor designs: η² for each factor adds up to more than 1.0 (since each uses the same SS_Total), while partial η² for each factor can be interpreted independently. SPSS reports partial η² by default; R's effectsize package and Python's pingouin.anova() report both.
Common Mistakes in ANOVA
| Mistake | Why It's Wrong | What to Do Instead |
|---|---|---|
| "ANOVA tells me which groups differ" | ANOVA only flags that at least one group differs | Run post hoc tests (Tukey HSD, Bonferroni) after a significant F to identify specific pairs |
| Running ANOVA on 2 groups | For exactly 2 groups, a t-test is equivalent and more direct | Use an independent samples t-test; ANOVA on 2 groups gives F = t² |
| Ignoring the homogeneity assumption | Unequal variances inflate the Type I error rate | Run Levene's test first; if p < 0.05, use Welch ANOVA instead |
| Reporting only the p-value | Statistical significance depends heavily on sample size | Always report F(df_between, df_within), p-value, and η² or partial η² |
| Using standard ANOVA for repeated measures | Violates the independence assumption; underestimates error | Use repeated measures ANOVA; check sphericity with Mauchly's test |
| Running post hoc tests without a significant F | Inflates family-wise Type I error rate | Only run post hoc tests after obtaining a significant omnibus F |
One-Way ANOVA Calculator
Enter your raw data below — one group per row, values separated by commas. The calculator computes SS_Between, SS_Within, degrees of freedom, MS, F, and the p-value, then gives the decision at α = 0.05.
🔬 One-Way ANOVA Calculator (up to 5 groups)
ANOVA Glossary — Key Terms and Formulas
| Term / Symbol | Definition | Formula |
|---|---|---|
| ANOVA | Analysis of Variance — tests whether 3+ group means differ by partitioning total variance | F = MS_B / MS_W |
| F statistic | Ratio of between-group variance to within-group variance; the test statistic for ANOVA | F = MS_Between / MS_Within |
| SS_Between | Between-group sum of squares — measures how much group means vary around the grand mean | Σ nⱼ(x̄ⱼ − x̄)² |
| SS_Within | Within-group sum of squares — measures random variation within each group | ΣΣ(xᵢⱼ − x̄ⱼ)² |
| MS_Between | Mean square between groups — SS_B divided by its degrees of freedom | SS_B / (k−1) |
| MS_Within | Mean square within groups — SS_W divided by its degrees of freedom; the error variance estimate | SS_W / (N−k) |
| df_Between | Degrees of freedom for between-group variance | k − 1 |
| df_Within | Degrees of freedom for within-group variance | N − k |
| η² (eta squared) | Proportion of total variance explained by the group factor | SS_Between / SS_Total |
| Tukey HSD | Post hoc test comparing all group pairs while controlling family-wise error; developed by John Tukey | HSD = q* × √(MS_W / n) |
| Homoscedasticity | Equal population variances across all groups — a key ANOVA assumption tested with Levene's test | σ₁² = σ₂² = … = σₖ² |
| Sphericity | Assumption in repeated measures ANOVA: the variances of the differences between all pairs of time points are equal | Tested with Mauchly's test |
| Interaction (A×B) | In two-way ANOVA, the effect of Factor A changes depending on the level of Factor B | SS_Interaction = SS_Cells − SS_A − SS_B |
Frequently Asked Questions
ANOVA (Analysis of Variance) is a statistical test that compares the means of three or more groups simultaneously. Use it when you have one continuous dependent variable and one or more categorical independent variables, and you want to know whether the groups differ on that outcome. You need at least three groups — for exactly two groups, use an independent samples t-test instead. ANOVA controls the family-wise error rate, which is why it is preferred over running multiple t-tests when more than two groups are involved.
The F statistic is the ratio of between-group variance to within-group variance: F = MS_Between / MS_Within. When all group means are equal (H₀ is true), F is expected to be close to 1, because both the numerator and denominator estimate the same population variance. When groups differ (H₀ is false), MS_Between inflates while MS_Within stays the same, pushing F above 1. The larger F is, the more evidence against H₀. The p-value is the probability of observing an F this large or larger if H₀ were true, calculated from the F-distribution with (k−1) and (N−k) degrees of freedom. Use the F-table for critical values.
ANOVA requires four conditions: (1) Independence — each observation must be independent of all others; if the same subjects appear in multiple groups, use repeated measures ANOVA. (2) Normality — scores within each group should follow an approximately normal distribution; check with a Shapiro-Wilk test or Q-Q plots. ANOVA is fairly robust to this when groups are equal in size. (3) Homogeneity of variance — all groups should have similar population variances; test with Levene's test (if p < 0.05, use Welch ANOVA). (4) Random sampling — data should come from random samples. See the assumptions testing guide.
One-way ANOVA has a single independent variable (one factor with three or more levels), for example, testing three fertilizer types on crop yield. Two-way ANOVA has two independent variables (two factors), for example, testing both fertilizer type and irrigation level on crop yield simultaneously. Two-way ANOVA is more efficient — it tests main effects for both factors and their interaction in a single analysis. The interaction tests whether the effect of one factor changes depending on the level of the other, which is often the most scientifically important finding.
A significant ANOVA (F significant, p < α) tells you that at least one group mean differs, but not which pairs of groups are responsible. You run post hoc tests to find out. For equal sample sizes and all pairwise comparisons, Tukey HSD is the standard choice — it compares all pairs while holding the family-wise error rate at α. For a small number of pre-planned comparisons, Bonferroni correction (α' = α/m) is more appropriate and more conservative. For complex contrasts (comparing combinations of groups), use the Scheffé test. Always report effect size (η² or partial η²) alongside the result. See the detailed guide at Tukey HSD Test.
Repeated measures ANOVA is used when the same participants are measured at multiple time points or under multiple conditions. Because each person serves as their own control, the analysis removes individual differences from the error term — making the test substantially more sensitive than a standard one-way ANOVA with different subjects in each condition. A key additional assumption is sphericity (equal variances of all pairwise differences between conditions), tested with Mauchly's test. If sphericity is violated, adjust the degrees of freedom using the Greenhouse-Geisser or Huynh-Feldt correction.
For one-way ANOVA: (1) Calculate each group mean and the grand mean. (2) SS_Between = Σ nⱼ(x̄ⱼ − x̄)² — weighted sum of squared deviations of group means from the grand mean. (3) SS_Within = ΣΣ(xᵢⱼ − x̄ⱼ)² — sum of squared deviations within each group. (4) SS_Total = SS_Between + SS_Within. (5) df_B = k−1, df_W = N−k. (6) MS_B = SS_B/df_B, MS_W = SS_W/df_W. (7) F = MS_B/MS_W. (8) Compare F to the critical value from the F-table with (k−1) and (N−k) df. The full calculation is shown step by step in Examples 1 and 2 above.
ANOVA and linear regression are mathematically equivalent when predictors are categorical — both are special cases of the General Linear Model. ANOVA compares group means using an F test; regression models the same data by coding groups as dummy variables. The key practical difference is emphasis: ANOVA focuses on group mean differences and variance decomposition; regression emphasizes the relationship between predictors and outcome, including the magnitude and direction of effects. When predictors are continuous, regression is the natural choice. When predictors are categorical (treatment groups), both methods give identical results. See the detailed comparison at ANOVA vs Regression.