linearmodels.panel.results.PanelResults.wald_test

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

Test linear equality constraints using a Wald test

Parameters:
restriction: ndarray | DataFrame | 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: ndarray | Series | None = None

q element array containing the restricted values.

formula: str | list[str] | 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

>>> from linearmodels.datasets import wage_panel
>>> import statsmodels.api as sm
>>> import numpy as np
>>> import pandas as pd
>>> data = wage_panel.load()
>>> year = pd.Categorical(data.year)
>>> data = data.set_index(["nr", "year"])
>>> data["year"] = year
>>> from linearmodels.panel import PanelOLS
>>> exog_vars = ["expersq", "union", "married", "year"]
>>> exog = sm.add_constant(data[exog_vars])
>>> mod = PanelOLS(data.lwage, exog, entity_effects=True)
>>> fe_res = mod.fit()

Test the restriction that union and married have 0 coefficients

>>> restriction = np.zeros((2, 11))
>>> restriction[0, 2] = 1
>>> restriction[1, 3] = 1
>>> value = np.array([0, 0])
>>> wald_res = fe_res.wald_test(restriction, value)

The same test using formulas

>>> formula = "union = married = 0"
>>> wald_res = fe_res.wald_test(formula=formula)