Tutorials › Regression Analysis (Undergraduate) › Total Sum of Squares Around the Mean

Model Fit and Nested Comparisons · Tutorial 246 of 991

Total Sum of Squares Around the Mean

Learn to calculate total sum of squares around the sample mean and understand how its value changes when outcomes are rescaled or observations change.

Intermediate 9 min read

What You'll Learn

  • Define total sum of squares around the sample mean.
  • Calculate it from a small set of observed outcomes.
  • Connect total sum of squares to sample variance.
  • Determine how changing outcome units affects its value.
  • Explain why changing the sample can change total sum of squares.

Why Measure Variation Around the Mean?

A list of outcomes is easier to summarize when we know both its center and how far its values tend to lie from that center. In regression, the outcome’s sample mean provides a simple reference point: it is one value shared by the whole sample. The total sum of squares measures the observed outcomes’ squared distances from that reference point.

This quantity is useful to define precisely before using it in model-fit comparisons. It describes the outcome values in the sample; it is not a measure of predictor variation, and its calculation does not require fitting a regression model. Its numerical value also depends on the units used for the outcome and on which observations are in the sample.

Definition: For \(n\) observed outcome values \(y_1,\ldots,y_n\), their sample mean is \(\bar{y}=\frac{1}{n}\sum_{i=1}^{n}y_i\). The total sum of squares around the mean, often abbreviated TSS, is
$$ \mathrm{TSS}=\sum_{i=1}^{n}(y_i-\bar{y})^2. $$
Each outcome’s deviation from the sample mean is squared, and those squared deviations are added. TSS is nonnegative and is zero exactly when every observed outcome equals \(\bar{y}\).

The subscript \(i\) identifies an observation, not a predictor or a model coefficient. Each term \(y_i-\bar{y}\) is measured in the same units as the outcome; after squaring, TSS has squared outcome units. For example, if outcomes are measured in centimetres, TSS is measured in square centimetres.

TSS is a descriptive quantity for the particular observed sample. There are no regression-model assumptions needed to calculate it. A sample of only one outcome has TSS equal to zero, because that one outcome is also its sample mean. The usual sample variance is defined for \(n\geq 2\), so its connection to TSS below is stated for that case.

Calculating TSS and Connecting It to Sample Variance

A reliable calculation follows a simple sequence: find the sample mean, subtract that mean from each outcome, square each deviation, and add the squared deviations. Keeping the deviations visible helps prevent errors, especially when observations lie on both sides of the mean.

For \(n\geq 2\), the sample variance \(s^2\) is the sum of squared deviations from the sample mean divided by \(n-1\). Therefore, TSS is exactly \((n-1)s^2\). This relationship is a way to check a TSS calculation; it does not change the definition of TSS.

Worked Example: Calculating TSS From Five Outcomes

Suppose, hypothetically, that five measurements of a plant’s height, in centimetres, are \(2, 4, 6, 8,\) and \(10\). Calculate their TSS.

First find the sample mean:

$$ \bar{y}=\frac{2+4+6+8+10}{5}=\frac{30}{5}=6\text{ cm}. $$

The deviations from the mean are \(-4,-2,0,2,\) and \(4\) cm. Squaring and adding gives

$$ \mathrm{TSS}=(-4)^2+(-2)^2+0^2+2^2+4^2 =16+4+0+4+16 =40\text{ cm}^2. $$

As a check, the sample variance is \(s^2=40/(5-1)=10\text{ cm}^2\). Thus \((n-1)s^2=4(10)=40\text{ cm}^2\), which agrees with the direct calculation. The 40 is a sum of squared deviations for these five observed heights; it is not itself an average deviation.

The connection to sample variance follows directly from its definition:

$$ s^2=\frac{\sum_{i=1}^{n}(y_i-\bar{y})^2}{n-1} =\frac{\mathrm{TSS}}{n-1}, \qquad\text{so}\qquad \mathrm{TSS}=(n-1)s^2. $$

The factor \(n-1\) matters. Dividing TSS by \(n\) does not give the usual sample variance \(s^2\). TSS itself is the sum, while \(s^2\) is that sum divided by \(n-1\). Because variance has squared outcome units, this relationship also confirms that TSS has squared outcome units.

How Changing Outcome Units Changes TSS

TSS is affected by a change in the numerical scale of the outcome. Suppose every outcome is transformed using \(z_i=a+c y_i\), where \(a\) is a constant shift and \(c\) is a constant multiplier. The transformed sample mean is \(\bar{z}=a+c\bar{y}\). Each transformed deviation is therefore

$$ z_i-\bar{z}=(a+c y_i)-(a+c\bar{y})=c(y_i-\bar{y}). $$

The shift \(a\) cancels when deviations from the mean are taken. The multiplier \(c\), however, remains in every deviation and is squared in TSS. Thus a constant shift does not change TSS, while multiplying all outcomes by \(c\) multiplies TSS by \(c^2\).

Worked Example: Converting the Measurement Scale

Use the hypothetical heights \(2,4,6,8,10\) cm from the previous calculation. Convert each height to millimetres by multiplying by 10, and determine the transformed TSS.

The new outcomes are \(20,40,60,80,\) and \(100\) mm, with mean \(60\) mm. Their deviations are \(-40,-20,0,20,\) and \(40\) mm. Therefore,

$$ \mathrm{TSS}_{\mathrm{mm}} =(-40)^2+(-20)^2+0^2+20^2+40^2 =1600+400+0+400+1600 =4000\text{ mm}^2. $$

The original TSS was \(40\text{ cm}^2\). Since \(1\text{ cm}=10\text{ mm}\), each deviation is multiplied by 10 and each squared deviation by \(10^2=100\). The predicted transformed TSS is \(100(40)=4000\text{ mm}^2\), matching the direct calculation.

A temperature conversion illustrates the role of both shifting and scaling. Fahrenheit values are obtained from Celsius values by \(F=32+1.8C\). The added 32 does not affect deviations from the mean, while the multiplier 1.8 multiplies TSS by \(1.8^2=3.24\). For the five values \(2,4,6,8,10\) Celsius, their TSS is \(40\text{ °C}^2\), so their Fahrenheit TSS is \(3.24(40)=129.6\text{ °F}^2\). A different numerical TSS after conversion does not mean the observations’ pattern of relative differences has changed; it reflects the new scale.

How Changing the Sample Changes TSS

TSS is calculated using the mean of the particular sample being analyzed. If observations are added or removed, the mean may move, so the deviations of the original observations may change as well. TSS is therefore sample-dependent: it is not a fixed number that belongs to the outcome variable regardless of which observations are included.

The effect of adding one observation can be derived exactly. Suppose a sample of \(n\) observations has mean \(\bar{y}\) and TSS \(T\). Add one observation \(z\). The new mean is \(\bar{y}_{\mathrm{new}}=(n\bar{y}+z)/(n+1)\). For each original observation, its deviation from the new mean is its old deviation minus \((z-\bar{y})/(n+1)\). The new observation’s deviation from the new mean is \(n(z-\bar{y})/(n+1)\). Squaring these deviations and adding yields the update formula below.

Result: If one observation \(z\) is added to a sample of size \(n\), then
$$ \mathrm{TSS}_{\mathrm{new}} =\mathrm{TSS}_{\mathrm{old}}+\frac{n}{n+1}(z-\bar{y})^2. $$
The formula uses the old sample mean \(\bar{y}\). Its added term is nonnegative, so adding one observation to an otherwise unchanged sample cannot decrease TSS. If \(z=\bar{y}\), the new TSS equals the old TSS.

For completeness, let \(d=z-\bar{y}\). The shift in the mean is \(\bar{y}_{\mathrm{new}}-\bar{y}=d/(n+1)\). The sum of the original deviations \(y_i-\bar{y}\) is zero, so when the original squared deviations are recentered around the new mean, their total becomes \(T+n d^2/(n+1)^2\). The new observation contributes \(n^2d^2/(n+1)^2\). Adding these contributions gives

$$ T+\frac{n d^2}{(n+1)^2}+\frac{n^2d^2}{(n+1)^2} =T+\frac{n(n+1)d^2}{(n+1)^2} =T+\frac{n}{n+1}d^2, $$

which establishes the result. The key point is that the original observations must be recentered around the new mean; it is not enough to add the new observation’s squared distance from the old mean to the old TSS.

Worked Example: Adding an Observation Recalculates the Mean

Suppose a hypothetical sample of three daily measurements, in units, is \(2,4,\) and \(6\). Find its TSS, then add a fourth measurement of \(10\) and calculate the new TSS.

For the first three measurements, the mean is \((2+4+6)/3=4\). Their TSS is

$$ \mathrm{TSS}_{\mathrm{old}}=(2-4)^2+(4-4)^2+(6-4)^2 =4+0+4=8\text{ units}^2. $$

After adding 10, the mean changes to \((2+4+6+10)/4=5.5\). Recalculate every deviation using this new mean:

$$ \mathrm{TSS}_{\mathrm{new}} =(2-5.5)^2+(4-5.5)^2+(6-5.5)^2+(10-5.5)^2 =12.25+2.25+0.25+20.25 =35\text{ units}^2. $$

The update formula gives the same answer: \(8+\frac{3}{4}(10-4)^2=8+\frac{3}{4}(36)=8+27=35\text{ units}^2\). Simply adding \((10-4)^2=36\) to the old TSS would give 44, which is incorrect because the mean has shifted from 4 to 5.5.

Interpreting and Using TSS Carefully

TSS summarizes the total squared spread of the observed outcomes around their sample mean. A larger value can arise because the outcomes are more dispersed, because the outcome is expressed on a larger numerical scale, or because the sample contains different observations. Consequently, TSS values should not be compared casually across different units or samples.

When two samples have the same size and outcome units, TSS can help describe which sample’s outcomes are more spread out around its own mean. The sample variance provides a related summary on a per-degree-of-freedom scale. But TSS alone does not say why the outcomes vary, whether any predictor explains that variation, or whether a regression model is adequate. Those questions require additional quantities and reasoning.

Key takeaway: Compute TSS by centering each observed outcome at the sample mean, squaring each deviation, and summing. TSS is measured in squared outcome units, is unchanged by adding the same constant to every outcome, and is multiplied by \(c^2\) when every outcome is multiplied by \(c\). Changing the observations requires recalculating the sample mean and TSS.

Common Mistakes

  • Using the wrong center. TSS in this definition is centered at the sample mean \(\bar{y}\), not at zero or at a predictor’s mean.
  • Forgetting to square deviations. Positive and negative deviations would cancel if added directly. Squaring makes every contribution nonnegative.
  • Reporting the wrong units. If \(y_i\) is measured in minutes, each squared deviation and TSS are in minutes squared, not minutes.
  • Assuming a unit conversion leaves the numerical value unchanged. A shift alone leaves TSS unchanged, but multiplying outcomes by \(c\) multiplies TSS by \(c^2\).
  • Adding an observation without updating the mean. Recompute the mean and all deviations, or use the one-observation update formula.
  • Treating TSS as a model-based quantity. It is calculated from the observed outcomes alone and does not require regression assumptions.

Check Your Understanding

Try these questions using the definitions and results above.

  1. For outcomes \(1,3,5\), calculate the sample mean and TSS. State the units if the outcomes are measured in litres.
  2. If every outcome is shifted upward by 7 units, what happens to the sample mean and TSS? Explain using deviations from the mean.
  3. If every outcome is converted by multiplying by 4, by what factor does TSS change? What happens to its units?
  4. A sample has \(n=6\) and sample variance \(s^2=9\text{ kg}^2\). Find its TSS and give the units.
  5. Explain why adding a new observation requires recalculating the deviations of the original observations as well as including the new observation.