Curious Minds

Clear answers to science and history questions

SS in Statistics: Sum of Squares Explained

· 6 min read · Science

In statistics, SS stands for sum of squares. It is the sum of the squared deviations of each data point from a central value, usually the mean. SS is the fundamental building block of variance, standard deviation, ANOVA, and regression. It quantifies total variability: the larger the SS, the more spread out the data are around the reference point. SS is not a single number with one universal meaning; its interpretation depends on which reference (mean, fitted model, or group mean) is used and on the context of the analysis. This article explains the definition, the different types, how SS is calculated, how it is used in practice, and common pitfalls.

Definition and Basic Formula

The sum of squares is defined as the sum of the squared differences between each observation and a reference value. For a sample of n values x1, x2, …, xn with sample mean x̄, the total sum of squares (often denoted SST or TSS) is:

SS = Σ (xi − x̄)2

Squaring serves two purposes: it makes all deviations positive (so they do not cancel) and it penalizes large deviations more heavily than small ones. The result is in squared units—for example, squared kilograms or squared dollars—which is why SS itself is rarely reported as a final descriptive measure. Instead, it is divided by degrees of freedom to produce variance, or used in ratios (such as the F statistic) to test hypotheses.

When the reference is not the mean but a model prediction, the same idea applies: SS measures the total squared discrepancy between observed and predicted values. This is the basis of least-squares estimation, where parameters are chosen to minimize SS.

Types of Sum of Squares

In inferential statistics, SS is partitioned into components that reflect different sources of variation. The most common types are:

  • Total sum of squares (SST): the sum of squared deviations of each observation from the grand mean. It represents all variability in the data.
  • Regression sum of squares (SSR): the part of SST explained by the fitted model (the squared deviations of predicted values from the grand mean). Also called model sum of squares.
  • Error sum of squares (SSE): the part of SST not explained by the model (the squared deviations of observed values from predicted values). Also called residual sum of squares.
  • Within-group sum of squares (SSW): in ANOVA, the variability inside each group, summed across groups.
  • Between-group sum of squares (SSB): in ANOVA, the variability of group means around the grand mean, weighted by group size.

The fundamental identity is SST = SSR + SSE in regression, and SST = SSB + SSW in one-way ANOVA. This partitioning is what allows analysts to compare explained and unexplained variation.

How SS Is Calculated: A Worked Example

Suppose a sample of five values: 2, 4, 4, 4, 6. The mean is (2+4+4+4+6)/5 = 20/5 = 4. The deviations from the mean are −2, 0, 0, 0, 2. Squaring gives 4, 0, 0, 0, 4. Summing yields SS = 8. The sample variance is SS/(n−1) = 8/4 = 2, and the sample standard deviation is √2 ≈ 1.41.

For a regression example, imagine predicting a response y from a predictor x. After fitting the least-squares line, you compute predicted values ŷ. Then SSE = Σ(y − ŷ)² and SSR = Σ(ŷ − ȳ)². If SST = 100 and SSE = 30, then SSR = 70, and the coefficient of determination R² = SSR/SST = 0.70, meaning 70% of the total variation is explained by the model.

In ANOVA with three groups, you would compute each group mean, the grand mean, then SSB = Σ nj(x̄j − x̄)² and SSW = Σ Σ (xij − x̄j)². The F statistic is (SSB/dfB) / (SSW/dfW), where dfB = k−1 and dfW = N−k for k groups and N total observations.

Role in Variance, Standard Deviation, and ANOVA

SS is the raw material for variance and standard deviation. Sample variance is SS divided by n−1 (the degrees of freedom). Population variance divides SS by N. Standard deviation is the square root of variance, returning the measure to original units. Thus SS is an intermediate quantity: useful for computation and for partitioning variability, but not usually interpreted on its own.

In ANOVA, SS components are divided by their degrees of freedom to produce mean squares (MS). The F ratio compares between-group MS to within-group MS. A large F suggests group means differ beyond what chance would produce. The logic is that if groups are truly similar, SSB should be small relative to SSW. The same partitioning underlies regression ANOVA, where the F test assesses whether the model explains a significant portion of variance.

In regression, SSE is also called the residual sum of squares. Minimizing SSE is the ordinary least squares criterion. The resulting estimates have desirable properties under standard assumptions. SSR and SSE together sum to SST, and R² = 1 − SSE/SST is a common goodness-of-fit measure.

Common Misconceptions and Pitfalls

  • SS is not variance. Variance is SS divided by degrees of freedom. Reporting SS alone without context can mislead because it scales with sample size.
  • SS depends on the reference value. Using the mean versus a model prediction changes the interpretation. Always specify which SS you mean (total, regression, error, within, between).
  • SS is in squared units. It cannot be compared directly to the original data scale. Convert to standard deviation for interpretable spread.
  • Larger SS does not always mean more variability. A larger sample or different units can inflate SS. Compare mean squares or standardized measures instead.
  • SS is sensitive to outliers. Squaring amplifies extreme deviations, so a single outlier can dominate SS. Robust alternatives exist but are beyond basic SS.

A common related question is whether SS can be negative. Because it is a sum of squares, SS is always non-negative. It equals zero only when all values equal the reference (e.g., all observations equal the mean).

When to Use SS vs. Other Measures

SS is most useful when you need to partition variability—in ANOVA, regression, and designed experiments. For simple description of spread, standard deviation or interquartile range is more interpretable. For comparing variability across different units or scales, the coefficient of variation may be preferable. SS is also used in quality control (e.g., sum of squared deviations from target) and in machine learning loss functions (sum of squared errors), though mean squared error is more common there to account for sample size.

In summary, choose SS when the goal is decomposition of variance or least-squares estimation. Choose standard deviation when communicating spread to a general audience. Choose mean squares when testing hypotheses, because they adjust for degrees of freedom.

Frequently Asked Questions

What does SS stand for in statistics?

SS stands for sum of squares. It is the sum of squared deviations from a reference value, typically the mean or a model prediction.

Is SS the same as variance?

No. Variance is SS divided by degrees of freedom (n−1 for a sample). SS is the numerator in that calculation.

Can SS be negative?

No. Because it is a sum of squared values, SS is always zero or positive.

What is the difference between SST, SSR, and SSE?

SST is total variability around the mean. SSR is variability explained by the regression model. SSE is unexplained variability (residuals). SST = SSR + SSE.

Why is SS divided by degrees of freedom?

Dividing by degrees of freedom produces an unbiased estimate of variance (mean square) and adjusts for sample size, allowing comparisons across datasets.

Is SS used outside statistics?

Yes. Sum of squared errors appears in engineering, machine learning, and quality control as a loss or deviation measure, though often averaged rather than summed.

In this article
  1. Definition and Basic Formula
  2. Types of Sum of Squares
  3. How SS Is Calculated: A Worked Example
  4. Role in Variance, Standard Deviation, and ANOVA
  5. Common Misconceptions and Pitfalls
  6. When to Use SS vs. Other Measures
  7. Frequently Asked Questions