linearmodels.iv.model.IVGMM.from_formula

static IVGMM.from_formula(formula: str, data: pandas.DataFrame, *, weights: IVData | ndarray | DataArray | DataFrame | Series | None = None, weight_type: str = 'robust', **weight_config: Any) linearmodels.iv.model.IVGMM[source]
Parameters:
formula: str

Formula modified for the IV syntax described in the notes section

data: pandas.DataFrame

DataFrame containing the variables used in the formula

weights: IVData | ndarray | DataArray | DataFrame | Series | None = None

Observation weights used in estimation

weight_type: str = 'robust'

Name of moment condition weight function to use in the GMM estimation

**weight_config

Additional keyword arguments to pass to the moment condition weight function

Notes

The IV formula modifies the standard formula syntax to include a block of the form [endog ~ instruments] which is used to indicate the list of endogenous variables and instruments. The general structure is dependent ~ exog [endog ~ instruments] and it must be the case that the formula expressions constructed from blocks dependent ~ exog endog and dependent ~ exog instruments are both valid formulas.

A constant must be explicitly included using “1 +” if required.

Returns:

Model instance

Return type:

linearmodels.iv.model.IVGMM

Examples

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