linearmodels.iv.model.IVGMMCUE.fit

IVGMMCUE.fit(*, starting: ndarray[tuple[int, ...], dtype[float64]] | Series | None = None, display: bool = False, cov_type: str = 'robust', debiased: bool = False, opt_options: dict[str, Any] | None = None, **cov_config: Any) → OLSResults | IVGMMResults[source]

Estimate model parameters.

Parameters:
starting: ndarray[tuple[int, ...], dtype[float64]] | Series | None = None

Starting values to use in optimization, with one value for each regressor. If not provided, the estimates of IVGMM are used. See Notes.

display: bool = False

Flag indicating whether to display optimization output. The default is False.

cov_type: str = 'robust'

Name of covariance estimator to use. The default is “robust”. The names are not case sensitive. Supported covariance estimators are:

  • ”unadjusted”, “homoskedastic” - Assumes moment conditions are homoskedastic

  • ”robust”, “heteroskedastic” - Allows for heteroskedasticity but not autocorrelation

  • ”kernel” - Allows for heteroskedasticity and autocorrelation

  • ”clustered” - Allows for one-way cluster dependence

debiased: bool = False

Flag indicating whether to debias the covariance estimator using a degree of freedom adjustment. The default is False.

opt_options: dict[str, Any] | None = None

Additional options to pass to scipy.optimize.minimize when optimizing the objective function. If not provided, defers to scipy to choose an appropriate optimizer. All minimize inputs except fun, x0, and args can be overridden.

**cov_config: Any

Additional parameters to pass to the covariance estimator. The keys are center (bool) for every covariance estimator, kernel (str), bandwidth (int) and optimal_bw (bool) for “kernel”, and clusters (array_like) for “clustered”. The names of the kernels are not case sensitive. See IVGMMCovariance for details on the available options. Defaults are used if no covariance configuration is provided.

Returns:

Results container.

Return type:

linearmodels.iv.results.IVGMMResults

Raises:
  • ValueError – If the covariance of the moment conditions is singular, which occurs if there are too few clusters or observations, or if the moment conditions are not centered and there are as many clusters as moment conditions, so that the objective function is constant. The number of clusters has to be larger than the number of moment conditions. The error is also raised if the bandwidth of a kernel weight matrix or of the kernel covariance is estimated from the data and there are fewer observations than the kernel needs, or the estimated bandwidth is not finite, if starting does not have one value for each regressor, and if the labels of clusters do not match the labels of the other inputs. A key of cov_config that the covariance estimator that cov_type selects does not accept also raises it. The message names the key and lists the accepted keys. This is checked before the model is estimated. Releases before 7.1 raised the TypeError of the constructor of the covariance estimator.

  • UnknownOptionError – If cov_type is not supported. It is both a KeyError and a ValueError.

See also

linearmodels.iv.gmm.IVGMMCovariance

Covariance estimation for GMM models.

Notes

Starting values are computed by IVGMM with the weight type and configuration of the model. A kernel weight matrix has the bandwidth of the objective function: bandwidth if it was given and nobs - 2 if optimal_bw is False. Otherwise the bandwidth is estimated from the data, once, from the residuals of the first step estimates, which are the first step of IVGMM too. The same bandwidth is used for the starting values, for every evaluation of the objective function and for the weight matrix of the estimates, so that the objective function is smooth in the parameters. In 7.0 and earlier the starting values used nobs - 2 whenever bandwidth was not given, and the bandwidth that was estimated from the data was estimated again at every evaluation of the objective function.

If cov_type is “kernel” and neither bandwidth nor optimal_bw is in cov_config, the bandwidth of the covariance is estimated from the data, from the residuals of the final estimates. In 7.0 and earlier it was nobs - 2. fit issues a DefaultBandwidthWarning (a UserWarning) once for each call when the covariance, or the kernel weight matrix of the model, uses the default bandwidth. To restore the previous covariance, pass optimal_bw=False or bandwidth=nobs - 2 in cov_config, for example fit(cov_type="kernel", optimal_bw=False). Passing bandwidth or optimal_bw silences the warning, and optimal_bw=True selects the bandwidth from the data without it.

The bandwidth that is estimated from the data needs at least 4 observations with the Bartlett kernel, 5 with the Parzen kernel and 6 with the quadratic spectral kernel. Pass bandwidth or optimal_bw=False to use the kernel with fewer observations. See kernel_optimal_bandwidth().