Sub topic 14
Explained and Unexplained Variation: R-Squared, SEE, and the ANOVA Table
Assume you know the mean, variance, standard deviation, and basic algebra of straight lines. This chapter uses those ideas to evaluate a simple linear regression.
The variation in the dependent variable
Suppose we model a fund’s return, \(y\), using a market return, \(x\):
\hat{y}_i = b_0 + b_1x_iThe observed value \(yi\) can differ from both the sample mean \(\bar{y}\) and the fitted value \(\hat{y}i\). Regression separates the total variation in \(y\) into two parts:
- Total sum of squares (SST): total variation around the mean.
- Explained sum of squares (SSR): variation explained by the regression.
- Residual sum of squares (SSE): unexplained variation left in the residuals.
The identity is:
SST = SSR + SSEA residual is \(ei = yi - \hat{y}_i\). Therefore:
SST=\sum(y_i-\bar{y})^2SSR=\sum(\hat{y}_i-\bar{y})^2SSE=\sum(y_i-\hat{y}_i)^2R-squared and standard error of estimate
R-squared measures the fraction of total variation explained by the regression:
R^2=\frac{SSR}{SST}=1-\frac{SSE}{SST}An \(R^2\) of 0.64 means that 64% of the sample variation in \(y\) is explained by \(x\). It does not prove that \(x\) causes \(y\), and a high \(R^2\) does not guarantee accurate forecasts.
The standard error of estimate (SEE) measures the typical size of a residual:
SEE=\sqrt{\frac{SSE}{n-2}}The \(n-2\) denominator applies to simple regression because two parameters, the intercept and slope, are estimated.
The ANOVA table and F-test
The analysis of variance (ANOVA) table organizes the decomposition.
| Source | Sum of squares | Degrees of freedom | Mean square |
|---|---|---|---|
| Regression | SSR | 1 | \(MSR=SSR\) |
| Error | SSE | \(n-2\) | \(MSE=SSE/(n-2)\) |
| Total | SST | \(n-1\) | Not usually reported |
The overall F-statistic tests whether the regression explains a statistically significant amount of variation:
F=\frac{MSR}{MSE}
=\frac{SSR}{SSE/(n-2)}For simple regression, this tests \(H0:b1=0\) against \(Ha:b1\ne0\). A large F-statistic provides evidence that the slope is not zero.
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(f"R-squared: {r_squared:.4f}")
print(f"SEE: {see:.4f}")
print(f"F-statistic: {f_stat:.4f}")Exercise
A regression has SST = 250, SSE = 100, and n = 12. Compute SSR, R-squared, SEE, and the F-statistic.
Show answer
SSR = 250 - 100 = 150. R-squared = 150/250 = 0.60. SEE = sqrt(100/10) = 3.16. F = 150/(100/10) = 15.