1 Definition and role in ANOVA
1.1 Total variation concept
In analysis of variance (ANOVA), the goal is to explain variation in a response variable by attributing it to different sources. The starting point is the total variability of the observed data around a single overall center (often the grand mean). This total variability is summarized by the total sum of squares (SST), which aggregates squared deviations across all observations.
1.2 Sum of squares components
ANOVA partitions SST into components associated with the model structure and with residual (unexplained) noise. In the common one-way layout, there are three key pieces:
- Between-groups (treatment) sum of squares (SSB): variability due to differences among group means.
- Within-groups (error) sum of squares (SSW): variability of observations around their own group mean.
These components support comparing how much signal (group differences) exists relative to random scatter.
1.3 Relationship to mean squares and the F-statistic
To turn sums of squares into test statistics, ANOVA converts each component into a mean square by dividing by its associated degrees of freedom. The F-statistic compares the between-group mean square to the within-group mean square:
- Large MSB relative to MSW suggests group means differ more than would be expected from within-group variability alone.
- When the two are similar, observed differences are consistent with random variation.
2 Mathematical formulation
2.1 Notation and assumptions
Consider a one-way ANOVA with \(k\) groups. Let \(n_i\) be the sample size of group \(i\), \(y_{ij}\) the \(j\)-th observation in group \(i\), \(\bar{y}_i\) the group mean, and \(\bar{y}\) the overall (grand) mean. The total number of observations is \(n=\sum_{i=1}^{k} n_i\). The definitions below do not require a specific distribution, but standard inference relies on typical ANOVA assumptions such as independent observations and residual behavior.
2.2 Total sum of squares (SST)
The total sum of squares measures the overall deviation of observations from the grand mean: \[ \mathrm{SST}=\sum_{i=1}^{k}\sum_{j=1}^{n_i}\left(y_{ij}-\bar{y}\right)^2. \]
2.3 Between-groups (treatment) sum of squares (SSB)
The between-groups component captures how far each group mean sits from the grand mean, scaled by group size: \[ \mathrm{SSB}=\sum_{i=1}^{k} n_i\left(\bar{y}_i-\bar{y}\right)^2. \]
2.4 Within-groups (error) sum of squares (SSW)
The within-groups component measures how tightly observations cluster around their own group means: \[ \mathrm{SSW}=\sum_{i=1}^{k}\sum_{j=1}^{n_i}\left(y_{ij}-\bar{y}_i\right)^2. \]
2.5 Partition identity: SST = SSB + SSW
A fundamental algebraic identity links these quantities: \[ \mathrm{SST}=\mathrm{SSB}+\mathrm{SSW}. \] This expresses that total variation equals explained variation (between groups) plus unexplained variation (within groups).
3 Computation methods
3.1 Direct computation from group summaries
For one-way ANOVA, it is common to compute sums of squares using group means and the grand mean.
3.1.1 Group means and overall mean
Compute:
- \(\bar{y}_i = \frac{1}{n_i}\sum_{j=1}^{n_i} y_{ij}\)
- \(\bar{y} = \frac{1}{n}\sum_{i=1}^{k}\sum_{j=1}^{n_i} y_{ij}\)
These means then feed directly into formulas for SSB (and help determine SST and SSW).
3.1.2 Using deviations and squared terms
- Compute SSB via \(n_i(\bar{y}_i-\bar{y})^2\) and sum over groups.
- Compute SSW via \((y_{ij}-\bar{y}_i)^2\) and sum over observations.
- Compute SST via \((y_{ij}-\bar{y})^2\), or equivalently use \( \mathrm{SST}=\mathrm{SSB}+\mathrm{SSW}\) after the other two are known.
3.2 Computational shortcuts
When raw data are large, there are algebraic shortcuts that reduce repeated calculations.
3.2.1 Sum-of-squares from raw values vs. means
A typical approach uses identities that expand squared deviations. For example, SST can be expressed in terms of sums of observations and sums of squares of observations (with the grand mean substituting for averages). Similar expansions can be used to derive SSW and SSB without explicitly computing every deviation-to-mean term, though the exact formulas depend on what intermediate quantities are available.
3.3 Balanced vs. unbalanced designs
- Balanced designs: group sizes are equal (\(n_i=n_0\)). Many computational expressions simplify, and mean squares align neatly with intuitive scaling.
- Unbalanced designs: group sizes differ. The partitions remain valid, but SSB includes the weighting by \(n_i\), so groups with more observations can contribute more to between-group variation even if their means differ by the same amount.
3.4 Handling missing observations (conceptual)
Conceptually, missing values affect the calculation because sums are taken only over observed entries. In a strictly classical ANOVA framework, the structure of the groups (what counts as each group mean) determines the SSB/SSW partition. In practice, missingness may require a modeling strategy (e.g., treating data as unbalanced with only observed cases), and specialized methods may be used to maintain the validity of inference.
4 Two-group special case
4.1 Connection to the t-test
When there are exactly two groups, one-way ANOVA with groups \(1\) and \(2\) becomes closely related to the two-sample t-test. The F-statistic from ANOVA equals the square of the t-statistic (under standard conditions), because both are comparing the same underlying mean difference while normalizing by an estimate of variability.
4.2 SSB and SSW interpretation for two groups
For two groups:
- SSB reflects the squared distance between the two group means, adjusted for how the grand mean lies midway (in an algebraic sense) and scaled by group sizes.
- SSW reflects the pooled-like within-group variability, measuring spread around each group mean.
A larger separation between group centers increases SSB, while greater within-group scatter inflates SSW, reducing the ratio used in the F-test.
5 Effect sizes derived from sums of squares
5.1 Eta-squared (η²)
Eta-squared quantifies the proportion of total variability accounted for by the grouping factor: \[ \eta^2=\frac{\mathrm{SSB}}{\mathrm{SST}}. \] It ranges from 0 to 1 in typical settings (when SSB and SST are nonnegative and SST is not zero) and is often reported alongside the hypothesis test.
5.2 Omega-squared (ω²) (overview)
Omega-squared aims to estimate the proportion of variance explained with a bias correction relative to \(\eta^2\). It is generally more conservative, particularly in small samples, because it adjusts for the fact that SSB can be inflated by sampling variability.
5.3 Interpretation and practical meaning
Effect size connects the numeric results to substantive relevance:
- High η² or ω² indicates that group means explain a meaningful share of variability.
- A statistically significant F-test does not automatically imply a large effect; conversely, a small p-value can coincide with modest practical differences depending on sample size and variability.
Because SSB and SSW determine these measures, the ratio between between-group and within-group sums of squares is the driving mechanism.
6 Model extensions and variants
6.1 One-way ANOVA
One-way ANOVA assumes a single categorical predictor affecting the response. In that setting, the classic split is \(\mathrm{SST}=\mathrm{SSB}+\mathrm{SSW}\), with SSB representing differences among \(k\) group means and SSW representing within-group residual variability.
6.2 Two-way ANOVA (high-level)
Two-way ANOVA introduces two categorical factors (and potentially their interaction). The total variability is partitioned into multiple sum-of-squares terms, commonly associated with:
- main effect of factor A,
- main effect of factor B,
- interaction effect,
- residual/error.
6.2.1 Main effects vs. interaction (overview)
- Main effects assess whether average responses differ across levels of one factor, averaging over levels of the other.
- Interaction captures whether the effect of one factor depends on the level of the other. In variance-partition terms, interaction corresponds to an additional explained component beyond the additive main effects.
6.3 Repeated-measures ANOVA (overview)
Repeated-measures designs involve correlated observations from the same subjects under multiple conditions. The decomposition of variability is modified to account for within-subject correlation structures. As a result, sum-of-squares terms and degrees of freedom are computed differently from the independent-groups case.
6.4 Generalized linear model perspective (brief)
In a broader generalized linear model (GLM) view, ANOVA-like comparisons can be framed using deviance or likelihood-based measures rather than simple squared deviations. Although the “sum of squares” language changes in GLMs, the conceptual role remains: partitioning variability attributable to model terms versus residual variation.
7 Degrees of freedom and mean squares
7.1 Degrees of freedom for each component
In one-way ANOVA:
- Total degrees of freedom: \(n-1\)
- Between-groups degrees of freedom: \(k-1\)
- Within-groups (error) degrees of freedom: \(n-k\)
These degrees of freedom determine how sums of squares translate into mean squares.
7.2 Mean square calculations
Mean squares are defined by dividing each sum of squares by its degrees of freedom: \[ \mathrm{MSB}=\frac{\mathrm{SSB}}{k-1},\quad \mathrm{MSW}=\frac{\mathrm{SSW}}{n-k}. \] MS values represent average squared variation per adjustable degree.
7.3 How F uses MSB and MSW
The F-statistic is computed as: \[ F=\frac{\mathrm{MSB}}{\mathrm{MSW}}. \] Under null hypotheses where group means are equal, MSB and MSW estimate different aspects of variability but are expected to be comparable; large ratios arise when between-group variation exceeds what within-group scatter would predict.
8 Diagnostics and interpretation tips
8.1 What large SSB indicates
A large SSB suggests group means are well separated relative to the overall mean. In practical terms, it indicates that the between-group component of variability is strong: the grouping structure lines up with differences in the response.
8.2 What large SSW indicates
A large SSW indicates substantial scatter within groups. Even if group centers differ, high within-group variability can mask those differences because it inflates MSW, lowering the F ratio and reducing evidence against the null.
8.3 Common pitfalls in interpreting sum of squares
Several issues can lead to misleading conclusions:
- Confusing variability with effect size: SSB depends on scale and sample sizes; its magnitude alone is not a complete description of practical impact.
- Ignoring degrees of freedom: sums of squares are not directly comparable across different designs without accounting for their associated degrees through mean squares.
- Equating statistical significance with uniform superiority: a significant between-group component does not imply every group differs from every other; it establishes that at least some group means likely differ beyond random noise.
9 Worked examples (template-based)
9.1 Example: one-way ANOVA with three groups
Suppose three groups \(i=1,2,3\) with sizes \(n_1,n_2,n_3\) and observations \(y_{ij}\). Compute:
1 Definition and role in ANOVA
2 Mathematical formulation
3 Computation methods
4 Two-group special case
5 Effect sizes derived from sums of squares
Then compute degrees of freedom (\(k-1=2\) and \(n-k\)) and mean squares to obtain F.
9.2 Example: computing SST, SSB, SSW step-by-step
A common stepwise template:
1 Definition and role in ANOVA
2 Mathematical formulation
3 Computation methods
4 Two-group special case
9.3 Example: using sums of squares to derive F
After sums of squares are computed:
1 Definition and role in ANOVA
2 Mathematical formulation
3 Computation methods
A larger SSB relative to SSW increases MSB/MSW, which raises F.
10 Assumptions and their impact on sums of squares
10.1 Independence of observations
ANOVA’s variance partition and the resulting F-reference behavior rely on observations being independent within the analyzed structure. Dependence can distort SSW (and sometimes SSB) by reducing the effective randomness of residual variation, leading to inaccurate p-values even if the computed sums of squares are arithmetically correct.
10.2 Homogeneity of variances (conceptual)
Standard one-way ANOVA presumes that groups share a common residual variance. If variances differ strongly across groups, then SSW is not a uniform measure of error across groups, and the interpretation of MSW as a common error estimate becomes less reliable.
10.3 Normality of residuals (conceptual)
The classical F-test is derived under normal residual assumptions (or asymptotic approximations). Departures from normality can affect the distribution of the test statistic, particularly in small samples, altering the calibration of evidence drawn from large or small ratios of MSB to MSW.
10.4 Robustness considerations (overview)
In many practical settings, ANOVA can be reasonably robust to mild violations, especially with balanced group sizes and sufficiently large samples. Nonetheless, the sums of squares themselves do not “fix” assumption problems: they quantify observed deviations, while validity depends on whether those deviations behave like the assumed random error model.