What Within-Group Sum of Squares Measures
In a one-way analysis of variance, each observation belongs to one of several groups. The within-group sum of squares measures how much the observations vary around the mean of their own group. It is a measure of residual variation: each residual is the observation minus the mean assigned to its group.
This calculation is distinct from measuring how far group means are from one another. An observation is centered at its own group mean, not at the overall mean. Consequently, the within-group sum of squares can be small even when group means differ substantially, or large when observations vary widely inside their groups.
The observations may be measurements such as processing times, yields, or scores. The calculation itself is descriptive: it requires group membership and numerical observations, but it does not require a normal distribution. If the result is used as part of an inferential ANOVA, the assumptions of that analysis must also be considered.
Because each deviation is squared, \(SS_W\) is nonnegative and is expressed in squared measurement units. For example, if observations are recorded in minutes, \(SS_W\) is in minutes squared. A value of zero means every observation equals its own group mean, so every group has no observed internal variation.
Calculating from Raw Observations
The direct calculation follows the definition. Find each group mean, subtract that mean from every observation in that group, square each deviation, and add the squared deviations across all groups. A deviation below the mean contributes just as much as an equally large deviation above the mean, because both are squared.
Worked Example: Comparing Variation in Three Training Groups
A hypothetical organization records completion times, in minutes, for participants in three training formats. The observations are: Format A, 4, 6, 8; Format B, 5, 7, 9; and Format C, 8, 10, 12. Calculate the within-group sum of squares. Use the direct-deviation method, and identify the calculation error that would result from using the overall mean instead.
Method. Calculate deviations from each format's own mean. This method avoids treating a group's position relative to the other groups as within-group variation.
For Format A, the mean is \((4+6+8)/3=18/3=6\). The squared deviations are \((4-6)^2=4\), \((6-6)^2=0\), and \((8-6)^2=4\). Its contribution is \(4+0+4=8\).
For Format B, the mean is \((5+7+9)/3=21/3=7\). The squared deviations are \((5-7)^2=4\), \((7-7)^2=0\), and \((9-7)^2=4\). Its contribution is \(4+0+4=8\).
For Format C, the mean is \((8+10+12)/3=30/3=10\). The squared deviations are \((8-10)^2=4\), \((10-10)^2=0\), and \((12-10)^2=4\). Its contribution is \(4+0+4=8\).
Therefore, \(SS_W=8+8+8=24\) minutes squared. As a check, the three group contributions are all nonnegative, and the total is their sum.
Common mistake avoided. The overall mean is \(69/9=7.6667\), not the mean to use for these deviations. Centering observations at that overall mean would mix differences between the formats with variation within them. Each observation must be centered at its own format mean.
A Computational Shortcut
When a problem gives group totals and sums of squares, or when the raw observations are numerous, a shortcut avoids listing every deviation. For a single group, let \(T_i=\sum_j y_{ij}\) be its total and \(Q_i=\sum_j y_{ij}^2\) be its sum of squared observations. Then that group's contribution can be calculated as \(Q_i-T_i^2/n_i\).
For every group, record its sample size \(n_i\), total \(T_i\), and sum of squared observations \(Q_i\).
Evaluate \(Q_i-T_i^2/n_i\), keeping the squared total and the division by that group's size together.
Sum the group-specific results to obtain \(SS_W\). Do not average them.
The shortcut follows by expanding the definition for one group:
By definition, \(\sum_j y_{ij}=n_i\bar{y}_i\). Substituting gives \(\sum_j y_{ij}^2-2n_i\bar{y}_i^2+n_i\bar{y}_i^2=\sum_j y_{ij}^2-n_i\bar{y}_i^2\). Since \(\bar{y}_i=T_i/n_i\), the last expression is \(Q_i-T_i^2/n_i\). This proves the formula for each group; adding those group identities proves the formula for \(SS_W\).
Worked Example: Using Unequal Group Sizes and Totals
In a hypothetical study of claim-processing workflows, processing times are summarized as follows. Workflow A has \(n_1=3\), \(T_1=42\), and \(Q_1=596\). Workflow B has \(n_2=4\), \(T_2=84\), and \(Q_2=1784\). Workflow C has \(n_3=3\), \(T_3=51\), and \(Q_3=875\). Calculate \(SS_W\) from the summaries and check each contribution.
Method. Apply the computational formula separately within each workflow. The group sizes are unequal, so each squared total must be divided by its own group size.
For Workflow A, \(T_1^2=42^2=1764\), and \(T_1^2/n_1=1764/3=588\). Its contribution is \(Q_1-T_1^2/n_1=596-588=8\).
For Workflow B, \(T_2^2=84^2=7056\), and \(T_2^2/n_2=7056/4=1764\). Its contribution is \(1784-1764=20\).
For Workflow C, \(T_3^2=51^2=2601\), and \(T_3^2/n_3=2601/3=867\). Its contribution is \(875-867=8\).
Adding the contributions gives \(SS_W=8+20+8=36\) minutes squared. Each contribution is nonnegative, as it must be because it equals a sum of squared deviations.
Common mistake avoided. Do not divide every squared total by the same number, such as the total sample size. The correction term for each group is \(T_i^2/n_i\), using that group's own \(n_i\).
Interpreting the Residual Variation
In the one-way model, the group mean is the fitted value for every observation in that group. The residual for observation \(j\) in group \(i\) is \(e_{ij}=y_{ij}-\bar{y}_i\). Therefore, the within-group sum of squares is exactly the sum of squared residuals from fitting a separate mean to each group.
The within-group sum of squares describes the total residual variation, so it is affected by both the number of observations and their spread within groups. It is not, on its own, a standardized measure of spread. Also, it is not the average squared residual: the definition calls for a sum, and dividing by a count would produce a different quantity.
Worked Example: Finding Within-Group Variation from Summary Statistics
A hypothetical quality review reports only summary statistics for three inspection teams. Team A has \(n_1=5\), \(T_1=50\), and \(Q_1=510\); Team B has \(n_2=4\), \(T_2=44\), and \(Q_2=496\); Team C has \(n_3=3\), \(T_3=39\), and \(Q_3=515\). Here \(Q_i\) is the sum of squared recorded measurements, not the square of the group total. Calculate \(SS_W\), and determine which team contributes most.
Method. Use the summary-statistic formula group by group, then compare the resulting contributions. This avoids confusing \(Q_i=\sum_j y_{ij}^2\) with \(T_i^2\).
For Team A, \(T_1^2=50^2=2500\), and \(T_1^2/n_1=2500/5=500\). Its contribution is \(510-500=10\).
For Team B, \(T_2^2=44^2=1936\), and \(T_2^2/n_2=1936/4=484\). Its contribution is \(496-484=12\).
For Team C, \(T_3^2=39^2=1521\), and \(T_3^2/n_3=1521/3=507\). Its contribution is \(515-507=8\).
Thus \(SS_W=10+12+8=30\) in squared measurement units. Team B contributes the most, with 12, compared with 10 for Team A and 8 for Team C. The contributions sum to the total, which checks the arithmetic.
Common mistake avoided. Squaring the group total gives \(T_i^2\), which is only part of the correction term. It is not the group's sum of squared observations \(Q_i\). Replacing \(Q_i\) by \(T_i^2\) would therefore not calculate the within-group sum of squares.
Common Calculation Traps
- Using the grand mean. Within-group deviations are measured from each corresponding group mean. The grand mean answers a different question.
- Forgetting to square deviations. Adding signed deviations within a group gives zero, since deviations from the group mean sum to zero. It does not measure variation.
- Dividing the result by a group size. The definition is a sum of squared deviations. Do not divide the final sum by the number of observations.
- Mixing up totals and squared totals. \(T_i^2\) means the square of the sum; \(Q_i\) means the sum of the squared observations. They are not interchangeable.
- Combining groups too early. Calculate \(Q_i-T_i^2/n_i\) within each group before adding. Applying one correction to all observations would center at a pooled mean instead.
Check Your Understanding
For each problem, calculate the within-group sum of squares using the stated observations or summaries.
- A hypothetical study records three observations in Group A: 3, 5, 7, and three in Group B: 6, 8, 10. Find the mean and squared-deviation contribution for each group, then find \(SS_W\). (Answer: Group contributions 8 and 8; \(SS_W=16\).)
- Three groups have observations A: 2, 4, 6; B: 5, 7; and C: 8, 10, 12, 14. Calculate each group's mean and contribution before adding them. (Answer: Contributions 8, 2, and 20; \(SS_W=30\).)
- Group A has \(n_1=3\), \(T_1=24\), and \(Q_1=200\); Group B has \(n_2=4\), \(T_2=36\), and \(Q_2=338\). Find each contribution using the computational formula. (Answer: Contributions 8 and 14; \(SS_W=22\).)
- A hypothetical sensor study gives Group A the observations 10, 12, 14, 16 and Group B the observations 9, 11, 13. Find each mean, each within-group contribution, and the total. (Answer: Means 13 and 11; contributions 20 and 8; \(SS_W=28\).)
- Group A contains 2, 4, 6 and Group B contains 1, 5, 9. A revised recording system adds 10 to every Group A observation and subtracts 3 from every Group B observation. Calculate the original \(SS_W\) and explain the value after the changes. (Answer: Original contributions 8 and 32, so \(SS_W=40\); after the changes, \(SS_W\) remains 40.)