Wald Test
Calculate a Wald test of q general linear restriction(s) on the coefficients of an OLS regression of dependent_ticker on independent_tickers.
Also known as: Wald chi-squared test.
Fits a single OLS regression internally (via regression_model.get_ols) and tests H0: restriction_matrix @ beta = restriction_values on its coefficients. For more information about the method, see hypothesis_testing_model.get_wald_test.
No programming experience? With the Finance Toolkit MCP server, AI assistants such as Claude and ChatGPT can calculate the Wald Test for you. Just ask in plain English.
Calculate the Wald Test in Python
The Wald Test is available in the Econometrics module of the open-source Finance Toolkit. Install it with:
pip install financetoolkit -U
Then call get_wald_test as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(["AAPL", "MSFT"], api_key="FINANCIAL_MODELING_PREP_KEY")
# H0: the coefficients on both MSFT and Benchmark are jointly zero.
toolkit.econometrics.get_wald_test(
restriction_matrix=[[0, 1, 0], [0, 0, 1]],
independent_tickers=["MSFT", "Benchmark"],
period="weekly",
)
Which returns:
| Metric | Value |
|---|---|
| Wald Statistic (Chi2) | 314.2908 |
| Chi2 P-Value | 0.0000 |
| F-Statistic | 157.1454 |
| F P-Value | 0.0000 |
| Restrictions (q) | 2 |
| Reject Restrictions (5%) | 1 |
Parameters
get_wald_test accepts the following parameters:
- restriction_matrix (pd.DataFrame | np.ndarray): The
(q, k)restriction matrixR, one row per restriction, one column per coefficient in the same order asadd_constant(if True, “Intercept” first) followed by the independent ticker(s). - dependent_ticker (str | None, optional): The dependent (predicted) asset. Defaults to None, meaning the Toolkit instance’s first ticker.
- independent_tickers (str | list[str] | None, optional): The independent
(predictor) asset(s), in the order the restriction matrix’s columns
(after “Intercept”, if
add_constant) refer to them. Defaults to None, meaning every other ticker in the Toolkit instance besidesdependent_ticker. - include_benchmark (bool, optional): Whether to include “Benchmark” in the default independent ticker(s) (has no effect when independent_tickers is given explicitly). Defaults to False.
- restriction_values (pd.Series | np.ndarray | None, optional): The length-
qvector of hypothesized values. Defaults to None, i.e. all restrictions equal zero. - 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. 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.