AI Glossary / Statistics and probability / Intermediate
Sums of squares
Definition
Sums of squares are totals formed by squaring quantities, commonly deviations from a mean, fitted value, or other reference, and adding the results. They measure variation or discrepancy without positive and negative deviations canceling. In statistics, different sums of squares describe total variation, variation represented by a model, and residual variation. The reference point and definition must be stated because several different quantities share similar names and abbreviations.
What it means
Squaring gives larger discrepancies disproportionately more influence. A deviation of four contributes sixteen, while a deviation of two contributes four. This makes sums of squares useful for least-squares fitting and variance calculations, but also sensitive to unusually large observations or errors.
A centered total sum of squares uses deviations from the sample mean. A residual sum of squares uses observed-minus-fitted differences. An uncorrected sum of squares simply adds squared observations and therefore measures distance from zero. These are not interchangeable. A sum of squares has squared measurement units and grows with both the amount of variation and, generally, the amount of data represented.
How it works
Choose the reference for each observation, calculate its deviation, square that deviation, and add across the relevant observations. Keep the definition consistent with the model and analysis. For ordinary sample variance, divide the centered total sum of squares by n − 1.
In ordinary least-squares regression fitted with an intercept on the same data, centered total variation decomposes into fitted variation plus residual variation. The geometry of the fit makes the cross-term vanish. That identity should not be assumed unchanged for arbitrary predictions, models without an intercept, or differently weighted calculations.
In one-way ANOVA, total variation around the grand mean divides into variation between group means and variation within groups. Dividing each component by its associated degrees of freedom gives mean squares. Appropriate ratios can then support tests under the required model assumptions.
State notation clearly. Some references use SST for total variation, while others use it for treatment variation. In unbalanced models with several factors, different definitions of adjusted or sequential sums of squares can answer different hypotheses. Matching the calculation to the question matters more than memorizing one abbreviation.
Three practical examples
1. A regression routine minimizes residual sum of squares to fit a linear relationship between workload and processing time.
2. An analyst decomposes variation in outcomes into between-group and within-group components before interpreting an ANOVA comparison.
3. An AI evaluation team compares squared prediction errors on the same test cases, while also examining whether a few large errors dominate the metric.
Think of it this way
Think of measuring squared distances from a target. Points on opposite sides contribute positive amounts, so errors cannot cancel. Changing the target changes the quantity, and distant points contribute more.
Worked example
Consider an original dataset with group A values 1, 2, 3 and group B values 5, 6, 7. The group means are 2 and 6; the grand mean is 4. Centered total sum of squares is (1 − 4) squared + (2 − 4) squared + (3 − 4) squared + (5 − 4) squared + (6 − 4) squared + (7 − 4) squared = 28.
Within-group sum of squares is 1 + 0 + 1 for A and 1 + 0 + 1 for B, totaling 4. Between-group sum of squares is 3(2 − 4) squared + 3(6 − 4) squared = 24. Thus 28 = 24 + 4.
Total degrees of freedom are 6 − 1 = 5, between-group degrees of freedom are 2 − 1 = 1, and within-group degrees of freedom are 6 − 2 = 4. The within-group mean square is 4 / 4 = 1; the between-group mean square is 24 / 1 = 24. Their ratio is 24, but a formal F-test interpretation needs the relevant independent normal common-variance model.
The uncorrected sum of squared observations is 124, not 28. It equals 28 + 6 × 4 squared, illustrating the difference between variation around the mean and magnitude relative to zero. These are descriptive calculations for stipulated data, not evidence of a causal group effect.
Illustrative case study
In a fictional company, Alder Forecasts compares model errors across two months. One month contains twice as many evaluated cases, so its larger residual sum of squares initially looks like worse performance. The analyst reports mean squared error on clearly defined cases and examines the error distribution as well. For a separate group comparison, the team labels between-group and within-group sums explicitly to avoid confusing treatment SS with total SS. The revised report makes the quantity and denominator clear before drawing conclusions.
Common misconceptions and mistakes
A sum of squared deviations is not the square of their sum. Squaring after addition would allow cancellation first and produces a different result.
Total, residual, treatment, and uncorrected sums of squares are different quantities. Abbreviations vary across references, so check definitions.
Smaller training residual sum of squares does not automatically mean better future prediction; adding model flexibility can reduce training error without improving generalization. Likewise, sums from different sample sizes or measurement scales are not directly comparable without appropriate context. The familiar decomposition also relies on the fit and reference definitions, rather than holding for every set of predictions.
Business use
Sums of squares underpin regression fitting, variance estimation, ANOVA, and squared-error performance metrics. They give businesses a consistent way to quantify deviations once the reference and scope are specified.
Use comparable observations and units when assessing models. Report denominators when converting sums to mean squares, and inspect large contributions rather than letting one total hide the error pattern. If the business cost of errors is asymmetric or driven by absolute rather than squared deviations, a squared-error criterion may not reflect the decision objective. Choose the metric deliberately.
People also ask
Can a sum of squares be negative?
A directly calculated sum of real squared quantities cannot be negative.
Is it a variance?
Not by itself; variance requires an appropriate normalization and definition.
Why are units squared?
Each deviation is squared before addition, so minutes become square minutes, for example.
Check your understanding
Answer: Residuals are −2, 1, and 1.
What is their sum of squares?
Answer: It is 4 + 1 + 1 = 6. Their sum is zero, whose square is zero; that is a different calculation.
Related terms
- Variance
- Least squares
- Degrees of freedom
- R-squared
- Squared error loss
- residual sum of squares
- mean square error
- ANOVA
Learn next
Study least-squares decomposition and ANOVA mean squares. Then compare squared-error metrics with alternatives tied to practical decision costs.
More in Statistics and probability
- Subjective logic - Subjective logic is a formal framework for reasoning with uncertain opinions, developed by Audun Jøsang.
- Subjective probability - Subjective probability expresses an individual's or agent's degree of belief that a proposition is true, given the information and assumptions available to...
- Sufficient statistic - A sufficient statistic is a function of observed data that preserves all the information those data contain about a specified parameter within a specified...
- Sunrise problem - The sunrise problem asks how observing an event repeatedly should affect belief that it will happen again.
- Suppressor variable - A suppressor variable is a predictor whose inclusion in a regression improves the predictive contribution of another predictor by accounting for variation...
- Surrogate data testing - Surrogate data testing is a hypothesis-testing approach that compares a statistic from observed data with values computed from artificial datasets generated...
Sources
Howell's author glossary, Sums of squares: https://www.uvm.edu/~statdhtx/methods8/Glossary/Glossary.html . NIST, The ANOVA table and tests of hypotheses about means: https://www.itl.nist.gov/div898/handbook/prc/section4/prc433.htm . The example and fictional reporting case are original. Notation differences and the assumptions required for inferential use are stated explicitly.
Previous: Sum-of-squares optimization Next: Sunburst chart