linearmodels.iv.model.IV2SLS.fit¶
-
IV2SLS.fit(*, cov_type: str =
'robust', debiased: bool =False, **cov_config: Any) OLSResults | IVResults¶ Estimate model parameters.
- Parameters:¶
- 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”, “homo”, “homoskedasticcovariance” - Classic homoskedastic inference
”robust”, “heteroskedastic”, “hccm”, “heteroskedasticcovariance” - Heteroskedasticity robust inference
”kernel”, “kernelcovariance” - Heteroskedasticity and autocorrelation robust inference
”clustered”, “one-way”, “onewayclusteredcovariance” - Cluster dependent inference, which is heteroskedasticity robust. It is one-way unless
clustershas two columns.
- debiased: bool =
False¶ Flag indicating whether to debias the covariance estimator using a degree of freedom adjustment. The default is False.
- **cov_config: Any¶
Additional parameters to pass to the covariance estimator. The keys that are used depend on
cov_type. “unadjusted” and “robust” do not use any. “kernel” useskernel(str), the name of the kernel, which is “bartlett” if it is not provided, andbandwidth(int), which is selected from the data if it is not provided. The names of the kernels are not case sensitive. “clustered” usesclusters(array_like), the cluster assignment of each observation, with one or two columns. Every covariance estimator acceptsextra_df(int), the number of degrees of freedom that the model uses in addition to its regressors. It is 0 if it is not provided, and it is only used ifdebiasedis True, when the covariance is scaled by n / (n - k -extra_df), where k is the number of regressors. The keyscenterandkappaare accepted and ignored:kappais set by the model. SeeHomoskedasticCovariance,HeteroskedasticCovariance,KernelCovarianceandClusteredCovariancefor the details.
- cov_type: str =
- Returns:¶
Results container. It is an OLSResults if the model has no endogenous regressors and no instruments.
- Return type:¶
linearmodels.iv.results.IVResultsorlinearmodels.iv.results.OLSResults- Raises:¶
ValueError – If
kappais None, so that it is estimated, as inIVLIMLby default, and the estimate of \(\kappa\) is not defined. That occurs if there are fewer than 1 + the number of endogenous regressors observations more than the number of exogenous regressors and instruments, or the residuals of the dependent variable and the endogenous regressors on the exogenous regressors and instruments are collinear. See the notes ofIVLIML. It is also raised 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_typeorkernelis not supported. It is both aKeyErrorand aValueError.
See also
linearmodels.iv.covariance.HomoskedasticCovarianceHomoskedastic covariance.
linearmodels.iv.covariance.HeteroskedasticCovarianceHeteroskedasticity robust covariance.
linearmodels.iv.covariance.KernelCovarianceKernel (HAC) covariance.
linearmodels.iv.covariance.ClusteredCovarianceClustered covariance.
Notes
Additional covariance parameters depend on specific covariance used. See the docstring of the specific covariance estimator for a list of supported options. Defaults are used if no covariance configuration is provided.