OLSResults.wald_test(restriction=None, value=None, *, formula=None)

Test linear equality constraints using a Wald test

restriction{ndarray, DataFrame}

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{ndarray, Series}

q element array containing the restricted values.

formulaUnion[str, list[str]]

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.


Test statistic for null that restrictions are valid.


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.


>>> 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"])
Return type: