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", ...)
TRUE or greater than 0 a VAR model of
order as.integer(prewhite) is fitted via ar with
method "ols" and demean = Fmethod argument passed to
ar for prewhitening.bwAndrews2.tol are used for computing
the covariance matrix, all other weights are treated as 0.bwAndrews2 or bwNeweyWest without having unusued arguments.weightsAndrews returns a vector of weights.bwAndrews returns the selected bandwidth parameter.
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.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(345)
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')Run the code above in your browser using DataLab