Tutorials › Introduction to Statistics › Mean Squares as Variance Estimates

One-Way ANOVA · Tutorial 855 of 996

Mean Squares as Variance Estimates

Calculate the two ANOVA mean squares and understand why the within-group mean square estimates the common variance of observations around their group means.

Intermediate 11 min read

What You'll Learn

  • Calculate between-group and within-group mean squares from sums of squares and degrees of freedom
  • Distinguish the role of each mean square in a one-way ANOVA
  • Explain the assumptions under which the within-group mean square estimates common error variance
  • Derive why dividing within-group sum of squares by its degrees of freedom gives an unbiased variance estimate
  • Interpret the units and avoid common errors when comparing sums of squares

From Sums of Squares to Mean Squares

In a one-way ANOVA, the total variation in a quantitative response is separated into variation between groups and variation within groups. The sums of squares summarize these two sources of variation, but they do not have the same degrees of freedom. A mean square puts each sum of squares on a per-degree-of-freedom scale.

This tutorial focuses on calculating those mean squares and understanding their roles. In particular, the within-group mean square is a pooled estimate of the common variance of observations around their group means. The between-group mean square also summarizes variation, but it is not generally an estimate of that same error variance when group means differ.

Definition: In a one-way ANOVA with \(k\) groups and \(N\) total observations, the between-group mean square is \(MS_B=SS_B/(k-1)\), and the within-group mean square is \(MS_W=SS_W/(N-k)\). Here, \(SS_B\) and \(SS_W\) are the between-group and within-group sums of squares, respectively; \(k-1\) and \(N-k\) are their corresponding degrees of freedom.

Both sums of squares have units equal to the response units squared. Dividing by degrees of freedom does not change those units, so each mean square is also measured in squared response units. For example, if the response is a concentration measured in milligrams per liter, both mean squares are in \((\text{mg/L})^2\).

What Each Mean Square Summarizes

Let \(n_i\) be the number of observations in group \(i\), \(\bar{x}_i\) its sample mean, and \(\bar{x}\) the grand mean across all \(N\) observations. The between-group sum of squares weights each group mean's squared distance from the grand mean by that group's size:

$$ SS_B=\sum_{i=1}^{k} n_i(\bar{x}_i-\bar{x})^2 $$

Thus \(MS_B=SS_B/(k-1)\) summarizes between-group variation per between-group degree of freedom. It reflects how far the group means are spread around the grand mean. Its value can be influenced by genuine differences among the group means as well as by sampling variation.

The within-group sum of squares adds the squared distances of individual observations from their own group means:

$$ SS_W=\sum_{i=1}^{k}\sum_{j=1}^{n_i}(x_{ij}-\bar{x}_i)^2 $$

The within-group mean square, \(MS_W=SS_W/(N-k)\), pools the information about variation around group means across all groups. Under the common-variance model described below, it estimates the shared error variance, \(\sigma^2\).

Worked Example: Calculating Both Mean Squares

Suppose a hypothetical experiment records a response in units for three groups, with observations \(4,5,6\) in Group A; \(6,7,8\) in Group B; and \(8,9,10\) in Group C. Calculate both mean squares.

Each group has \(n_i=3\), and the group means are \(5\), \(7\), and \(9\). The grand mean is \(\bar{x}=(4+5+6+6+7+8+8+9+10)/9=7\). The between-group sum of squares is

$$ SS_B=3(5-7)^2+3(7-7)^2+3(9-7)^2=12+0+12=24 $$

There are \(k-1=3-1=2\) between-group degrees of freedom, so \(MS_B=24/2=12\) response-units squared.

Within each group, the deviations from that group's mean are \(-1,0,1\), whose squared values sum to \(2\). Thus \(SS_W=2+2+2=6\). The total sample size is \(N=9\), giving \(N-k=9-3=6\) within-group degrees of freedom. Therefore, \(MS_W=6/6=1\) response-units squared.

The two calculated quantities summarize different sources of variation. The between-group mean square is \(12\), and the within-group mean square is \(1\). The within-group value is the pooled estimate of common error variance when the model assumptions hold.

Why the Within-Group Mean Square Estimates Common Error Variance

To explain the variance-estimation result, use the one-way model \(X_{ij}=\mu_i+\varepsilon_{ij}\), where \(\mu_i\) is the population mean for group \(i\), and \(\varepsilon_{ij}\) is the deviation of observation \(j\) in group \(i\) from that group mean. Assume the errors are independent, have mean zero, and share a common finite variance \(\sigma^2\). In particular, this model gives each group the same error variance even though the group means \(\mu_i\) may differ.

Within a group, subtracting its sample mean removes the group mean \(\mu_i\). The within-group sum of squares therefore measures the errors' variation around their own group average. The following derivation shows why each group contributes, on average, one error-variance unit per within-group degree of freedom.

1
Center the observations within one group.
For a group of size \(n_i\), write \(\bar{\varepsilon}_i\) for its average error. Since \(X_{ij}=\mu_i+\varepsilon_{ij}\) and \(\bar{x}_i=\mu_i+\bar{\varepsilon}_i\), the residual \(X_{ij}-\bar{x}_i\) equals \(\varepsilon_{ij}-\bar{\varepsilon}_i\).
2
Rewrite the group's squared residuals.
Expanding and using \(\sum_j\varepsilon_{ij}=n_i\bar{\varepsilon}_i\) gives \(\sum_j(\varepsilon_{ij}-\bar{\varepsilon}_i)^2=\sum_j\varepsilon_{ij}^2-n_i\bar{\varepsilon}_i^2\).
3
Take expectations.
Each error has mean zero and variance \(\sigma^2\), so \(E(\sum_j\varepsilon_{ij}^2)=n_i\sigma^2\). Independence gives \(Var(\bar{\varepsilon}_i)=\sigma^2/n_i\), and its mean is zero, so \(E(n_i\bar{\varepsilon}_i^2)=n_i(\sigma^2/n_i)=\sigma^2\). Thus the expected within-group sum of squares is \((n_i-1)\sigma^2\).
4
Add the groups and divide by degrees of freedom.
Adding the group expectations gives \(E(SS_W)=\sum_i(n_i-1)\sigma^2=(N-k)\sigma^2\). Consequently, \(E(MS_W)=E(SS_W/(N-k))=\sigma^2\).

This establishes that \(MS_W\) is an unbiased estimator of the common error variance under the stated model: across repeated samples under that model, its average value is \(\sigma^2\). It does not mean that every calculated \(MS_W\) equals \(\sigma^2\); a particular sample estimate will generally differ from the population value. Normality is not needed for this expectation calculation, although it is used for some exact results in ANOVA inference.

Worked Example: Pooling Within-Group Variation

In a hypothetical measurement exercise, three groups have observations \(1,3\); \(2,4,6\); and \(3,5,7,9\). Calculate the pooled within-group mean square and compare it with the separate sample variances.

The group means are \(2\), \(4\), and \(6\). The within-group sums of squares are \(2\) for the first group, \(8\) for the second, and \(20\) for the third. For example, in the third group the squared deviations are \((-3)^2,(-1)^2,1^2,3^2\), which sum to \(20\). Therefore, \(SS_W=2+8+20=30\).

There are \(N=2+3+4=9\) observations in \(k=3\) groups. Hence \(df_W=N-k=9-3=6\), and

$$ MS_W=\frac{SS_W}{df_W}=\frac{30}{6}=5 $$

The separate sample variances are \(2/(2-1)=2\), \(8/(3-1)=4\), and \(20/(4-1)=6.667\), in squared response units. The pooled estimate is not their simple unweighted average. It weights each group variance by its degrees of freedom:

$$ MS_W=\frac{(1)(2)+(2)(4)+(3)(6.667)}{1+2+3} \approx\frac{30}{6}=5 $$

The pooling reflects how much within-group information each group supplies. Under the common-variance model, these group contributions estimate the same \(\sigma^2\); combining their sums of squares and degrees of freedom gives the overall estimate.

Unequal Group Sizes and Between-Group Mean Squares

The formulas do not require equal group sizes. For unequal groups, use each group's actual size in the between-group sum of squares, and use \(N-k\) for the within-group degrees of freedom. The total sample size is the sum of the group sizes, \(N=\sum_i n_i\).

Worked Example: Mean Squares With Unequal Group Sizes

Consider hypothetical observations \(10,12\) in Group A; \(13,14,15\) in Group B; and \(16,18,20,22\) in Group C. Calculate \(MS_B\) and \(MS_W\).

The group sizes are \(2,3,4\), and their means are \(11,14,19\). The grand mean is \(\bar{x}=140/9\approx15.56\), because the total of all nine observations is \(140\). The between-group sum of squares is

$$ SS_B=2(11-140/9)^2+3(14-140/9)^2+4(19-140/9)^2 \approx96.22 $$

With \(k=3\), the between-group degrees of freedom are \(2\), giving \(MS_B=96.22/2\approx48.11\) squared response units.

For the within-group sum of squares, Group A contributes \((10-11)^2+(12-11)^2=2\). Group B contributes \((13-14)^2+(14-14)^2+(15-14)^2=2\). Group C contributes \((16-19)^2+(18-19)^2+(20-19)^2+(22-19)^2=20\). Thus \(SS_W=2+2+20=24\). Since \(N=9\), \(df_W=N-k=9-3=6\), so \(MS_W=24/6=4\) squared response units.

The group sizes enter the between-group calculation as weights, while each group contributes its own residual squared deviations to \(SS_W\). Neither calculation should be replaced by treating all groups as though they had the same size.

Common Mistake: Assuming a Sum Must Rise With Its Degrees of Freedom

A tempting but incorrect explanation is: “Each sum of squares grows as its degrees of freedom grow, so the sums alone are misleading.” A realized sum of squares need not increase whenever its degrees of freedom increase. For observations \(0\) and \(2\), the mean is \(1\), and the sum of squared deviations is \((0-1)^2+(2-1)^2=2\), with one degree of freedom. Add an observation equal to the mean, \(1\). The sum of squares remains \(2\), but the degrees of freedom become two.

Under the model, sums of squares generally scale with their degrees of freedom, but that does not force every realized sum to increase as degrees of freedom increase. Dividing by degrees of freedom produces mean-square quantities on a per-degree-of-freedom scale. The division is especially important for \(MS_W\), because under the common-variance model its expected value is \(\sigma^2\).

A related interpretive error is to call both mean squares estimates of the same error variance. The within-group mean square estimates common error variance under the stated model. The between-group mean square summarizes variation among the group means per degree of freedom; because it can reflect differences among the population group means, it is not generally an estimate of only the common error variance.

Key takeaway: Compute \(MS_B\) as \(SS_B/(k-1)\) and \(MS_W\) as \(SS_W/(N-k)\). Under independent errors with mean zero and common finite variance \(\sigma^2\), the within-group mean square has expectation \(\sigma^2\), so it estimates the common error variance.

Check Your Understanding

Use the definitions and results above to answer the following questions.

  1. A one-way ANOVA has \(SS_B=36\), \(SS_W=48\), \(k=4\), and \(N=20\). Calculate both mean squares and state each one's degrees of freedom.
  2. Why does \(MS_W\) estimate common error variance under the one-way model? State the assumptions needed for the expectation result.
  3. A researcher says that a within-group sum of squares must increase whenever its degrees of freedom increase. Give a counterexample or explain why the claim is not guaranteed.
  4. In a study with unequal group sizes, why is the pooled within-group variance not generally the simple average of the groups' sample variances?
  5. If the response is measured in seconds, what are the units of \(SS_W\) and \(MS_W\)?