linearmodels.panel.covariance.ACCovariance

class linearmodels.panel.covariance.ACCovariance(y: ndarray[Any, dtype[float64]], x: ndarray[Any, dtype[float64]], params: ndarray[Any, dtype[float64]], entity_ids: ndarray[Any, dtype[int64]], time_ids: ndarray[Any, dtype[int64]], *, debiased: bool = False, extra_df: int = 0, kernel: str | None = None, bandwidth: float | None = None)[source]

Autocorrelation robust covariance estimation

Parameters:
y: ndarray[Any, dtype[float64]]

(entity x time) by 1 stacked array of dependent

x: ndarray[Any, dtype[float64]]

(entity x time) by variables stacked array of exogenous

params: ndarray[Any, dtype[float64]]

variables by 1 array of estimated model parameters

entity_ids: ndarray[Any, dtype[int64]]

(entity x time) by 1 stacked array of entity ids

time_ids: ndarray[Any, dtype[int64]]

(entity x time) by 1 stacked array of time ids

debiased: bool = False

Flag indicating whether to debias the estimator

extra_df: int = 0

Additional degrees of freedom consumed by models beyond the number of columns in x, e.g., fixed effects. Covariance estimators are always adjusted for extra_df irrespective of the setting of debiased

kernel: str | None = None

Name of one of the supported kernels. If None, uses the Newey-West kernel.

bandwidth: float | None = None

Non-negative integer to use as bandwidth. If not provided a rule-of- thumb value is used.

Notes

Estimator is robust to autocorrelation but not cross-sectional correlation.

Supported kernels:

  • “bartlett”, “newey-west” - Bartlett’s kernel

  • “quadratic-spectral”, “qs”, “andrews” - Quadratic-Spectral Kernel

  • “parzen”, “gallant” - Parzen kernel

Bandwidth is set to the common value for the Bartlett kernel if not provided.

The estimator of the covariance is

\[n^{-1}\hat{\Sigma}_{xx}^{-1}\hat{S}\hat{\Sigma}_{xx}^{-1}\]

where

\[\hat{\Sigma}_{xx} = n^{-1}X'X\]

and

\[\begin{split}\xi_t & = \epsilon_{it} x_{it} \\ \hat{S} & = n / (N(n-df)) \sum_{i=1}^N S_i \\ \hat{S}_i & = \sum_{j=0}^{bw} K(j, bw) \hat{S}_{ij} \\ \hat{S}_{i0} & = \sum_{t=1}^{T} \xi'_{it} \xi_{it} \\ \hat{S}_{ij} & = \sum_{t=1}^{T-j} \xi'_{it} \xi_{it+j} + \xi'_{it+j} \xi_{it}\end{split}\]

where df is extra_df and n-df is replace by n-df-k if debiased is True. \(K(i, bw)\) is the kernel weighting function.

Methods

deferred_cov()

Covariance calculation deferred until executed

Properties

ALLOWED_KWARGS

DEFAULT_KERNEL

cov

Estimated covariance

eps

Model residuals

name

Covariance estimator name

s2

Error variance