Encompassing Test

The Encompassing Test, following the encompassing principle of Mizon and Richard (1986), asks whether the tested model encompasses the rival: whether it explains everything the rival does. It adds the rival’s own regressors that the tested model lacks and tests them jointly with an F-test, against an artificial model that nests both.

The formula for the Encompassing Test regresses the dependent series on the regressors of model A and those of model B that model A does not have, by OLS:

\[y = X_{A} \cdot a + Z_{B} \cdot b + u\]

The statistic is the F-statistic of the added regressors, comparing the residual sum of squares of model A alone with that of the combined model:

\[F = \frac{\frac{\text{SSR}_{A} - \text{SSR}}{q}}{\frac{\text{SSR}}{n - k}}\]

Where y is the dependent series, \(X_{A}\) the regressors of model A with a constant, \(Z_{B}\) the regressors of model B that model A does not have, a and b their coefficients, u the error, \(\text{SSR}_{A}\) and SSR the residual sums of squares of model A and of the combined model, q the number of columns of \(Z_{B}\), n the number of observations and k the number of parameters of the combined model. F is F(q, n - k) distributed under the null that model A encompasses model B: model A is rejected when the p-value is below the significance level (0.05 for the 5% level). With many added regressors it loses power compared with the J Test, which adds only one.

Two explanations of the same returns, such as a sector ETF against the market, or one factor set against another, cannot be compared with an F-test when neither model is a special case of the other: the models are non-nested. A non-nested test takes one model as the null hypothesis and asks whether the other model explains something it misses, the alternative. Each test is run both ways, model A against model B and model B against model A. Rejecting one and not the other favours the one not rejected; rejecting both says each misses something the other has, and rejecting neither says the data cannot tell them apart. Unlike an information criterion, the tests can reject both models.

Also known as: encompassing F-test, artificial nesting test.

In the Finance Toolkit this is get_non_nested_test with method="encompassing", the same function as Non-Nested Test.

Example · XOM, XLE · 2025

Install the Finance Toolkit with pip install financetoolkit -U, then call get_non_nested_test:

from financetoolkit import Toolkit

toolkit = Toolkit(
    ["XOM", "XLE"],
    api_key="FINANCIAL_MODELING_PREP_KEY",
    start_date="2025-01-01",
    end_date="2025-12-31",
)

# XOM explained by XLE (model A) or by the benchmark SPY (model B)
toolkit.econometrics.get_non_nested_test(method="encompassing")

Which returns:

Using Your Own Data

get_non_nested_test runs on any data, not only prices: ratios, economic indicators, yield curves or your own dataset. Pass a DataFrame, a Series or a dictionary of them to Econometrics as data, with the dates in the rows or the columns, and set changes to how its changes are calculated: "percentage", "log", "difference" for rates and ratios, or None when the data are changes already. For example, for the monthly unemployment rates of the United States and Germany:

from financetoolkit import Economics, Econometrics

economics = Economics(start_date="2000-01-01")

unemployment = economics.get_unemployment_rate(
    countries=["United States", "Germany"], period="monthly"
)

econometrics = Econometrics(data=unemployment, changes="difference")

econometrics.get_non_nested_test()

References

  • Paper Mizon, G.E. and Richard, J.-F. (1986). “The Encompassing Principle and its Application to Testing Non-Nested Hypotheses.” Econometrica, 54(3), 657-678.
  • Library Referenced against statsmodels’ compare_encompassing (Encompassing Test)
Share