NeweyWest(x, lag = NULL, order.by = NULL, prewhite = TRUE, adjust = FALSE,
diagnostics = FALSE, sandwich = TRUE, ar.method = "ols", data = list(),
verbose = FALSE)bwNeweyWest(x, order.by = NULL, kernel = c("Bartlett", "Parzen",
"Quadratic Spectral", "Truncated", "Tukey-Hanning"), weights = NULL,
prewhite = 1, ar.method = "ols", data = list(), ...)
"lm" or "glm".NULL
floor(bwNeweyWest(x, ...)) is used.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 = FbwNeweyWest can only
compute bandwidths for "Bartlett", "Parzen" and
"Quadratic Spectral".vcovHAC for details.FALSE only the middle matrix is returned.method argument passed to
ar for prewhitening (only, not for bandwidth selection).order.by
model. By default the variables are taken from the environment which
the function is called from.approx). By
default all weights are 1 except that for the intercept term (if there is more than
one variable).NeweyWest returns the same type of object as vcovHAC
which is typically just the covariance matrix.bwNeweyWest returns the selected bandwidth parameter.
NeweyWest is a convenience interface to vcovHAC using
Bartlett kernel weights as described in Newey & West (1987, 1994).
The automatic bandwidth selection procedure described in Newey & West (1994)
is used as the default and can also be supplied to kernHAC for the
Parzen and quadratic spectral kernel. It is implemented in bwNeweyWest
which does not truncate its results - if the results for the Parzen and Bartlett
kernels should be truncated, this has to be applied afterwards. For Bartlett
weights this is implemented in NeweyWest.To obtain the estimator described in Newey & West (1987), prewhitening has to be suppressed.
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.
Zeileis A (2004),
Econometric Computing with HC and HAC Covariance Matrix Estimators.
Journal of Statistical Software, 11(10), 1--17.
URL
vcovHAC, weightsAndrews,
kernHAC## fit investment equation
data(Investment)
fm <- lm(RealInv ~ RealGNP + RealInt, data = Investment)
## Newey & West (1994) compute this type of estimator
NeweyWest(fm)
## The Newey & West (1987) estimator requires specification
## of the lag and suppression of prewhitening
NeweyWest(fm, lag = 4, prewhite = FALSE)
## bwNeweyWest() can also be passed to kernHAC(), e.g.
## for the quadratic spectral kernel
kernHAC(fm, bw = bwNeweyWest)Run the code above in your browser using DataLab