Description Usage Arguments Value Source Examples
HAC Covariance Matrix Estimation
HAC
computes the central quantity (the meat) in the HAC covariance matrix estimator, also called
sandwich estimator. HAC is the abbreviation for "heteroskedasticity and autocorrelation consistent".
1 | HAC(mcond, method = "Bartlett", bw)
|
mcond |
a q-dimensional multivariate time series. In the case of OLS regression with q regressors mcond contains the series of the form regressor*residual (see example below). |
method |
kernel function, choose between "Truncated", "Bartlett", "Parzen", "Tukey-Hanning", "Quadratic Spectral". |
bw |
bandwidth parameter, controls the number of lags considered in the estimation. |
mat a (q,q)-matrix
Heberle, J. and Sattarhoff, C. (2017) <doi:10.3390/econometrics5010009> "A Fast Algorithm for the Computation of HAC Covariance Matrix Estimators"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
data(MUSKRAT)
y <- ts(log10(MUSKRAT))
n <- length(y)
t <- c(1:n)
t2 <- t^2
out2 <- lm(y ~ t +t2)
mat_xu <- matrix(c(out2$residuals,t*out2$residuals, t2*out2$residuals),nrow=62,ncol=3)
hac <- HAC(mat_xu, method="Bartlett", 4)
mat_regr<- matrix(c(rep(1,62),t,t2),nrow=62,ncol=3)
mat_q <- t(mat_regr)%*%mat_regr/62
vcov_HAC <- solve(mat_q)%*%hac%*%solve(mat_q)/62
# vcov_HAC is the HAC covariance matrix estimation for the OLS coefficients.
|
Loading required package: Matrix
Loading required package: vars
Loading required package: MASS
Loading required package: strucchange
Loading required package: zoo
Attaching package: ‘zoo’
The following objects are masked from ‘package:base’:
as.Date, as.Date.numeric
Loading required package: sandwich
Loading required package: urca
Loading required package: lmtest
Loading required package: fftwtools
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.