linearmodels.panel.covariance.DriscollKraay¶
- class DriscollKraay(y, x, params, entity_ids, time_ids, *, debiased=False, extra_df=0, kernel=None, bandwidth=None)[source]¶
Driscoll-Kraay heteroskedasticity-autocorrelation robust covariance estimation
- Parameters:
- y
ndarray
(entity x time) by 1 stacked array of dependent
- x
ndarray
(entity x time) by variables stacked array of exogenous
- params
ndarray
variables by 1 array of estimated model parameters
- entity_ids
ndarray
(entity x time) by 1 stacked array of entity ids
- time_ids
ndarray
(entity x time) by 1 stacked array of time ids
- debiasedbool
Flag indicating whether to debias the estimator
- extra_df
int
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
Name of one of the supported kernels. If None, uses the Newey-West kernel.
- bandwidth
int
Non-negative integer to use as bandwidth. If not provided a rule-of- thumb value is used.
- y
Notes
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 & = \sum_{i=1}^{n_t} \epsilon_i x_{i} \\ \hat{S}_0 & = \sum_{i=1}^{t} \xi'_t \xi_t \\ \hat{S}_j & = \sum_{i=1}^{t-j} \xi'_t \xi_{t+j} + \xi'_{t+j} \xi_t \\ \hat{S} & = (n-df)^{-1} \sum_{j=0}^{bw} K(j, bw) \hat{S}_j\end{split}\]where df is
extra_df
and n-df is replace by n-df-k ifdebiased
isTrue
. \(K(i, bw)\) is the kernel weighting function.- Attributes:
Methods
Covariance calculation deferred until executed
Properties
Estimated covariance
Model residuals
Covariance estimator name
Error variance