To calculate a one-way ANOVA by hand, you work out the variation between your groups and the variation within them, turn each into a mean square, and divide one by the other to get the F-ratio (F = MST / MSE). If that F value is larger than the F critical value from an F-distribution table, the group means differ significantly. The full step-by-step calculation — sums of squares, degrees of freedom, mean squares and the ANOVA table — is worked through below.
If you only need the concept and theory rather than the computation, see our companion guide, An Overview of the One-Way ANOVA. This article focuses specifically on how to calculate it. For the wider family of tests, read Everything You Need to Know About ANOVA.
Overview
What is ANOVA?
ANOVA is short for Analysis of Variance, a widely used hypothesis testing technique. In essence, the test tells you whether the differences between group averages in your data are large enough to be statistically significant, or whether they could plausibly have arisen by chance. It does this by comparing the variance between the groups with the variance within the groups.
The scope of ANOVA is significant in research because it helps to pinpoint how an independent variable affects a dependent variable. Based on the resulting F-ratio, you either reject the null hypothesis (all group means are equal) or fail to reject it.
ANOVA is categorised into two main types:
- One-way ANOVA — one independent variable (factor).
- Two-way ANOVA — two independent variables (factors).
This article concentrates on the calculation of one-way ANOVA.
“Analysis of variance (ANOVA) is a collection of statistical models… used to analyse the differences among group means in a sample.” The technique was developed by statistician Ronald Fisher, which is why the test statistic is named the F-ratio in his honour.— R. A. Fisher, Statistical Methods for Research Workers (1925)
One-Way ANOVA: Definition
A one-way ANOVA tests whether there is a statistically significant difference among the means of two or more independent groups, where the groups are defined by the levels of a single categorical independent variable.
One-way ANOVA is also called one-factor ANOVA, one-way analysis of variance, and between-subjects ANOVA. As the name suggests, it analyses the impact of one factor — a single independent variable — although that factor is split into multiple levels. For example, social media consumption is one independent variable that can be divided into low, medium and high levels.
One-way ANOVA is an omnibus test. This means it can tell you that the groups differ overall, but it does not tell you which specific groups differ from one another. If you have three, four, five or more groups, the test confirms only that a difference exists somewhere; identifying which pairs differ requires a post-hoc test (covered below).
The two variables a one-way ANOVA uses are:
- Dependent variable — the quantitative outcome being measured (e.g. test score, weight loss, running time). It changes in response to other factors.
- Independent variable — a single categorical factor with three or more levels (e.g. teaching method, diet type). It is manipulated or grouped, and its effect on the dependent variable is what the test evaluates.
To understand the difference between these variable types in more depth, see our guide to types of variables.
Assumptions of One-Way ANOVA
Before you trust the result of a one-way ANOVA, your data should satisfy four key assumptions:
- Normality — the dependent variable is approximately normally distributed within each group.
- Independence — each observation is independent of the others; samples are drawn independently.
- Homogeneity of variance — the groups have roughly equal variances (homoscedasticity). This is often checked with Levene’s test.
- Continuous dependent variable — the outcome is measured on an interval or ratio scale (see levels of measurement).
If the homogeneity-of-variance assumption is violated, a Welch’s ANOVA is a more robust alternative.
When to Use One-Way ANOVA
Use a one-way ANOVA when your data has:
- One categorical independent variable with three or more levels (groups).
- One quantitative dependent variable.
The independent variable needs multiple levels because comparing the means of only two groups is the job of an independent-samples t-test, not ANOVA. If you are unsure which procedure fits your design, our guide on which statistical test you should use walks through the decision.
The Difference Between One-Way and Two-Way ANOVA
The key difference is the number of independent variables (factors). A one-way ANOVA examines the effect of a single categorical factor on a continuous outcome and simply tells you whether the group means differ significantly. A two-way ANOVA examines two factors at once and can additionally test whether the two factors interact — that is, whether the effect of one depends on the level of the other.
| Feature | One-Way ANOVA | Two-Way ANOVA |
|---|---|---|
| Independent variables | One | Two |
| Tests interaction? | No | Yes |
| Dependent variable | One (continuous) | One (continuous) |
| Minimum groups/levels | 3 levels of one factor | 2 levels of each factor |
| Typical use | Do diets A/B/C differ? | Do diet and exercise (and their combination) differ? |
For a full treatment of the two-factor case, read our beginner’s guide on two-way ANOVA. To compare every variant side by side, see Everything You Need to Know About ANOVA.
Is the Statistics assignment pressure too much to handle?
How about we handle it for you?
Put in the order right now in order to save yourself time, money, and nerves at the last minute.
How to Calculate One-Way ANOVA (Step-by-Step Worked Example)
The one-way ANOVA test statistic is the F-ratio, defined as:
MST = mean square for treatment (variation between groups) = SSR / dftreatment
MSE = mean square for error (variation within groups) = SSE / dferror
Key terms:
- F — the overall variance ratio (the test statistic).
- SSR (between-groups sum of squares) — variation of group means around the grand mean.
- SSE (within-groups / error sum of squares) — variation of observations around their own group mean.
- SST (total sum of squares) — total variation, where SST = SSR + SSE.
- df — degrees of freedom.
The calculation has five clear steps. We will work through them using four groups in a class (Red, Blue, Green, Yellow), each with five students, who scored the following marks out of 10.
| Group | Scores | Group mean |
|---|---|---|
| Red | 9, 10, 8, 9, 9 | 9.0 |
| Blue | 7, 8, 6, 8, 9 | 7.6 |
| Green | 5, 6, 7, 7, 8 | 6.6 |
| Yellow | 10, 10, 9, 9, 10 | 9.6 |
Step 1: Calculate the group means and the grand (overall) mean.
The group means are Red = 9.0, Blue = 7.6, Green = 6.6 and Yellow = 9.6. The grand mean is the average of all 20 observations:
Grand mean = (45 + 38 + 33 + 48) / 20 = 164 / 20 = 8.2
Step 2: Calculate the between-groups sum of squares (SSR).
Use SSR = Σ nj(X̄j − X̄)2, where nj is the size of group j, X̄j is the group mean and X̄ is the grand mean:
= 5(9.0−8.2)2 + 5(7.6−8.2)2 + 5(6.6−8.2)2 + 5(9.6−8.2)2
= 5(0.8)2 + 5(−0.6)2 + 5(−1.6)2 + 5(1.4)2
= 5(0.64) + 5(0.36) + 5(2.56) + 5(1.96)
= 3.2 + 1.8 + 12.8 + 9.8
SSR = 27.6
Step 3: Calculate the within-groups (error) sum of squares (SSE).
Use SSE = Σ (Xij − X̄j)2, the squared deviation of each observation from its own group mean:
- Red: (9−9)2+(10−9)2+(8−9)2+(9−9)2+(9−9)2 = 2.0
- Blue: (7−7.6)2+(8−7.6)2+(6−7.6)2+(8−7.6)2+(9−7.6)2 = 5.2
- Green: (5−6.6)2+(6−6.6)2+(7−6.6)2+(7−6.6)2+(8−6.6)2 = 5.2
- Yellow: (10−9.6)2+(10−9.6)2+(9−9.6)2+(9−9.6)2+(10−9.6)2 = 1.2
SSE = 2.0 + 5.2 + 5.2 + 1.2
SSE = 13.6
Step 4: Calculate the total sum of squares (SST).
SST = SSR + SSE = 27.6 + 13.6 = 41.2
Step 5: Compute degrees of freedom, mean squares and F, then fill in the ANOVA table.
With k = 4 groups and n = 20 observations:
- dftreatment = k − 1 = 4 − 1 = 3
- dferror = n − k = 20 − 4 = 16
- dftotal = n − 1 = 19
- MST = SSR / dftreatment = 27.6 / 3 = 9.2
- MSE = SSE / dferror = 13.6 / 16 = 0.85
- F = MST / MSE = 9.2 / 0.85 ≈ 10.82
| Source | Sum of Squares | df | Mean Square | F |
|---|---|---|---|---|
| Treatment (between) | 27.6 | 3 | 9.20 | 10.82 |
| Error (within) | 13.6 | 16 | 0.85 | |
| Total | 41.2 | 19 |
ANOVA partitions total variance
- Variation due to the treatment / factor
- Random error inside each group
Interpreting the result: the calculated F statistic is 10.82. We compare it with the F critical value for df (3, 16) at the 0.05 significance level, which is 3.24 according to an F-distribution table. Because 10.82 > 3.24, we reject the null hypothesis and conclude that there is a statistically significant difference between the group means.
Post-Hoc Tests: Finding Out Which Groups Differ
Because one-way ANOVA is an omnibus test, a significant F only confirms that at least one group mean differs — it does not say which. To pinpoint the specific pairs that differ, you run a post-hoc test after a significant ANOVA. Common choices include:
- Tukey’s HSD (Honestly Significant Difference) — the most popular all-pairs comparison, controlling the family-wise error rate.
- Bonferroni correction — a conservative adjustment that divides the significance threshold by the number of comparisons.
- Scheffé’s test — flexible and very conservative, useful for complex comparisons.
In our worked example, a Tukey’s HSD test would reveal, for instance, whether the Green group (mean 6.6) differs significantly from the Yellow group (mean 9.6).
Struggling to run or interpret your ANOVA?
ResearchProspect to the rescue!
Our experts can run, check and explain your test results — explore our statistical analysis service for one-to-one help with ANOVA and beyond.