Learn R Programming

gmm (version 0.1-0)

HAC: Covariance matrix of weakly dependent time series

Description

Function to compute a consistent covariance matrix of the sample mean of a random vector of time series

Usage

HAC(x, weights = weightsAndrews2, prewhite = FALSE, ar.method = "ols",kernel=c("Quadratic Spectral", 
    "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"))

Arguments

x
a $n\times 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.
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 = F
ar.method
character. The method argument passed to ar for prewhitening.
kernel
The choice of kernel

Value

  • A $q \times q$ matrix containing an estimator of the asymptotic variance of $\sqrt{n} \bar{x}$, where $\bar{x}$ is $q\times 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.

Details

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.

References

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1--16. URL http://www.jstatsoft.org/v16/i09/.

Examples

Run this code
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)

Run the code above in your browser using DataLab