weave(x, order.by = NULL, prewhite = FALSE, C = NULL,
method = c("truncate", "smooth"), acf = isoacf, adjust = FALSE,
diagnostics = FALSE, sandwich = TRUE, tol = 1e-7, data = list(), ...)weightsLumley(x, order.by = NULL, C = NULL,
method = c("truncate", "smooth"), acf = isoacf, tol = 1e-7, 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 = FC is by default
4 for method "truncate" und 1 for method "smooth".isoacf is used.vcovHAC for details.FALSE only the middle matrix is returned.tol are used for computing
the covariance matrix, all other weights are treated as 0.order.by
model. By default the variables are taken from the environment which
the function is called from.weave returns the same type of object as vcovHAC
which is typically just the covariance matrix.weightsLumley returns a vector of weights.
weave is a convenience interface to vcovHAC using
weightsLumley: first a weights function is defined and then vcovHAC
is called.Both weighting methods are based on some estimate of the autocorrelation
function $\rho$ (as computed by acf) of the residuals of
the model x. The weights for the "truncate" method are
$$I{n \rho^2 > C}$$
and the weights for the "smooth" method are
$$\min{1, C n \rho^2}$$
where n is the number of observations in the model an C is the truncation
constant C.
Further details can be found in Lumley & Heagerty (1999).
vcovHAC, weightsAndrews,
kernHACx <- sin(1:100)
y <- 1 + x + rnorm(100)
fm <- lm(y ~ x)
weave(fm)
vcov(fm)Run the code above in your browser using DataLab