linearmodels.system.covariance.KernelCovariance¶
-
class linearmodels.system.covariance.KernelCovariance(x: list[ndarray], eps: ndarray[tuple[int, ...], dtype[float64]], sigma: ndarray[tuple[int, ...], dtype[float64]], full_sigma: ndarray[tuple[int, ...], dtype[float64]], *, gls: bool =
False, debiased: bool =False, constraints: LinearConstraint | None =None, kernel: str ='bartlett', bandwidth: float | None =None)[source]¶ Kernel (HAC) covariance estimation for system regression.
- Parameters:¶
- x: list[ndarray]¶
Regressors of each equation, with shape (nobs, k_i) for equation i.
- eps: ndarray[tuple[int, ...], dtype[float64]]¶
Model residuals, with shape (nobs, neq).
- sigma: ndarray[tuple[int, ...], dtype[float64]]¶
Covariance of the residuals of the equations that is used to weight the equations if
glsis True, with shape (neq, neq).- full_sigma: ndarray[tuple[int, ...], dtype[float64]]¶
Covariance of the residuals of the equations at the final estimates, with shape (neq, neq). It differs from
sigmaif the weights are not the covariance of the final residuals, e.g., if the model was givensigmaor did not iterate. It is used to estimate the covariance of the scores ifglsis True.- gls: bool =
False¶ Flag indicating to compute the GLS covariance estimator. If False, assume OLS was used. The default is False.
- debiased: bool =
False¶ Flag indicating to apply a small sample adjustment. The default is False.
- constraints: LinearConstraint | None =
None¶ Constraints used in estimation. The default is no constraints.
- kernel: str =
'bartlett'¶ Name of the kernel. The default is “bartlett”. The names are not case sensitive. Supported kernels are:
”bartlett”, “newey-west” - Bartlett’s kernel
”parzen”, “gallant” - Parzen’s kernel
”qs”, “quadratic-spectral”, “andrews” - Quadratic spectral kernel
- bandwidth: float | None =
None¶ Non-negative bandwidth to use for the kernel. If not provided, the optimal bandwidth will be estimated. It needs at least 4 observations with the Bartlett kernel, 5 with the Parzen kernel and 6 with the quadratic spectral kernel, and a
ValueErroris raised for fewer when the covariance is first used. Seekernel_optimal_bandwidth().
See also
linearmodels.iv.covariance.kernel_weight_bartlettWeights of the Bartlett kernel.
linearmodels.iv.covariance.kernel_weight_parzenWeights of the Parzen kernel.
linearmodels.iv.covariance.kernel_weight_quadratic_spectralWeights of the quadratic spectral kernel.
Notes
If GLS is used, the covariance is estimated by
\[(X'\Omega^{-1}X)^{-1}\tilde{S}(X'\Omega^{-1}X)^{-1}\]where X is a block diagonal matrix of exogenous variables and where \(\tilde{S}\) is a estimator of the covariance of the model scores based on the model residuals and the weighted X matrix \(\Omega^{-1/2}X\).
When GLS is not used, the covariance is estimated by
\[(X'X)^{-1}\hat{S}(X'X)^{-1}\]where \(\hat{S}\) is a estimator of the covariance of the model scores.
Changed in version 7.1: The optimal bandwidth raises a
ValueErrorif there are fewer observations than the kernel needs, and if it is not finite. Earlier versions raised “cannot convert float infinity to integer” (anOverflowError) or “cannot convert float NaN to integer” for some data, and used a bandwidth of nobs - 1, or another bandwidth, for other data.Methods
Properties
Bandwidth used in estimation.
Covariance of the parameter estimates.
Configuration of the covariance estimator.
Kernel used in estimation.
Covariance of the residuals of the equations.