How to Compute SSreg and SSres in Regression
At a glance
- 1. Find the mean
Calculate the mean of the observed response values.
- 2. Get fitted values
Use the regression equation to predict each observed response.
- 3. Sum squared deviations
Square and add fitted-value deviations for SSreg, and residuals for SSres.
- 4. Check the identity
With an intercept, verify that total sum of squares equals SSreg plus SSres.
In regression, SSreg measures the variation in the response values accounted for by the model, while SSres measures the variation left in the residuals. The exact abbreviations differ among textbooks and software, so it helps to write down the definitions rather than rely on labels such as SSR or SSE.
For ordinary least-squares regression that includes an intercept, the total variation splits into these two parts: . The formulas and example below show how to calculate and check them.
Definitions and formulas
Suppose you have observed responses and fitted values from a regression model. Let be the mean of the observed responses. A common convention is:
The residual for observation is . Thus, SSres is the sum of squared residuals. SSreg is the sum of squared differences between the fitted values and the overall response mean.
Some sources call the explained sum of squares SSR and the residual sum of squares SSE; other sources use those abbreviations differently. The definitions above specify which quantity is meant. The word “sum” matters: these quantities add squared differences. They are not the corresponding averages or mean squares.
Step-by-step calculation
- Find the mean response, .
- Calculate the fitted response for every data point using the regression equation.
- For SSreg, subtract from each fitted value, square each difference, and add them.
- For SSres, subtract each fitted value from its observed response, square each residual, and add them.
- If the least-squares model includes an intercept, check that SSreg plus SSres equals SStotal, calculated from the observed responses.
Worked example
Consider the data and , fitted by a simple linear regression with an intercept. The least-squares line is
The observed response mean is . The fitted values and residuals are:
| Observed | Fitted | Residual | |
|---|---|---|---|
| 1 | 2 | 2.3 | -0.3 |
| 2 | 3 | 3.1 | -0.1 |
| 3 | 5 | 3.9 | 1.1 |
| 4 | 4 | 4.7 | -0.7 |
For the regression sum of squares, compare each fitted value with :
For the residual sum of squares, square and add the residuals:
The total sum of squares from the observed responses is
The identity checks: . In this example, the coefficient of determination is . So the fitted model accounts for 64% of the observed variation around the response mean, under this standard definition of .
Why the sums add up
For least squares with an intercept, residuals sum to zero and are orthogonal to the fitted values. Since , squaring and summing gives the total as the sum of the fitted-value variation and residual variation; the cross-product term is zero. This is why the identity holds for this model.
For a model with linearly independent predictors and an intercept, the usual regression degrees of freedom are , and the residual degrees of freedom are . Dividing SSreg and SSres by their respective degrees of freedom gives the regression and residual mean squares. These mean squares are different quantities from the sums of squares themselves.
Common mistakes
- Using observed values in the wrong sum: SSreg uses fitted values relative to ; SSres uses observed minus fitted values.
- Forgetting to square: Residuals can be positive or negative. Squaring prevents them from canceling out.
- Confusing sums with mean squares: Do not divide by degrees of freedom unless you are specifically asked for a mean square.
- Assuming the identity always applies: The standard centered decomposition assumes an ordinary least-squares fit with an intercept. In a regression through the origin, the residuals need not sum to zero, and the centered identity may fail. Some software reports an uncentered for such models, so check its convention.
- Mixing up abbreviations: State the defining formula, especially when comparing results from different books or software.
References
- Introduction to Linear Regression Analysis, Douglas C. Montgomery, Elizabeth A. Peck, and G. Geoffrey Vining
- Applied Linear Statistical Models, Michael H. Kutner, Christopher J. Nachtsheim, John Neter, and William Li
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.