bwWilhelm: Wilhelm (2015) bandwidth selection

View source: R/bandwidth.R

bwWilhelmR Documentation

Wilhelm (2015) bandwidth selection

Description

It computes the optimal bandwidth for the HAC estimation of the covariance matrix of the moment conditions. The bandwidth was shown by Wilhelm (2005) to be the one that minimizes the MSE of the GMM estimator.

Usage

bwWilhelm(x, order.by = NULL, kernel = c("Quadratic Spectral",
  "Bartlett", "Parzen", "Tukey-Hanning"), approx = c("AR(1)", "ARMA(1,1)"),
  weights = NULL, prewhite = 1, ar.method = "ols", data = list())

Arguments

x

An object of class gmm.

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).

kernel

type of kernel used to compute the covariance matrix of the vector of sample moment conditions (see kernHAC for more details)

approx

A character specifying the approximation method if the bandwidth has to be chosen by 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)

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.

ar.method

character. The method argument passed to ar for prewhitening.

data

an optional data frame containing the variables in the 'order.by' model.

Value

The function 'bwWilhelm' returns the optimal bandwidth.

Note

The function was written by Daniel Wilhelm and is based on bwAndrews.

References

Wilhelm, D. (2015), Optimal Bandwidth Selection for Robust Generalized Method of Moments Estimation. Econometric Theory, 31, 1054–1077

Zeileis A (2006), Object-oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1–16. URL \Sexpr[results=rd]{tools:::Rd_expr_doi("10.18637/jss.v016.i09")}.

Examples

data(Finance)
f1 <- Finance[1:300, "rm"] 
f2 <- Finance[1:300, "hml"] 
f3 <- Finance[1:300, "smb"] 
y <- Finance[1:300,"WMK"]

## Silly example just to make it over-identified
###############################################
res <- gmm(y ~ f1, ~ f1 + f2 + f3)
summary(res)


## Set the bandwidth using the second step estimate
################################################
bw <- bwWilhelm(res)
res2 <- update(res, bw=bw)
summary(res2)

## Set the bandwidth using the first-step estimate as for bwAndrews
###################################################################
res3 <- gmm(y ~ f1, ~ f1 + f2 + f3, bw=bwWilhelm)
summary(res3)





gmm documentation built on June 7, 2023, 6:05 p.m.

Related to bwWilhelm in gmm...