weightsAndrews           package:sandwich           R Documentation

_K_e_r_n_e_l-_b_a_s_e_d _H_A_C _C_o_v_a_r_i_a_n_c_e _M_a_t_r_i_x _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:

     kernHAC(x, order.by = NULL, prewhite = 1, bw = NULL,
       kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),
       approx = c("AR(1)", "ARMA(1,1)"), diagnostics = FALSE, sandwich = TRUE, data = list(), ...)

     weightsAndrews(x, order.by = NULL, bw = NULL,
       kernel = c("Quadratic Spectral", "Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),
       prewhite = 1, data = list(), ...)

     bwAndrews(x, order.by = NULL, kernel = c("Quadratic Spectral", "Truncated",
       "Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"),
       weights = NULL, prewhite = 1, 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'. The default is to use VAR(1)
          prewhitening.

      bw: numeric. The bandwidth of the kernel (corresponds to the
          truncation lag). If set to 'NULL' (the default) it is
          adaptively chosen by the function 'bwAndrews'.

  kernel: a character specifying the kernel used. All kernels used are
          described in Andrews (1991).

  approx: a character specifying the approximation method if the
          bandwidth 'bw' has to be chosen by 'bwAndrews'.

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.

     ...: further arguments passed to 'bwAndrews'.

 weights: numeric. A vector of weights used for weighting the estimated
          coefficients of the approximation model (as specified by
          'approx'). By default all weights are 1 except that for the
          intercept term (if there is more than one variable).

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

     'kernHAC' is a convenience interface to 'vcovHAC' using 
     'weightsAndrews': first a weights function is defined and then
     'vcovHAC' is called.

     The kernel weights underlying 'weightsAndrews' are directly
     accessible via the function 'kweights' and require the
     specification of the bandwidth parameter 'bw'. If this is not
     specified it can be chosen adaptively by the function 'bwAndrews'
     (except for the '"Truncated"' kernel). The automatic bandwidth
     selection is based on an approximation of the estimating functions
     by either AR(1) or ARMA(1,1) processes. To aggregate the estimated
     parameters from these approximations a weighted sum is used. The
     'weights' in this aggregation are by default all equal to 1 except
     that corresponding to the intercept term which is set to 0 (unless
     there is no other variable in the model) making the covariance
     matrix scale invariant.

     Further details can be found in Andrews (1991).

     The estimator of Newey & West (1987) can be obtained using the
     '"Bartlett"' kernel.

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

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

     'weightsAndrews' returns a vector of weights.

     'bwAndrews' returns the selected bandwidth parameter.

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

     Andrews DWK (1991), Heteroskedasticity and Autocorrelation
     Consistent Covariance Matrix Estimation. _Econometrica_, *59*,
     817-858.

     Newey WK & West KD (1987), A Simple, Positive Semi-Definite,
     Heteroskedasticity and Autocorrelation Consistent Covariance
     Matrix. _Econometrica_, *55*, 703-708.

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

     'vcovHAC', 'weightsLumley', 'weave'

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

     curve(kweights(x, kernel = "Quadratic", normalize = TRUE),
           from = 0, to = 3.2, xlab = "x", ylab = "k(x)")
     curve(kweights(x, kernel = "Bartlett", normalize = TRUE),
           from = 0, to = 3.2, col = 2, add = TRUE)
     curve(kweights(x, kernel = "Parzen", normalize = TRUE),
           from = 0, to = 3.2, col = 3, add = TRUE)
     curve(kweights(x, kernel = "Tukey", normalize = TRUE),
           from = 0, to = 3.2, col = 4, add = TRUE)
     curve(kweights(x, kernel = "Truncated", normalize = TRUE),
           from = 0, to = 3.2, col = 5, add = TRUE)

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

