HAC {gmm} | R Documentation |
Function to compute a consistent covariance matrix of the sample mean of a random vector of time series. It is consistent in presence of heteroscedasticity and autocorrelation.
HAC(x, weights = weightsAndrews2, bw = bwAndrews2, prewhite = FALSE, ar.method = "ols", kernel=c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"), approx="AR(1)",tol = 1e-7)
x |
a ntimes q matrix of time series, where n is the sample size. |
weights |
The method to compute the kernel weights. For now, weightsAndrews2 is the only one possible. I leave the option there because I am planning to give more choices in futur versions of the package. |
bw |
The method to compute the bandwidth parameter. By default it is bwAndrews2 which is proposed by Andrews (1991). The alternative is bwNeweyWest2 of Newey-West(1994). |
prewhite |
logical or integer. Should the estimating functions
be prewhitened? If TRUE or greater than 0 a VAR model of
order as.integer(prewhite) is fitted via ar with
method "ols" and demean = FALSE . |
ar.method |
character. The method argument passed to
ar for prewhitening. |
kernel |
The choice of kernel |
approx |
a character specifying the approximation method if the bandwidth has to be chosen by bwAndrews2 . |
tol |
numeric. Weights that exceed tol are used for computing the covariance matrix, all other weights are treated as 0. |
HAC
is simply a modified version of meatHAC
from the package sandwich. The modifications have been made so that the argument x can be a matrix instead of an object of class lm or glm. The details on how is works can be found on the sandwich manual.
A q times q matrix containing an estimator of the asymptotic variance of sqrt{n} bar{x}, where bar{x} is qtimes 1 vector with typical element bar{x}_i = frac{1}{n}sum_{j=1}^nx_{ji}. This function is called by gmm() but can also be used by itself.
Zeileis A (2006), Object-oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1–16. URL http://www.jstatsoft.org/v16/i09/.
Newey WK & West KD (1987), A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix. Econometrica, 55, 703–708.
Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation. Review of Economic Studies, 61, 631-653.
x <- arima.sim(n=200,list(order=c(1,0,1),ar=.5,ma=.3,sd=.5)) y <- .4*x+rnorm(200) x <- cbind(x,y) vcov <- HAC(x)