linearmodels.iv.results.OLSResults.wald_test

OLSResults.wald_test(restriction: DataFrame | ndarray | None = None, value: Series | ndarray | None = None, *, formula: str | list[str] | dict[str, float] | None = None) WaldTestStatistic

Test linear equality constraints using a Wald test

Parameters:
restriction: DataFrame | ndarray | None = None

q by nvar array containing linear weights to apply to parameters when forming the restrictions. It is not possible to use both restriction and formula.

value: Series | ndarray | None = None

q element array containing the restricted values.

formula: str | list[str] | dict[str, float] | None = None

formulaic linear constraints. The simplest formats are one of:

  • A single comma-separated string such as “x1=0, x2+x3=1”

  • A list of strings where each element is a single constraint such as [“x1=0”, “x2+x3=1”]

  • A single string without commas to test simple constraints such as “x1=x2=x3=0”

  • A dictionary where each key is a parameter restriction and the corresponding value is the restriction value, e.g., {“x1”: 0, “x2+x3”: 1}.

It is not possible to use both restriction and formula.

Returns:

Test statistic for null that restrictions are valid.

Return type:

linearmodels.shared.hypotheses.WaldTestStatistic

Notes

Hypothesis test examines whether \(H_0:C\theta=v\) where the matrix C is restriction and v is value. The test statistic has a \(\chi^2_q\) distribution where q is the number of rows in C.

Examples

>>> import numpy as np
>>> from linearmodels.datasets import wage
>>> from linearmodels.iv import IV2SLS
>>> data = wage.load()
>>> formula = "np.log(wage) ~ 1 + exper + I(exper**2) + brthord + [educ ~ sibs]"
>>> res = IV2SLS.from_formula(formula, data).fit()

Testing the experience is not needed in the model

>>> restriction = np.array([[0, 1, 0, 0, 0],
...                         [0, 0, 1, 0, 0]])
>>> value = np.array([0, 0])
>>> wald_res = res.wald_test(restriction, value)

Using the formula interface to test the same restrictions

>>> formula = "exper = I(exper**2) = 0"
>>> wald_res = res.wald_test(formula=formula)

Using the formula interface with a list

>>> wald_res = res.wald_test(formula=["exper = 0", "I(exper**2) = 0"])