weightsLumley            package:sandwich            R Documentation

_W_e_i_g_h_t_e_d _E_m_p_i_r_i_c_a_l _A_d_a_p_t_i_v_e _V_a_r_i_a_n_c_e _E_s_t_i_m_a_t_i_o_n

_D_e_s_c_r_i_p_t_i_o_n:

     A set of functions implementing a class of kernel-based
     heteroskedasticity and autocorrelation consistent (HAC) covariance
     matrix estimators as introduced by Andrews (1991).

_U_s_a_g_e:

     weave(x, order.by = NULL, prewhite = FALSE, C = NULL,
       method = c("truncate", "smooth"), acf = isoacf, adjust = FALSE,
       diagnostics = FALSE, sandwich = TRUE, data = list(), ...)

     weightsLumley(x, order.by = NULL, C = NULL,
       method = c("truncate", "smooth"), acf = isoacf, data = list(), ...)

_A_r_g_u_m_e_n_t_s:

       x: a fitted model object of class '"lm"' or '"glm"'.

order.by: Either a vector '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 assumed to be ordered (e.g., a time
          series).

prewhite: logical or integer. Should the estimating functions be
          prewhitened? If 'TRUE' or greater than 0 a VAR model of order
          'as.integer(prewhite)' is fitted via 'ar' with method '"ols"'
          and 'demean = FALSE'.

       C: numeric. The cutoff constant 'C' is by default 4 for method
          '"truncate"' und 1 for method '"smooth"'.

  method: a character specifying the method used, see details.

     acf: a function that computes the autocorrelation function of  a
          vector, by default 'isoacf' is used.

  adjust: logical. Should a finite sample adjustment be made? This
          amounts to multiplication with $n/(n-k)$ where $n$ is the
          number of observations and $k$ the number of estimated
          parameters.

diagnostics: logical. Should additional model diagnostics be returned?
          See 'vcovHAC' for details.

sandwich: logical. Should the sandwich estimator be computed? If set to
          'FALSE' only the middle matrix is returned.

    data: an optional data frame containing the variables in the
          'order.by'  model. By default the variables are taken from
          the environment which the function is called from.

     ...: currently not used.

_D_e_t_a_i_l_s:

     '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 

                                  r

     (as computed by 'acf') of the residuals of the model 'x'. The
     weights for the '"truncate"' method are 


                          I{n * r ** 2 > C}


     and the weights for the '"smooth"' method are


                        min{1, C * n * r ** 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).

_V_a_l_u_e:

     'weave' returns the same type of object as 'vcovHAC' which is
     typically just the covariance matrix.

     'weightsLumley' returns a vector of weights.

_R_e_f_e_r_e_n_c_e_s:

     Lumley A & Heagerty P (1999), Weighted Empirical Adaptive Variance
     Estimators for Correlated Data Regression. _Journal of the Royal
     Statistical Society B_, *61*, 459-477.

_S_e_e _A_l_s_o:

     'vcovHAC', 'weightsAndrews', 'kernHAC'

_E_x_a_m_p_l_e_s:

     x <- sin(1:100)
     y <- 1 + x + rnorm(100)
     fm <- lm(y ~ x)
     weave(fm)
     vcov(fm)

