Why Work Through the Calculation?
A one-way ANOVA organizes a comparison of several population means into a small set of linked calculations. The final \(F\) statistic is a ratio of two mean squares, but those mean squares come from separating the observed variation into variation between groups and variation within groups. Working from raw data makes that structure visible and helps catch arithmetic errors before they reach the final statistic.
This tutorial focuses on a balanced design: every group contributes the same number of observations. We will calculate the group means, grand mean, sums of squares, degrees of freedom, mean squares, and \(F\) statistic. The calculations alone do not establish whether the observed \(F\) is statistically significant; that requires evaluating it using an appropriate reference distribution.
Model and Calculation Plan
Suppose a quantitative outcome is measured in \(k\) groups, with \(n\) observations in each group. The total sample size is \(N=kn\). A standard one-way ANOVA model writes observation \(j\) in group \(i\) as \(X_{ij}=\mu_i+\varepsilon_{ij}\). The model assumes independent errors with mean zero, a common variance \(\sigma^2\), and normally distributed errors within each group. These assumptions describe the model behind the \(F\) procedure; the arithmetic below does not by itself verify them.
For each observation, compare its value with its own group mean to calculate within-group variation. Compare each group mean with the grand mean to calculate between-group variation. The ANOVA degrees of freedom and mean squares are then obtained from those sums of squares.
The factor \(n\) in the balanced-design formula for \(SS_{\text{between}}\) is important: each group mean represents \(n\) observations. The degrees of freedom are \(k-1\) for between groups, \(N-k\) for within groups, and \(N-1\) for the total. Divide each sum of squares by its degrees of freedom to obtain the corresponding mean square. The \(F\) statistic is \(MS_{\text{between}}/MS_{\text{within}}\).
Why the Balanced Between-Group Formula Works
The definition of between-group variation can be written as adding the squared distance from the grand mean for every observation after replacing each observation in a group by that group’s mean. Since group \(i\) contains \(n\) observations, its contribution is \(n(\bar{x}_i-\bar{x}_{..})^2\). Adding the \(k\) contributions gives the balanced formula.
This simplification relies on equal group sizes. In an unbalanced design, group means do not receive the same weight in the grand mean or in this calculation.
Worked Calculations
Worked Example: Three Groups of Three Observations
In a hypothetical classroom exercise, three teaching approaches produce these quiz scores, all measured in points: Approach A: 4, 5, 6; Approach B: 6, 7, 8; Approach C: 8, 9, 10. Each group has \(n=3\), so the design is balanced, with \(k=3\) and \(N=9\).
Group means and grand mean. The group means are \(\bar{x}_A=(4+5+6)/3=5\), \(\bar{x}_B=(6+7+8)/3=7\), and \(\bar{x}_C=(8+9+10)/3=9\). The grand mean is \(\bar{x}_{..}=(4+5+6+6+7+8+8+9+10)/9=63/9=7\). As a balanced-design check, the average of the group means is \((5+7+9)/3=7\).
Between-group sum of squares. The group means differ from the grand mean by \(-2\), \(0\), and \(2\): \(SS_{\text{between}}=3[(-2)^2+0^2+2^2]=3(8)=24\) points squared.
Within-group sum of squares. For A, the squared deviations from 5 sum to \((4-5)^2+(5-5)^2+(6-5)^2=2\). The corresponding sums for B and C are each 2. Thus \(SS_{\text{within}}=2+2+2=6\) points squared. The total is \(SS_{\text{total}}=24+6=30\); calculating the nine squared deviations from the grand mean also gives \(30\).
Degrees of freedom and mean squares. The between-groups degrees of freedom are \(k-1=3-1=2\); the within-groups degrees of freedom are \(N-k=9-3=6\); the total degrees of freedom are \(N-1=8\). Therefore, \(MS_{\text{between}}=24/2=12\) and \(MS_{\text{within}}=6/6=1\).
F statistic. \(F=MS_{\text{between}}/MS_{\text{within}}=12/1=12\). The calculation is complete: the observed between-group mean square is 12 times the within-group mean square.
| Source | Sum of squares | Degrees of freedom | Mean square | F |
|---|---|---|---|---|
| Between groups | 24 | 2 | 12 | 12 |
| Within groups | 6 | 6 | 1 | |
| Total | 30 | 8 |
Worked Example: Unequal Group Means and a Fractional Grand Mean
Suppose a hypothetical lab exercise records a response in arbitrary units for three equally sized groups: Group A: 10, 12, 11, 13; Group B: 13, 15, 14, 14; Group C: 16, 15, 17, 16. Each group has four observations, so \(k=3\), \(n=4\), and \(N=12\).
Means. The group means are \(\bar{x}_A=46/4=11.5\), \(\bar{x}_B=56/4=14\), and \(\bar{x}_C=64/4=16\). The grand mean is \(\bar{x}_{..}=166/12=13.8333\) units. The mean of the group means is \((11.5+14+16)/3=13.8333\), agreeing with the grand mean.
Between-group sum of squares. Using the balanced formula, \(SS_{\text{between}}=4[(11.5-13.8333)^2+(14-13.8333)^2+(16-13.8333)^2]\). Using the exact grand mean \(83/6\), the deviations are \(-14/6\), \(1/6\), and \(13/6\), so the calculation is \(4[(196+1+169)/36]=4(366/36)=40.6667\) units squared.
Within-group sum of squares. For A, the mean is 11.5, so the squared deviations sum to \(2.25+0.25+0.25+2.25=5\). For B, the deviations from 14 are \(-1,1,0,0\), giving a sum of 2. For C, the deviations from 16 are \(0,-1,1,0\), also giving 2. Therefore, \(SS_{\text{within}}=5+2+2=9\) units squared, and \(SS_{\text{total}}=40.6667+9=49.6667\) units squared.
Degrees of freedom, mean squares, and \(F\). The degrees of freedom are \(2\) between groups, \(12-3=9\) within groups, and \(11\) total. The mean squares are \(MS_{\text{between}}=40.6667/2=20.3333\) and \(MS_{\text{within}}=9/9=1\). Thus \(F=20.3333/1=20.3333\). Rounding to three significant figures, the observed \(F\) statistic is 20.3.
Worked Example: Four Groups and a Table Check
Consider hypothetical measurements in four balanced groups: A: 2, 3, 4; B: 4, 5, 6; C: 6, 7, 8; D: 8, 9, 10. The measurements are in millimeters. Here \(k=4\), \(n=3\), and \(N=12\).
Means. The group means are 3, 5, 7, and 9 mm. The grand mean is the total, 60 mm, divided by 12, giving \(\bar{x}_{..}=5\) mm. The average of the group means is also \((3+5+7+9)/4=6\) mm—not 5 mm. This signals an inconsistency, so check the data totals: the four group totals are 9, 15, 21, and 27, for a grand total of 72, not 60. Therefore the correct grand mean is \(72/12=6\) mm, which agrees with the average of group means.
Sums of squares. The group means differ from 6 by \(-3,-1,1,3\). Hence \(SS_{\text{between}}=3(9+1+1+9)=60\) mm squared. Each group has within-group squared deviations \(2\), so \(SS_{\text{within}}=8\) mm squared. Therefore \(SS_{\text{total}}=68\) mm squared. As a direct check, summing squared deviations from 6 across the four groups gives \(29+5+5+29=68\).
Degrees of freedom and \(F\). Between-groups degrees of freedom are \(4-1=3\), within-groups degrees of freedom are \(12-4=8\), and total degrees of freedom are \(11\). Thus \(MS_{\text{between}}=60/3=20\), \(MS_{\text{within}}=8/8=1\), and \(F=20/1=20\).
| Source | Sum of squares | Degrees of freedom | Mean square | F |
|---|---|---|---|---|
| Between groups | 60 | 3 | 20 | 20 |
| Within groups | 8 | 8 | 1 | |
| Total | 68 | 11 |
Reading the Calculation Carefully
An ANOVA table is a compact record of a sequence, not a collection of unrelated entries. The degrees of freedom tell how each sum of squares is scaled into a mean square. The \(F\) statistic then compares the between-groups mean square with the within-groups mean square. A larger ratio means that group-to-group variation is larger relative to the variation among observations within groups. Whether a particular ratio is sufficiently large to reject \(H_0\) depends on the \(F\) distribution and the test’s significance level.
The variation decomposition \(SS_{\text{total}}=SS_{\text{between}}+SS_{\text{within}}\) is a useful arithmetic check. Degrees of freedom should also add: \((k-1)+(N-k)=N-1\). If either check fails, revisit the means and squared deviations before proceeding. Keep units in mind: sums of squares and mean squares have squared outcome units, while \(F\), a ratio of two mean squares, has no units.
Common Mistake
A frequent mistake is to calculate the between-group sum of squares as just \(\sum(\bar{x}_i-\bar{x}_{..})^2\), omitting the factor \(n\). That treats each group mean as if it represented one observation. In a balanced design, each mean represents \(n\) observations, so the correct expression is \(n\sum(\bar{x}_i-\bar{x}_{..})^2\). Another useful check is to calculate the grand mean from all observations and compare it with the average group mean; they must agree in a balanced design. A mismatch often reveals an addition error, as the four-group example illustrates.
Check Your Understanding
Use the balanced-design formulas and show the arithmetic for each calculation.
- Three groups each contain five observations. What are \(N\), the between-groups degrees of freedom, the within-groups degrees of freedom, and the total degrees of freedom?
- In a balanced design with \(n=4\), the group means are 8, 10, and 13, and the grand mean is 10. Find \(SS_{\text{between}}\).
- For one group, the observations are 3, 5, and 7. Calculate its contribution to \(SS_{\text{within}}\).
- An ANOVA calculation gives \(MS_{\text{between}}=18\) and \(MS_{\text{within}}=3\). Find \(F\), and state what this ratio compares.
- Why must the average of the group means equal the grand mean in a balanced design?