weightsAndrews2 {gmm} | R Documentation |
Function to compute the kernel weights used to compute the HAC covariance matrix
weightsAndrews2(x, bw = bwAndrews2, kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"), prewhite = 1, ar.method = "ols", tol = 1e-7, verbose = FALSE) bwAndrews2(x, kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"), prewhite = 1, ar.method = "ols") bwNeweyWest2(x, kernel = c("Bartlett", "Parzen", "Quadratic Spectral", "Truncated", "Tukey-Hanning"), prewhite = 1, ar.method = "ols",...)
x |
A ntimes q matrix of time series from which we want to compute the covariance matrix. |
bw |
The method to compute the bandwidth parameter. For now, bwAndrews2 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 = FALSE . |
ar.method |
character. The method argument passed to
ar for prewhitening. |
verbose |
logical. Should the bandwidth parameter used be printed? |
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. |
kernel |
The choice of kernel |
... |
It just allows to call either bwAndrews2 or bwNeweyWest without having unusued arguments. |
weightsAndrews2
, bwAndrews2
and bwNeweyWest2
are simply modified version of weightsAndrews
, bwAndrews
and bwNeweyWest
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. kweights
is the same as the one included in the package sandwich.
weightsAndrews
returns a vector of weights.
bwAndrews
returns the selected bandwidth parameter.
Zeileis A (2006), Object-oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1–16. URL http://www.jstatsoft.org/v16/i09/.
Andrews DWK (1991), Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation. Econometrica, 59, 817–858.
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.
set.seed(123) x <- arima.sim(n=200,list(ordre=c(1,0,1),ar=.9,ma=.4)) y <- 2*x + rnorm(200) x = cbind(x,y) w <- weightsAndrews2(x, bw = bwAndrews2, kernel = "Quadratic") plot(w,type='l') w2 <- weightsAndrews2(x, bw = bwNeweyWest2, kernel = "Bartlett") plot(w2,type='l')