Tutorials › VEE Mathematical Statistics › A Balanced One-Way ANOVA Calculation

VEE Mathematical Statistics · One-Way Analysis of Variance · Tutorial 802 of 880

A Balanced One-Way ANOVA Calculation

Learn to assemble and verify a complete balanced three-group ANOVA calculation, from the observations to the F statistic.

Intermediate 11 min read

What You'll Learn

  • Calculate each group mean and the overall grand mean from balanced raw data.
  • Find between-group, within-group and total sums of squares.
  • Determine the ANOVA degrees of freedom and mean squares.
  • Calculate the one-way ANOVA F statistic and check the partition of sums of squares.
  • Recognize how unequal group sizes or violated assumptions affect this calculation.

From Group Observations to an ANOVA Calculation

A one-way analysis of variance (ANOVA) compares the means of several groups using one test statistic. A balanced design has the same number of observations in each group. This makes the calculation especially direct: each group mean receives the same weight in the grand mean, and the between-group sum of squares is the common group size multiplied by the squared deviations of the group means from the grand mean.

The calculation does not replace the model assumptions. The observations should come from independent sampling units, the errors within each group should be approximately normal for the exact small-sample F test, and the groups should have a common error variance. ANOVA tests whether the group means are all equal; a significant result does not by itself identify which means differ.

Definition: In a balanced one-way ANOVA with \(k\) groups and \(n\) observations per group, write the observation in group \(i\), position \(j\) as \(y_{ij}\), where \(i=1,\ldots,k\) and \(j=1,\ldots,n\). The total sample size is \(N=kn\). The group mean is \(\bar{y}_{i\cdot}=\frac{1}{n}\sum_{j=1}^n y_{ij}\), and the grand mean is \(\bar{y}_{\cdot\cdot}=\frac{1}{N}\sum_{i=1}^k\sum_{j=1}^n y_{ij}\).

The fixed-effects model writes an observation as \(Y_{ij}=\mu+\tau_i+\varepsilon_{ij}\), where \(\mu\) is an overall level, \(\tau_i\) is the effect of group \(i\), and the errors \(\varepsilon_{ij}\) are independent with distribution \(N(0,\sigma^2)\). The usual constraint \(\sum_{i=1}^k\tau_i=0\) identifies the overall level and the group effects. The null hypothesis is \(H_0:\mu_1=\cdots=\mu_k\), where \(\mu_i=E[Y_{ij}]\) is the mean of group \(i\). The alternative is that at least one group mean differs.

The Sums of Squares and the F Statistic

The total variability around the grand mean is divided into variability between the group means and variability among observations within their own groups. For a balanced design, the calculations are:

$$ SS_{\text{total}}=\sum_{i=1}^k\sum_{j=1}^n(y_{ij}-\bar{y}_{\cdot\cdot})^2,\qquad SS_{\text{between}}=n\sum_{i=1}^k(\bar{y}_{i\cdot}-\bar{y}_{\cdot\cdot})^2,\qquad SS_{\text{within}}=\sum_{i=1}^k\sum_{j=1}^n(y_{ij}-\bar{y}_{i\cdot})^2. $$

The multiplier \(n\) in \(SS_{\text{between}}\) matters: every group mean represents \(n\) observations. The degrees of freedom are \(k-1\) between groups, \(N-k\) within groups, and \(N-1\) total. Divide each sum of squares by its degrees of freedom to obtain its mean square. The test statistic is the between-groups mean square divided by the within-groups mean square.

$$ MS_{\text{between}}=\frac{SS_{\text{between}}}{k-1},\qquad MS_{\text{within}}=\frac{SS_{\text{within}}}{N-k},\qquad F=\frac{MS_{\text{between}}}{MS_{\text{within}}}. $$

Under \(H_0\) and the model assumptions, this statistic has an \(F\) distribution with \(k-1\) numerator degrees of freedom and \(N-k\) denominator degrees of freedom. The earlier material on F critical values and ANOVA p-values explains how to use that reference distribution for a decision. Here the emphasis is on obtaining the statistic correctly.

Why the sums of squares partition: For every observation, write \(y_{ij}-\bar{y}_{\cdot\cdot}=(y_{ij}-\bar{y}_{i\cdot})+(\bar{y}_{i\cdot}-\bar{y}_{\cdot\cdot})\), then square and sum. The cross-product term is zero because, within each group, \(\sum_{j=1}^n(y_{ij}-\bar{y}_{i\cdot})=0\). The remaining terms give \(SS_{\text{total}}=SS_{\text{within}}+SS_{\text{between}}\). Also, the between-group term repeats each group-mean deviation \(n\) times, giving the factor \(n\) in \(SS_{\text{between}}\).
1
Calculate the means.
Find every group mean and the grand mean. In a balanced design, the grand mean is also the ordinary average of the group means.
2
Calculate the sums of squares.
Measure group-mean deviations for \(SS_{\text{between}}\), individual deviations from group means for \(SS_{\text{within}}\), and check that they add to \(SS_{\text{total}}\).
3
Complete the F calculation.
Use the correct degrees of freedom, calculate both mean squares, and divide \(MS_{\text{between}}\) by \(MS_{\text{within}}\).

Worked Calculations

Worked Example: A Balanced Design With Three Observations per Group

A hypothetical materials laboratory measures a strength score for three processing methods. The observations are Method A: 4, 5, 6; Method B: 6, 7, 8; Method C: 8, 9, 10. Calculate the complete one-way ANOVA quantities. Assume the independent-observation, normal-error and common-variance conditions are appropriate for the test.

Method and group means. Each group has \(n=3\) observations, so \(N=9\) and \(k=3\). The means are \(\bar{y}_{A\cdot}=(4+5+6)/3=5\), \(\bar{y}_{B\cdot}=(6+7+8)/3=7\), and \(\bar{y}_{C\cdot}=(8+9+10)/3=9\). The grand mean is \((4+5+6+6+7+8+8+9+10)/9=63/9=7\).

Between-group sum of squares. The group means are 2, 0 and 2 units from the grand mean, with the first deviation negative. Thus \(SS_{\text{between}}=3[(-2)^2+0^2+2^2]=3(4+0+4)=24\).

Within-group sum of squares. For each group, deviations from its own mean are \(-1,0,1\), so each group contributes \(1+0+1=2\). Therefore \(SS_{\text{within}}=2+2+2=6\). The total is \(SS_{\text{total}}=24+6=30\).

Degrees of freedom and F. Between groups, \(df=3-1=2\); within groups, \(df=9-3=6\); total, \(df=9-1=8\). These add correctly: \(2+6=8\). Hence \(MS_{\text{between}}=24/2=12\), \(MS_{\text{within}}=6/6=1\), and \(F=12/1=12\).

Check and trap avoided. The partition \(24+6=30\) agrees with the total sum of squares. Omitting the multiplier \(n=3\) from the between-group calculation would give 8 instead of 24 and would incorrectly shrink the F statistic.

Worked Example: Unequal Spacing Between Group Means

A hypothetical analyst compares the weekly number of processing delays under three balanced scheduling plans. The recorded counts are Plan A: 2, 4; Plan B: 5, 7; Plan C: 6, 10. Calculate the sums of squares, degrees of freedom, mean squares and F statistic. Treat the observations as independent and use the one-way equal-variance model.

Means. Here \(n=2\), \(k=3\), and \(N=6\). The group means are \((2+4)/2=3\), \((5+7)/2=6\), and \((6+10)/2=8\). The grand mean is \((6+12+16)/6=34/6=17/3\).

Between-group sum of squares. The deviations of the means from \(17/3\) are \(-8/3\), \(1/3\), and \(7/3\). Therefore \(SS_{\text{between}}=2[(64/9)+(1/9)+(49/9)]=2(114/9)=76/3\).

Within-group sum of squares. Plan A contributes \((2-3)^2+(4-3)^2=1+1=2\). Plan B contributes \((5-6)^2+(7-6)^2=1+1=2\). Plan C contributes \((6-8)^2+(10-8)^2=4+4=8\). Thus \(SS_{\text{within}}=2+2+8=12\), and \(SS_{\text{total}}=76/3+12=112/3\).

Degrees of freedom and F. The degrees of freedom are \(2\) between groups, \(6-3=3\) within groups, and \(5\) total. The check \(2+3=5\) holds. The mean squares are \(MS_{\text{between}}=(76/3)/2=38/3\) and \(MS_{\text{within}}=12/3=4\). Consequently \(F=(38/3)/4=19/6\), or approximately \(3.167\) to three decimal places.

Check and trap avoided. The sums of squares partition because \(76/3+12=112/3\). In Plan C, both squared deviations are 4; recording one of them as 8 would misstate that group's contribution. The F ratio uses the two mean squares, not the two raw sums of squares.

Worked Example: Verifying the Total From Raw Observations

A hypothetical reliability team compares three balanced inspection protocols using a score from 0 to 20. The scores are Protocol A: 10, 12, 11, 11; Protocol B: 12, 14, 13, 13; Protocol C: 14, 16, 15, 15. Calculate the ANOVA quantities and verify the total sum of squares directly from the observations.

Means. There are \(n=4\) scores per group, \(k=3\), and \(N=12\). The group means are \(44/4=11\), \(52/4=13\), and \(60/4=15\). The grand mean is \((44+52+60)/12=156/12=13\).

Between- and within-group sums of squares. The means differ from 13 by \(-2,0,2\), so \(SS_{\text{between}}=4[(-2)^2+0^2+2^2]=4(8)=32\). In each group, the deviations from its mean are \(-1,1,0,0\), whose squared values sum to 2. Thus \(SS_{\text{within}}=2+2+2=6\), and the partition gives \(SS_{\text{total}}=32+6=38\).

Direct total check. The squared deviations from the grand mean 13 sum to 14 for Protocol A: \(9+1+4+4=18\)—wait, evaluating these terms gives 18, so the direct check requires care. In fact the Protocol A deviations are \(-3,-1,-2,-2\), and their squares sum to \(9+1+4+4=18\). Protocol B's deviations are \(-1,1,0,0\), contributing 2, and Protocol C's are \(1,3,2,2\), contributing 18. Therefore the total is \(18+2+18=38\), agreeing with the partition.

Degrees of freedom and F. The degrees of freedom are \(k-1=2\), \(N-k=9\), and \(N-1=11\), with \(2+9=11\). The mean squares are \(32/2=16\) and \(6/9=2/3\). Hence \(F=16/(2/3)=24\).

Check and trap avoided. The direct calculation confirms the partition. A useful safeguard is to write the deviations from the grand mean explicitly: observations can be close to their own group mean but still far from the grand mean when their group mean is displaced.

Interpreting and Checking the Calculation

A balanced calculation is complete only when its components agree. Check that the group sizes are equal, the grand mean is based on all observations, the degrees of freedom sum to \(N-1\), and the sums of squares satisfy \(SS_{\text{total}}=SS_{\text{between}}+SS_{\text{within}}\). Then verify that the F ratio uses mean squares in the order between over within.

A large F statistic means the observed separation among group means is large relative to the within-group variation. It is evidence against equal means only when assessed against the appropriate \(F\) reference distribution and when the sampling design and model assumptions are defensible. It is not a measure of which groups differ, nor does a significant omnibus test establish that every group mean is different from every other one.

Common exam trap: Do not calculate \(SS_{\text{between}}\) as merely the sum of the squared deviations of the group means. In a balanced design, multiply that sum by \(n\), the number of observations represented by each mean. Also do not use \(k\) rather than \(k-1\) for the between-groups degrees of freedom, or divide either sum of squares by the wrong degrees of freedom.

The equal-size formulas here rely on the balanced design. If group sizes differ, the grand mean remains the mean of all observations, but it is generally not the unweighted mean of the group means, and the between-groups calculation must account for each group's size. The balanced formulas should not be carried over unchanged to that setting.

Check Your Understanding

For each balanced three-group data set, calculate the requested ANOVA quantities and check the sums-of-squares and degrees-of-freedom totals.

  1. Groups A, B and C each have two observations: A: 2, 4; B: 4, 6; C: 6, 8. Find the group means, grand mean, sums of squares, degrees of freedom and F statistic. (Answer: group means 3, 5, 7; grand mean 5; \(SS_{\text{between}}=16\), \(SS_{\text{within}}=6\), \(SS_{\text{total}}=22\); degrees of freedom 2, 3, 5; \(F=4\).)
  2. Groups A, B and C each have three observations: A: 1, 2, 3; B: 2, 3, 4; C: 4, 5, 6. Find all three sums of squares and the F statistic. (Answer: grand mean \(10/3\); \(SS_{\text{between}}=14\), \(SS_{\text{within}}=6\), \(SS_{\text{total}}=20\); degrees of freedom 2, 6, 8; \(F=7\).)
  3. Groups A, B and C each have two observations: A: 4, 8; B: 5, 9; C: 8, 12. Find the means, sums of squares and F statistic. (Answer: group means 6, 7, 10; grand mean \(23/3\); \(SS_{\text{between}}=52/3\), \(SS_{\text{within}}=24\), \(SS_{\text{total}}=124/3\); degrees of freedom 2, 3, 5; \(F=13/12\), approximately 1.0833.)
  4. Groups A, B and C each have four observations: A: 9, 10, 11, 10; B: 10, 11, 12, 11; C: 12, 13, 14, 13. Calculate the sums of squares, mean squares and F statistic. (Answer: grand mean \(34/3\); \(SS_{\text{between}}=56/3\), \(SS_{\text{within}}=6\), \(SS_{\text{total}}=74/3\); degrees of freedom 2, 9, 11; mean squares \(28/3\) and \(2/3\); \(F=14\).)
  5. Groups A, B and C each have three observations: A: 0, 1, 2; B: 2, 3, 4; C: 4, 5, 6. Find the grand mean, sums of squares and F statistic, then state whether the degrees of freedom sum to the total degrees of freedom. (Answer: grand mean 3; \(SS_{\text{between}}=24\), \(SS_{\text{within}}=6\), \(SS_{\text{total}}=30\); degrees of freedom 2, 6, 8, with \(2+6=8\); \(F=12\).)
Clinical Biostats