bwWilhelm | R Documentation |
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.
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())
x |
An object of class |
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 |
approx |
A character specifying the approximation method if the bandwidth has to be chosen by |
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 |
ar.method |
character. The |
data |
an optional data frame containing the variables in the 'order.by' model. |
The function 'bwWilhelm' returns the optimal bandwidth.
The function was written by Daniel Wilhelm and is based on bwAndrews.
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")}.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.