F-Test
Calculate a nested-model F-test for the joint significance of the regressors in unrestricted_independent_tickers that are not already in restricted_independent_tickers.
Also known as: nested F-test, restricted vs. unrestricted F-test, partial F-test.
Fits both a “restricted” and an “unrestricted” OLS regression of dependent_ticker internally (via regression_model.get_ols) and compares them. For more information about the method, see hypothesis_testing_model.get_f_test.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the F-Test for you. Just ask in plain English.
Calculate the F-Test in Python
The F-Test is available in the Econometrics module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_f_test as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
toolkit.econometrics.get_f_test(
"AAPL", "MSFT", ["MSFT", "Benchmark"], period="weekly"
)
Which returns:
| Metric | Value |
|---|---|
| F-Statistic | 43.6897 |
| Df Numerator | 1 |
| Df Denominator | 154 |
| P-Value | 0.0000 |
| Reject Restrictions (5%) | 1 |
Parameters
get_f_test accepts the following parameters:
- dependent_ticker (str): The dependent (predicted) asset.
- restricted_independent_tickers (str | list[str]): The independent asset(s) in the restricted (smaller) model.
- unrestricted_independent_tickers (str | list[str]): The independent asset(s) in the
unrestricted (larger) model – must be a superset of
restricted_independent_tickers. - period (str, optional): The data frequency (daily, weekly, monthly, quarterly, or yearly). Defaults to “daily”.
- column (str, optional): The historical data column to regress on. Defaults to “Return”.
- add_constant (bool, optional): Whether to include an intercept in both models. Defaults to True.
- rounding (int | None, optional): The number of decimals to round the results to. Defaults to None.
Related Hypothesis Tests
The Econometrics module page introduces the module, and the sidebar lists all of its functions.