vcovHAC(x, order.by = NULL, prewhite = FALSE, weights = weightsAndrews,
diagnostics = FALSE, sandwich = TRUE, data = list())"lm" or "glm".z or a formula with a single explanatory
variable like ~ z. The observations in the model
are ordered by the size of z. If set to NULL (the
default) the observations are assumTRUE or greater than 0 a VAR model of
order as.integer(prewhite) is fitted via ar with
method "ols" and demean = Fx, order.by,
prewhite and data. If weights is a function
it has to take these aFALSE only the middle matrix is returned.order.by
model. By default the variables are taken from the environment which
vcovHAC is called from.diagnostics
was set to TRUE this has an attribute "diagnostics} which is a list
with
item{bias.correction}{multiplicative bias correction}
item{df}{Approximate denominator degrees of freedom}
}
references{
Andrews DWK (1991),
Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimation.
emph{Econometrica}, bold{59},
817--858.
Andrews DWK & Monahan JC (1992),
An Improved Heteroskedasticity and Autocorrelation Consistent Covariance Matrix Estimatior.
emph{Econometrica}, bold{60},
953--966.
Lumley A & Heagerty P (1999),
Weighted Empirical Adaptive Variance Estimators for Correlated Data Regression.
emph{Journal of the Royal Statistical Society B}, bold{61},
459--477.
Newey WK & West KD (1987),
A Simple, Positive Semi-Definite, Heteroskedasticity and Autocorrelation Consistent Covariance Matrix.
emph{Econometrica}, bold{55},
703--708.
}
seealso{code{weightsLumley}, code{weightsAndrews},
code{weave}, code{kernHAC}}
examples{
x <- sin(1:100)
y <- 1 + x + rnorm(100)
fm <- lm(y ~ x)
vcovHAC(fm)
vcov(fm)
}
keyword{regression}
keyword{ts}
estfun). The crucial step is the specification
of weights: the user can either supply vcovHAC with some vector of
weights or with a function that computes these weights adaptively (based on
the arguments x, order.by, prewhite and data).
Two functions for adaptively choosing weights are implemented in
weightsAndrews implementing the results of Andrews (1991) and
in weightsLumley implementing the results of Lumley (1999).
The functions kernHAC and weave respectively
are to more convenient interfaces for vcovHAC with these functions.Prewhitening based on VAR approximations is described as suggested in Andrews & Monahan (1992).
The covariance matrix estimators have been improved by the addition of a bias correction and an approximate denominator degrees of freedom for test and confidence interval construction.