arch.covariance.kernel.CovarianceEstimator

class arch.covariance.kernel.CovarianceEstimator(x: ndarray | DataFrame | Series, bandwidth: float | None = None, df_adjust: int = 0, center: bool = True, weights: ndarray | DataFrame | Series | None = None, force_int: bool = False, bandwidth_method: str = 'newey-west')[source]

Base class of the kernel-based long-run covariance estimators.

Parameters:
x: ndarray | DataFrame | Series

The data to use in covariance estimation. Observations are in rows and variables in columns. Integer, Boolean and float32 data are converted to float64, and complex data to complex128. float16 data are not accepted. Must have at least 2 rows and 1 column, and must not contain NaN or infinite values.

bandwidth: float | None = None

The kernel’s bandwidth. If None, optimal bandwidth is estimated. Must be finite and non-negative.

df_adjust: int = 0

Degrees of freedom to remove when adjusting the covariance. Uses the number of observations in x minus df_adjust when dividing inner-products. Must be at least 0 and smaller than the number of observations in x.

center: bool = True

A flag indicating whether x should be demeaned before estimating the covariance.

weights: ndarray | DataFrame | Series | None = None

An array of weights used to combine when estimating optimal bandwidth. If not provided, a vector of 1s is used. Must have nvar elements, be finite and non-negative, and at least one must be strictly positive.

force_int: bool = False

Force bandwidth to be an integer.

bandwidth_method: str = 'newey-west'

The method used to estimate the bandwidth when bandwidth is None. “newey-west” uses the nonparametric estimate of Newey and West (1994) and “andrews” uses the AR(1) plug-in estimate of Andrews (1991), see opt_bandwidth. Not case sensitive, and hyphens and underscores are ignored as in the names of kernels, so that “newey_west” and “neweywest” are “newey-west”. Ignored if bandwidth is provided, and by ZeroLag.

Raises:
  • TypeError – If x cannot be converted to float64 or complex128 (it is float16, or contains strings or objects that are not numbers), if weights cannot be converted to float64, if bandwidth is not a real number, if df_adjust is not an integer (a float, including 5.0, or a Boolean is not accepted), or if center or force_int is not a bool, or if bandwidth_method is not a str.

  • ValueError – If x is not 2-d, has fewer than 2 rows or no columns or contains NaN or infinite values; if bandwidth is negative or not finite; if df_adjust is negative or not smaller than the number of observations; or if weights does not have nvar finite elements, has a negative element or has only zeros; if bandwidth_method is not one of the available names; or if bandwidth_method is “andrews” and the bandwidth must be estimated but the AR(1) cannot be fitted to the columns of x with positive weight, for example because they are all constant.

Notes

The kernel weights are defined by the concrete estimators that inherit from this class. A kernel that is 0 beyond 1 uses \(z=\frac{h}{H+1}\) for the lags h that are smaller than \(H+1\), where H is the bandwidth, so that H is the number of lags with a positive weight. The quadratic-spectral kernel uses \(z=\frac{h}{H}\) for every lag.

If the bandwidth is not provided, it is estimated using the constants of [1] and either the automatic lag selection of [2], the default, or the AR(1) plug-in estimate of [1] when bandwidth_method is “andrews”. See opt_bandwidth for details.

Complex data. The estimators accept complex data, for which they are Hermitian. The lag-\(j\) autocovariance is \(\hat{\Gamma}_j=T^{-1}\sum_t x_t x_{t-j}^H\), where \(^H\) is the conjugate transpose, \(\hat{\Gamma}_{-j}=\hat{\Gamma}_j^H\), and the long-run covariance \(\hat{\Omega}=\hat{\Gamma}_0+\sum_{j\geq 1}w_j(\hat{\Gamma}_j+ \hat{\Gamma}_j^H)\) is a complex Hermitian matrix. If \(x_t=a_t+ib_t\), then \(\hat{\Omega}=\hat{\Omega}_{aa}+\hat{\Omega}_{bb}+ i(\hat{\Omega}_{ba}-\hat{\Omega}_{ab})\), where \(\hat{\Omega}_{uv}\) is the long-run covariance of the real data \(u\) and \(v\) with the same kernel and bandwidth. The automatic bandwidth combines the columns of x using weights and uses the real part of the autocovariances of this complex series. The pseudo-covariance \(E[x_t x_{t-j}^\prime]\) is not estimated, and the estimates are complex128 arrays. Real data give float64 estimates.

References

Methods

Properties

bandwidth

The bandwidth used by the covariance estimator.

bandwidth_method

The method used to estimate the bandwidth.

bandwidth_scale

The power used in optimal bandwidth calculation.

centered

Flag indicating whether the data are centered (demeaned).

cov

The estimated covariances.

force_int

Flag indicating whether the bandwidth is restricted to be an integer.

kernel_const

The constant used in optimal bandwidth calculation.

kernel_weights

The weights used in covariance calculation.

name

The covariance estimator's name.

opt_bandwidth

Estimate optimal bandwidth.

rate

The optimal rate used in bandwidth selection.