Sub topic 14
Explained and Unexplained Variation: R-squared, SEE, and the ANOVA Table
This chapter assumes you can compute a mean and a variance, and that you have estimated a simple regression line by ordinary least squares (OLS), so you already have an intercept b0, a slope b1, and fitted values. It also assumes you know what a t-test and a critical value are. Here you measure how well that line fits.
The idea: split the variation in Y
A regression tries to explain why the dependent variable Y moves around its mean. Each observation sits some distance from the mean of Y. Part of that distance is captured by the regression line, and the rest is left over.
For observation i, the deviation from the mean splits into two pieces:
- Explained part: the fitted value minus the mean,
ŷᵢ − ȳ. - Unexplained part: the residual,
yᵢ − ŷᵢ.
Square each piece and add across all observations. For OLS with an intercept, the cross-terms cancel, so the pieces add up exactly.
| Quantity | Name | Formula | Meaning |
|---|---|---|---|
| SST | Total sum of squares | Σ(yᵢ − ȳ)² | Total variation in Y |
| SSR (also called RSS) | Regression sum of squares | Σ(ŷᵢ − ȳ)² | Variation explained by X |
| SSE | Sum of squared errors | Σ(yᵢ − ŷᵢ)² | Variation left unexplained |
The identity is SST = SSR + SSE.
Be careful with notation. Some textbooks call the explained sum of squares "ESS" and the residual sum of squares "RSS". The CFA curriculum uses SSR for regression (explained) and SSE for error (unexplained). Always check which meaning a source uses before plugging in numbers.
R-squared
The coefficient of determination is the fraction of total variation that the regression explains:
R² = SSR / SST = 1 − SSE / SST
It runs from 0 to 1. An R² of 0.75 means that 75% of the variation in Y is explained by X.
In a simple regression with one independent variable, R² equals the squared sample correlation: R² = r². The converse needs care. Taking the square root gives |r|, and the sign of r is the sign of the slope.
R² has limits:
- It says nothing about whether the slope is statistically significant, although in simple regression a high R² usually accompanies a significant slope.
- It does not show whether the model is correctly specified. A strongly curved relationship can still give a decent R² with a straight line.
- A few extreme observations can inflate or deflate it.
Standard error of estimate (SEE)
R² is unitless. The standard error of estimate is in the units of Y. It measures the typical size of a residual:
SEE = √( SSE / (n − 2) ) = √MSE
The divisor is n − 2 because two parameters, the intercept and the slope, were estimated from the data. A smaller SEE means the points cluster more tightly around the line. SEE is also the building block for the standard error of the slope and for prediction intervals, which later chapters cover.
The ANOVA table
ANOVA stands for analysis of variance. The table organizes the sums of squares, their degrees of freedom, and the resulting mean squares.
| Source | df | Sum of squares | Mean square |
|---|---|---|---|
| Regression | 1 | SSR | MSR = SSR / 1 |
| Error | n − 2 | SSE | MSE = SSE / (n − 2) |
| Total | n − 1 | SST |
The regression has 1 degree of freedom because there is one slope. The total has n − 1 because the mean of Y was used to center the data. The degrees of freedom add up: 1 + (n − 2) = n − 1.
The F-statistic
F = MSR / MSE = SSR / (SSE / (n − 2))
This tests H0: the slope is 0 against Ha: the slope is not 0. Under H0, F follows an F-distribution with 1 numerator and n − 2 denominator degrees of freedom. Reject H0 when F exceeds the critical value.
Two points matter in practice:
- The F-test for a regression is always a one-tailed (right-tail) test, because large F means more explained variation.
- In simple regression, F equals the square of the slope's t-statistic: F = t². The two tests give the same decision. With several independent variables this equivalence no longer holds.
Worked example by hand
Suppose a regression of a fund's returns on a market index uses n = 32 monthly observations. The ANOVA output shows SSR = 180 and SSE = 60.
- SST = 180 + 60 = 240.
- R² = 180 / 240 = 0.75, so the correlation magnitude is √0.75 ≈ 0.866.
- MSE = 60 / (32 − 2) = 2.0, so SEE = √2 ≈ 1.414 (in percentage points).
- MSR = 180 / 1 = 180, so F = 180 / 2 = 90.
At the 5% level, the critical F for 1 and 30 degrees of freedom is about 4.17. Since 90 is far larger, you reject H0 and conclude the slope differs from zero. The implied slope t-statistic is √90 ≈ 9.49.
The same calculation in code
This script fits the line from the previous chapter's formulas and then builds every ANOVA quantity. It uses five points that lie close to a straight line.
import numpy as np
x = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
y = np.array([2.1, 3.9, 6.2, 7.8, 10.1])
n = len(x)
b1 = np.cov(x, y, ddof=1)[0, 1] / np.var(x, ddof=1)
b0 = y.mean() - b1 * x.mean()
y_hat = b0 + b1 * x
sst = ((y - y.mean()) ** 2).sum()
sse = ((y - y_hat) ** 2).sum()
ssr = sst - sse
r_squared = ssr / sst
see = np.sqrt(sse / (n - 2))
f_stat = ssr / (sse / (n - 2))
print(b0, b1, r_squared, see, f_stat)The output is approximately b0 = 0.05, b1 = 1.99, R² = 0.9973, SEE = 0.189, and F = 1110. Here SST ≈ 39.708, SSR ≈ 39.601, and SSE ≈ 0.107. The line explains almost all the variation, the typical residual is about 0.19 units of Y, and F is enormous relative to any critical value for 1 and 3 degrees of freedom.
Common errors
- Dividing SSE by
norn − 1instead ofn − 2when computing SEE. - Using
n − 1as the denominator degrees of freedom for F. It isn − 2. - Reading R² as the correlation. R² is r², so a correlation of 0.5 gives an R² of only 0.25.
- Treating a high R² as proof that X causes Y or that the model is well specified.
- Mixing up SSR and SSE when a source defines "RSS" as the residual sum of squares.
- Comparing the F-statistic to a two-tailed critical value.
Reading package output
Statistical packages print these same pieces under different labels. "Multiple R" is |r|. "R Square" is R². "Standard Error" in a regression summary is usually SEE, not the standard error of a coefficient, so check the context. The "Significance F" value in spreadsheet output is the p-value of the F-test. A "Residual" row is the error row, and "MS" columns are the mean squares.
Exercise
A simple regression on 22 observations has SST = 500 and R² = 0.64. Find SSR, SSE, SEE, and F, and state whether you reject H0: slope = 0 at the 5% level if the critical F for 1 and 20 degrees of freedom is about 4.35.
Show answer
SSR = 0.64 × 500 = 320 and SSE = 500 − 320 = 180. The error degrees of freedom are 22 − 2 = 20, so MSE = 180 / 20 = 9 and SEE = √9 = 3. MSR = 320, so F = 320 / 9 ≈ 35.6. Since 35.6 > 4.35, reject H0 and conclude the slope is significantly different from zero.
Exercise
In a simple regression, the slope's t-statistic is 4.0 with 18 degrees of freedom. What is the F-statistic, and how many numerator and denominator degrees of freedom does it have?
Show answer
In simple regression F = t², so F = 16. The F-statistic has 1 numerator degree of freedom and 18 denominator degrees of freedom, which equals n − 2 with n = 20.