Sub topic 5
Testing coefficients jointly: the F-test and ANOVA table
This chapter assumes you can read a t-test on a single slope coefficient and know what R-squared means. It also assumes you know the partial slope idea from the multiple regression model. A t-test checks one coefficient at a time. The F-test checks several coefficients together, or all of them at once.
Why one t-test is not enough
Suppose a model has four independent variables. You could run four t-tests, one per slope. That approach has two problems.
- Each test at the 5% level has a 5% chance of a false rejection. Across several tests, the chance that at least one slope looks significant by luck is higher than 5%.
- Independent variables that are correlated share explanatory power. Each t-test can then look weak while the group is clearly useful together.
The F-test answers one question with one decision rule: do these coefficients, taken as a group, help explain the dependent variable?
The ANOVA table
ANOVA stands for analysis of variance. The table splits the variation in the dependent variable into the part the model explains and the part it leaves over. Here n is the number of observations and k is the number of independent variables.
| Source | Degrees of freedom | Sum of squares | Mean square |
|---|---|---|---|
| Regression | k | RSS (explained) | MSR = RSS / k |
| Error (residual) | n - k - 1 | SSE (unexplained) | MSE = SSE / (n - k - 1) |
| Total | n - 1 | SST = RSS + SSE |
A mean square is a sum of squares divided by its degrees of freedom, so it is a variance estimate. The CFA curriculum calls the explained sum of squares "RSS" (regression sum of squares). Many software packages call it ESS, and they use "RSS" or "SSR" for the residual sum of squares. Check the labels before copying a number from software output.
Three quantities come straight from the table:
- R-squared = RSS / SST.
- Standard error of estimate = the square root of MSE.
- F = MSR / MSE.
The overall F-test
The overall F-test checks whether the model explains anything.
- H0: b1 = b2 = ... = bk = 0. The intercept is not included.
- Ha: at least one slope is different from zero.
The statistic is F = MSR / MSE. It follows an F distribution with k numerator degrees of freedom and n - k - 1 denominator degrees of freedom. The test is one-tailed. A large F means the explained variance is large compared with the unexplained variance, so you reject H0 only when F exceeds the critical value in the upper tail.
Worked example: reading an ANOVA table
A model with k = 3 variables is fitted on n = 100 observations. The table gives RSS = 60 and SSE = 40, so SST = 100.
- Degrees of freedom: regression 3, error 100 - 3 - 1 = 96, total 99.
- MSR = 60 / 3 = 20. MSE = 40 / 96 = 0.4167.
- F = 20 / 0.4167 = 48.
- The 5% critical value for F with (3, 96) degrees of freedom is about 2.70. Since 48 is far above it, reject H0.
- R-squared = 60 / 100 = 0.60. The standard error of estimate is the square root of 0.4167, which is about 0.645.
You can also compute F from R-squared alone:
F = (R² / k) / ((1 - R²) / (n - k - 1))
Check it: (0.60 / 3) / (0.40 / 96) = 0.20 / 0.004167 = 48. This form is useful on the exam when a question gives you R², n and k but no sums of squares.
Testing a subset of coefficients
The overall test checks all slopes. Often you want to check only some of them. For example, you may ask whether two added variables improve a model that already has two others. This is a joint test on q restrictions, where q is the number of coefficients set to zero in H0.
You estimate two models on the same data and the same dependent variable:
- The unrestricted model contains all k variables.
- The restricted model drops the q variables named in H0.
The statistic is:
F = [(SSErestricted - SSEunrestricted) / q] / [SSE_unrestricted / (n - k - 1)]
Here k is the number of independent variables in the unrestricted model. The degrees of freedom are q for the numerator and n - k - 1 for the denominator. The logic is straightforward. Dropping useful variables raises the unexplained variation. If the rise in SSE per restriction is large compared with the unrestricted model's own error variance, the dropped variables mattered.
Worked example: two added variables
An analyst has n = 60 observations. The unrestricted model has k = 4 variables and SSE = 120. The restricted model drops 2 of them and has SSE = 140.
- q = 2, and the denominator degrees of freedom are 60 - 4 - 1 = 55.
- Numerator: (140 - 120) / 2 = 10.
- Denominator: 120 / 55 = 2.182.
- F = 10 / 2.182 = 4.58.
- The 5% critical value for (2, 55) degrees of freedom is about 3.16. Since 4.58 is larger, reject H0. At least one of the two dropped variables belongs in the model.
When both models share the same dependent variable, you can write the same test with R-squared values:
F = [(R²unrestricted - R²restricted) / q] / [(1 - R²_unrestricted) / (n - k - 1)]
This form works only when both regressions use the same dependent variable and the same sample. If the dependent variable is transformed in one model, for example y versus log y, the sums of squares are on different scales and the comparison is invalid.
Running the test in Python
The code below fits a model with two real variables (x1, x2) and two pure-noise variables (x3, x4). It tests x3 and x4 jointly in two ways: by hand from the restricted and unrestricted fits, and with the built-in f_test method. Both give the same F statistic.
import numpy as np
import statsmodels.api as sm
rng = np.random.default_rng(42)
n = 200
x1 = rng.normal(size=n)
x2 = rng.normal(size=n)
x3 = rng.normal(size=n)
x4 = rng.normal(size=n)
y = 1.0 + 2.0 * x1 - 1.0 * x2 + rng.normal(size=n)
X_full = sm.add_constant(np.column_stack([x1, x2, x3, x4]))
X_restricted = sm.add_constant(np.column_stack([x1, x2]))
full = sm.OLS(y, X_full).fit()
restricted = sm.OLS(y, X_restricted).fit()
# Overall F-test, rebuilt from the ANOVA pieces
k = 4
msr = full.ess / k
mse = full.ssr / (n - k - 1)
print("Overall F by hand:", msr / mse, " reported:", full.fvalue)
# Joint test that the coefficients on x3 and x4 are both zero
q = 2
f_manual = ((restricted.ssr - full.ssr) / q) / (full.ssr / (n - k - 1))
print("Subset F by hand:", f_manual)
R = np.array([[0, 0, 0, 1, 0],
[0, 0, 0, 0, 1]])
result = full.f_test(R)
print("Subset F from f_test:", float(result.fvalue), " p-value:", float(result.pvalue))In statsmodels, ess is the explained sum of squares (the curriculum's RSS) and ssr is the residual sum of squares (the curriculum's SSE). The matrix R has one row per restriction. Each row has a 1 in the column of a coefficient that H0 sets to zero. Column 0 is the intercept. Because x3 and x4 are noise, the subset test should usually fail to reject.
Interpreting F alongside t
The F-test and t-tests can disagree, and the disagreement is informative.
| Pattern | Likely explanation |
|---|---|
| F significant, every t insignificant | Multicollinearity. The variables overlap, so each looks weak alone while the group explains y. |
| F significant, some t significant | Normal case. At least one variable carries the explanatory power. |
| F insignificant, one t significant | Rare. Usually chance, or a sign the test assumptions are violated. Check the diagnostics. |
| F insignificant, all t insignificant | The model has no demonstrated explanatory power. |
For a single restriction (q = 1), F equals the square of the t statistic. A t of 2.5 on one coefficient gives F = 6.25 for the test that this coefficient is zero. The two tests give identical p-values in that case.
Gotchas and assumptions
- The intercept is not tested. The overall F-test checks slopes only. A model can have a significant intercept and a failed F-test.
- F cannot be negative and is one-tailed. Using a two-tailed critical value is a common exam mistake.
- F depends on the standard error assumptions. Under heteroskedasticity or serial correlation, the usual MSE-based F statistic is unreliable. Use robust versions of the test, or fix the problem first. The later chapters cover both.
- A significant F does not mean a good model. With a large n, even a tiny R² can produce a significant F. Significance says that some relationship exists, not that the model predicts well.
- Adding variables always raises R² and lowers SSE. The F-test for the added variables guards against keeping variables that only look useful because of this effect. The next chapter covers adjusted R², AIC and BIC, which penalize extra variables directly.
- Degrees of freedom use the unrestricted model. Plugging the restricted model's k into the denominator is a frequent slip.
Summary of the procedure
- State H0 as a set of coefficients equal to zero, and count the restrictions q.
- Get SSE (or R²) from the unrestricted model, and from the restricted model if testing a subset.
- Compute F with the right degrees of freedom: q and n - k - 1 for a subset test, or k and n - k - 1 for the overall test.
- Compare with the upper-tail critical value. Reject H0 if F is larger.
- Cross-check against the t-tests and the diagnostics before trusting the result.
Exercise
A regression with n = 50 observations and k = 5 independent variables has RSS = 90 and SSE = 66. (a) Compute the F statistic for the overall test. (b) The 5% critical value for (5, 44) degrees of freedom is about 2.43. What do you conclude?
Show answer
(a) MSR = 90 / 5 = 18. MSE = 66 / (50 - 5 - 1) = 66 / 44 = 1.5. F = 18 / 1.5 = 12. (b) Because 12 is larger than 2.43, reject H0 that all five slopes are zero. At least one slope differs from zero, so the model has explanatory power as a group.
Exercise
An analyst compares an unrestricted model (k = 6, SSE = 200) with a restricted model that drops 3 variables (SSE = 230), using n = 80 observations. Compute the F statistic and state its degrees of freedom.
Show answer
q = 3 and the denominator degrees of freedom are 80 - 6 - 1 = 73. Numerator: (230 - 200) / 3 = 10. Denominator: 200 / 73 = 2.740. F = 10 / 2.740 = 3.65, with (3, 73) degrees of freedom. The 5% critical value is about 2.73, so reject H0: at least one of the dropped variables is significant.
Exercise
A regression output shows a highly significant F-statistic, but none of the four slope t-statistics is significant at the 5% level. What is the most likely cause, and does the model have explanatory power?
Show answer
The most likely cause is multicollinearity. The independent variables are highly correlated, which inflates each coefficient's standard error and makes each t-statistic small. The significant F-test shows the variables jointly explain the dependent variable, so the model has explanatory power, but the individual coefficients are imprecisely estimated.