linearmodels.asset_pricing.covariance.KernelCovariance¶
-
class linearmodels.asset_pricing.covariance.KernelCovariance(xe: ndarray[tuple[int, ...], dtype[float64]], *, jacobian: ndarray | None =
None, inv_jacobian: ndarray | None =None, kernel: str | None =None, bandwidth: float | None =None, center: bool =True, debiased: bool =False, df: int =0)[source]¶ Heteroskedasticity-autocorrelation (HAC) robust covariance estimator.
- Parameters:¶
- xe: ndarray[tuple[int, ...], dtype[float64]]¶
The scores (moment) conditions, with shape (nobs, nmoments).
- jacobian: ndarray | None =
None¶ Jacobian, with shape (nmoments, nparams). One and only one of jacobian and inv_jacobian must be provided.
- inv_jacobian: ndarray | None =
None¶ Inverse jacobian. One and only one of jacobian and inv_jacobian must be provided.
- kernel: str | None =
None¶ 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. If None, the optimal bandwidth is 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 bandwidth is first used. Seekernel_optimal_bandwidth().- center: bool =
True¶ Flag indicating to center the scores when computing the covariance. The default is True.
- debiased: bool =
False¶ Flag indicating to use a debiased estimator. The default is False.
- df: int =
0¶ Degree of freedom value to use if debiasing. The default is 0.
- Raises:¶
ValueError – If both or neither of
jacobianandinv_jacobianare provided, or ifbandwidthis negative.TypeError – If
kernelis not a str, orbandwidthis not a number.UnknownOptionError – If
kernelis not supported. It is both aKeyErrorand aValueError.
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
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.
Configuration of the covariance estimator.
Compute parameter covariance.
Inverse Jacobian.
The Jacobian.
Kernel used in estimation.
Score/moment condition covariance.
Flag indicating if jacobian is square.