Why Measure Variation Within Groups?
In one-way ANOVA, observations are sorted into groups, and each group has its own mean. Those means summarize differences in level between groups. But observations in the same group may also differ from one another. The within-group sum of squares measures this variation by comparing each observation with the mean of its own group.
For example, suppose a hypothetical experiment records a response in each of several treatment groups. Two groups might have different average responses, while the observations within either group may still be tightly clustered or widely spread. The within-group sum of squares captures the latter pattern. It is also commonly called the error sum of squares, often abbreviated \(SS_W\) or \(SSE\). Here, “error” means the deviations from group means; it does not necessarily mean that anyone made a mistake.
This is a descriptive calculation. To calculate \(SS_W\), the observations need to be assigned to the correct groups and measured on the same quantitative outcome scale. No normality or equal-variance assumption is needed for the arithmetic itself. Such assumptions matter for inferential procedures built from the sums of squares, not for defining or calculating this quantity.
Calculating the Sum Directly
A reliable direct calculation has two stages. First find each group mean. Then, within each group, subtract that mean from every observation, square each difference, and add the squares. Only after doing this separately for every group do you combine the group sums. A deviation is always measured from the mean of the observation’s own group.
Worked Example: Two Groups With Equal Sizes
In a hypothetical classroom activity, students in two groups receive different practice formats. Their quiz responses, measured in points, are recorded as follows: Group A has scores 4, 6, and 8; Group B has scores 3, 5, and 7. Calculate the within-group sum of squares.
For Group A, the mean is \(\bar{x}_A=(4+6+8)/3=6\) points. Its squared deviations are \((4-6)^2=4\), \((6-6)^2=0\), and \((8-6)^2=4\), so its within-group sum is \(4+0+4=8\) points squared.
For Group B, the mean is \(\bar{x}_B=(3+5+7)/3=5\) points. Its squared deviations are \((3-5)^2=4\), \((5-5)^2=0\), and \((7-5)^2=4\), giving a within-group sum of \(8\) points squared.
The value \(16\) is the total squared deviation of all six scores from their respective group means. It is not the sum of deviations: the positive and negative deviations would cancel if they were added without squaring.
Unequal Group Sizes
Groups do not need to contain the same number of observations. The formula uses each group’s own size \(n_i\), and each observed value contributes one squared deviation. Thus, a group with more observations can contribute more to \(SS_W\), although the size of its contribution also depends on how far its observations lie from its mean.
Worked Example: Groups With Different Numbers of Observations
A hypothetical laboratory compares measured concentrations in two groups. Group A has observations 10, 12, and 14 mg/L. Group B has observations 16 and 18 mg/L. Find \(SS_W\).
Group A has mean \((10+12+14)/3=12\) mg/L. Its squared deviations are \(0^2\), \(0^2\), and \(2^2\) when written with signs as \(-2,0,2\), so its sum of squared deviations is \(4+0+4=8\) \((\text{mg/L})^2\).
Group B has mean \((16+18)/2=17\) mg/L. Its deviations are \(-1\) and \(1\) mg/L, so its sum of squared deviations is \(1+1=2\) \((\text{mg/L})^2\).
The group sizes are three and two, but the group sums are simply added. The resulting \(SS_W\) describes the total within-group squared deviation for all five recorded concentrations.
A Useful Computational Identity
The definition is conceptually clear, but a second formula can make arithmetic faster or provide a check. For one group with observations \(x_1,\ldots,x_n\) and mean \(\bar{x}\), the sum of squared deviations can be calculated from the sum of the observations and the sum of their squares:
This identity is applied separately within each group. For group \(i\), use that group’s observations and its size \(n_i\), then add the resulting group sums. It is not a formula that centers all observations at one overall mean.
To justify the identity, expand each squared difference and use the fact that the mean is the sum divided by the number of observations:
The key substitution is \(\sum_{j=1}^{n}x_j=n\bar{x}\). The identity gives the same result as calculating and squaring every individual deviation, but may involve fewer intermediate differences. When possible, retain exact fractions during the calculation and round only the final result.
Worked Example: Checking a Group Sum With the Identity
A hypothetical group has three response values: 2, 4, and 7 units. Calculate its sum of squared deviations both directly and with the computational identity.
The mean is \((2+4+7)/3=13/3\) units. The direct calculation is
For the identity, the sum of squares is \(2^2+4^2+7^2=69\), the sum is \(2+4+7=13\), and \(n=3\). Therefore,
Both calculations agree. Because there is only one group in this example, its group sum is also the total \(SS_W\) for these observations.
Interpreting the Result
The within-group sum of squares is a measure of total within-group variation around the group means. A value of zero means that every observation equals the mean of its own group. For example, if all the observations in a group are 12, every deviation from that group mean is zero. A larger sum indicates more total squared deviation, but its size depends both on the spread of observations and on how many observations are included.
The units are squared. If the outcome is measured in points, \(SS_W\) is in points squared; if it is measured in centimeters, the sum is in square centimeters. This is because each difference from a group mean is squared before summation. The quantity is therefore not itself an average deviation or a standard deviation. Those are different summaries.
The individual deviations from a group mean sum to zero within each group. Squaring before adding prevents positive and negative differences from canceling, and gives observations farther from their group mean more influence on the total. For example, a deviation of 4 contributes \(4^2=16\), while a deviation of 2 contributes only \(2^2=4\).
In one-way ANOVA, \(SS_W\) is one of the sums of squares used to describe variation in the data. Its role is to quantify variation that remains among observations after accounting for which group each observation belongs to. Calculating it correctly requires respecting the group boundaries: every observation is centered at its own group mean.
Common Mistakes
- Using the grand mean for every observation. This measures deviations from one overall center, not deviations within groups. For \(SS_W\), use \(\bar{x}_i\) for observations in group \(i\).
- Adding signed deviations instead of squared deviations. Within each group, signed deviations from the group mean sum to zero. Square each deviation before adding.
- Averaging the group sums when the formula calls for their total. \(SS_W\) is the sum of all squared deviations across groups, not the mean of the separate group sums.
- Ignoring squared units. State the outcome’s units squared, such as points squared, rather than reporting the result as though it were measured in points.
- Rounding every group mean too early. Use exact values or adequate precision for the means, because rounding intermediate calculations can change the final sum.
Check Your Understanding
Try these questions without looking back at the worked calculations.
- A group contains observations 5, 7, and 9. Find its mean and its sum of squared deviations.
- Why must an observation be compared with its own group mean when calculating \(SS_W\)?
- Two groups have within-group sums of 6 and 11. What is the overall \(SS_W\), and what units should it have if the outcome was measured in minutes?
- Explain why adding signed deviations from each group mean cannot produce the within-group sum of squares.
- For observations 3 and 7 in one group, calculate that group’s sum using the computational identity and check it using deviations from the mean.