weightsLumley {sandwich} | R Documentation |
Weighted Empirical Adaptive Variance Estimation
Description
A set of functions implementing weighted empirical adaptive variance estimation (WEAVE) as introduced by Lumley and Heagerty (1999). This is implemented as a special case of the general class of kernel-based heteroscedasticity and autocorrelation consistent (HAC) covariance matrix estimators as introduced by Andrews (1991), using a special choice of weights.
Usage
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(), ...)
Arguments
x |
a fitted model object. |
order.by |
Either a vector |
prewhite |
logical or integer. Should the estimating functions
be prewhitened? If |
C |
numeric. The cutoff constant |
method |
a character specifying the method used, see details. |
acf |
a function that computes the autocorrelation function of
a vector, by default |
adjust |
logical. Should a finite sample adjustment be made?
This amounts to multiplication with |
diagnostics |
logical. Should additional model diagnostics be returned?
See |
sandwich |
logical. Should the sandwich estimator be computed?
If set to |
tol |
numeric. Weights that exceed |
data |
an optional data frame containing the variables in the |
... |
currently not used. |
Details
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).
Value
weave
returns the same type of object as vcovHAC
which is typically just the covariance matrix.
weightsLumley
returns a vector of weights.
References
Lumley T & Heagerty P (1999). “Weighted Empirical Adaptive Variance Estimators for Correlated Data Regression.” Journal of the Royal Statistical Society B, 61, 459–477.
See Also
vcovHAC
, weightsAndrews
,
kernHAC
Examples
x <- sin(1:100)
y <- 1 + x + rnorm(100)
fm <- lm(y ~ x)
weave(fm)
vcov(fm)