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.

Wald Test in Python

get_wald_test is part of 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 matrix R, one row per restriction, one column per coefficient in the same order as add_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 besides dependent_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-q vector 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.
Share