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, andargscan 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) andoptimal_bw(bool) for “kernel”, andclusters(array_like) for “clustered”. The names of the kernels are not case sensitive. SeeIVGMMCovariancefor details on the available options. Defaults are used if no covariance configuration is provided.
- starting: ndarray[tuple[int, ...], dtype[float64]] | Series | None =
- Returns:¶
Results container.
- Return type:¶
- 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
startingdoes not have one value for each regressor, and if the labels ofclustersdo not match the labels of the other inputs. A key ofcov_configthat the covariance estimator thatcov_typeselects 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 theTypeErrorof the constructor of the covariance estimator.UnknownOptionError – If
cov_typeis not supported. It is both aKeyErrorand aValueError.
See also
linearmodels.iv.gmm.IVGMMCovarianceCovariance 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:
bandwidthif it was given andnobs - 2ifoptimal_bwis 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 usednobs - 2wheneverbandwidthwas not given, and the bandwidth that was estimated from the data was estimated again at every evaluation of the objective function.If
cov_typeis “kernel” and neitherbandwidthnoroptimal_bwis incov_config, the bandwidth of the covariance is estimated from the data, from the residuals of the final estimates. In 7.0 and earlier it wasnobs - 2.fitissues aDefaultBandwidthWarning(aUserWarning) once for each call when the covariance, or the kernel weight matrix of the model, uses the default bandwidth. To restore the previous covariance, passoptimal_bw=Falseorbandwidth=nobs - 2incov_config, for examplefit(cov_type="kernel", optimal_bw=False). Passingbandwidthoroptimal_bwsilences the warning, andoptimal_bw=Trueselects 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
bandwidthoroptimal_bw=Falseto use the kernel with fewer observations. Seekernel_optimal_bandwidth().