Skip to content

DPredict · Guide test 005

Partial F test or extra sum of squares test

Tests several restrictions together by comparing nested linear models.

Runs in CodeSplashPython example validatedR example validated

Do it in CodeSplash

In the app, set it up in Analyze with one of these methods:

In Compare nested models (LR, Wald, score, partial F), choose Model = Linear (numeric outcome).

Do it in CodeSplash Run this test on your own data, in Python or R.

Bench

Change the design, drag the data, move α. The statistic, its reference distribution and the verdict follow.

Bench · Partial F test (extra sum of squares)

40
0.30
0.080

Adds curve × (x − 5)².

0.00

Error SD grows like exp(h · (x − 5)/5).

0.00

Errors in collection order carry φ × the previous error.

0.00
0.050

Your data

Simulated with a known ρ

If H₀ were true

F = 20.59
  1. The reference: how F varies across samples when H₀ is true.
  2. Your statistic, from the data above.
  3. The p-value: the area at least as extreme as yours (p = < .001).
  4. The hatched rejection region at α = .050: statistics landing here reject H₀.

The formula

F=(RSS0−RSS1)/qRSS1/(n−p1)F = \dfrac{(\mathrm{RSS}_0-\mathrm{RSS}_1)/q}{\mathrm{RSS}_1/(n-p_1)}

With your numbers

F=(65.56−42.12)/142.12/37=20.59F = \dfrac{(65.56-42.12)/1}{42.12/37} = 20.59
RSS0, RSS1\mathrm{RSS}_0,\ \mathrm{RSS}_1
residual sums of squares of the nested and full models
qq
number of added terms
n−p1n-p_1
residual degrees of freedom of the full model

The verdict

F(1, 37) = 20.59, p < .001

p ≤ α = .050: reject H₀

Nested models only: the full model must contain the reduced one. The F compares the drop in error per added term with the remaining error per degree of freedom.

Statistic
20.592
p-value
0.0001
Partial F test (extra sum of squares) on 40 (x, y) pairs: F(1, 37) = 20.59, p < .001. The p-value is below α = .050, so the data are hard to reconcile with H0.

Partial F test (extra sum of squares) on 40 (x, y) pairs: F(1, 37) = 20.59, p < .001. The p-value is below α = .050, so the data are hard to reconcile with H₀.

Question and hypotheses

H0: q additional linear restrictions hold; H1: at least one fails.

Assumptions

Restricted and full linear models use the same response, observations, and weights. Exact F inference requires independent normal errors with common variance and full rank nested designs.

Formula

F=(RSS0−RSS1)/qRSS1/(n−p1)∼Fq,n−p1F=\frac{(\mathrm{RSS}_0-\mathrm{RSS}_1)/q}{\mathrm{RSS}_1/(n-p_1)}\sim F_{q,n-p_1}

Parameters and notation

RSS0 and RSS1 are restricted and full residual sums of squares; p1 is the full model coefficient count; q=p1−p0.

Structure of the method

Two nested least-squares projection spaces produce restricted and full residual sums of squares. Their difference, divided by independent restriction count, is compared with the full model's residual mean square. Gaussian orthogonal projection results justify the exact F numerator and denominator degrees of freedom.

Estimated and nuisance parameters

Each model estimates its coefficients, while the full model provides the common residual variance estimate. Effective model ranks determine parameter counts. The tested contrast subspace and restriction count are design quantities; an intercept contributes one fitted coefficient when present and estimable.

Settings and design choices

Prespecify the larger model, restrictions, observation mask, weights, and alpha. Model-order searches such as trying many polynomial degrees create an additional selection problem. If heteroskedastic covariance is used, state that the resulting robust Wald/F procedure is not automatically the same exact extra-sum-of-squares test.

Fitting and adaptation

Refit restricted and full models to a common complete-case dataset whenever predictors change. For one restriction, verify agreement with the square of the corresponding classical t statistic as a useful consistency check. Bootstrap methods must reproduce the fitted null and the original sampling or dependence structure.

Sensitivity and robustness

Different response transformations, incompatible weights, nonnested designs, penalized fits, or different rows invalidate the ordinary RSS comparison. Small residual degrees of freedom amplify instability. Under heteroskedasticity, raw RSS improvement may remain descriptive but its nominal F tail need not be correctly calibrated.

How to use and calibrate

Fit both models, calculate the improvement per added degree of freedom relative to residual noise, and take the upper F tail. One restriction yields the square of its corresponding t statistic.

Example application

Compare a straight line model with a cubic polynomial by jointly testing the quadratic and cubic coefficients, using q=2.

Interpretation and pitfalls

Watch out

Fitting models to different complete case subsets makes RSS comparisons invalid. The standard F reference does not automatically survive heteroskedasticity, clustering, or penalization.

What changed in edition 2

  • New sections: structure of the method, estimated and nuisance parameters, settings and design choices, fitting and adaptation, sensitivity and robustness.

Python and R

Exact F reference requires the Gaussian homoskedastic linear model.

Python · native

Validated — Executed successfully in the validation environment · needs numpy, scipy, statsmodels

import numpy as np
from scipy import stats
rng = np.random.default_rng(2026)
import statsmodels.api as sm
n=100
x=rng.normal(size=n); z=rng.normal(size=n); y=1+.5*x+.3*z+rng.normal(size=n)
X=sm.add_constant(np.column_stack([x,z])); fit=sm.OLS(y,X).fit(); reduced=sm.OLS(y,X[:,:2]).fit()
print(fit.compare_f_test(reduced))
Output
(np.float64(5.342011272107043), np.float64(0.022934169379552387), np.float64(1.0))
R

Validated — Executed successfully in the validation environment · needs Base/standard library

set.seed(2026)
n <- 100; x <- rnorm(n); z <- rnorm(n); y <- 1+.5*x+.3*z+rnorm(n)
d <- data.frame(y,x,z); fit <- lm(y~x+z,data=d); reduced <- lm(y~x,data=d)
print(anova(reduced,fit))
Output
Analysis of Variance Table

Model 1: y ~ x
Model 2: y ~ x + z
  Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
1     98 88.130                                  
2     97 76.864  1    11.266 14.218 0.0002799 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Sources

Statistics guide v4 (historical):
Python: Executed successfully in the validation environment · R: Executed successfully in the validation environment
Reference's record:
Edition 2 review: Python: skip · R: not executed (Rscript unavailable); why not run: Python: Unavailable local dependencies: statsmodels. Python: Not run in the reference's review: Unavailable local dependencies: statsmodels. No installation attempted. R: Reviewed but not run: R wasn't available to the reference's authors.

From the CodeSplash statistics guide (v4), entry 005, updated from the reference's edition 2 (reviewed 14 November 2026) as STAT005.