File: bwWilhelm.Rd

package info (click to toggle)
r-cran-gmm 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,592 kB
  • sloc: fortran: 131; ansic: 25; makefile: 2
file content (88 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
\name{bwWilhelm}
\alias{bwWilhelm}
	
\title{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{
\item{x}{An object of class \code{gmm}.}

\item{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).}

\item{kernel}{type of kernel used to compute the covariance matrix of the vector of sample moment conditions (see \code{\link{kernHAC}} for more details)}

\item{approx}{A character specifying the approximation method if the bandwidth has to be chosen by \code{bwAndrews}.}

\item{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)}

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

\item{ar.method}{character. The \code{method} argument passed to \code{\link{ar}} for prewhitening.}

\item{data}{an optional data frame containing the variables in the 'order.by' model.}

}

\value{
The function 'bwWilhelm'  returns the optimal bandwidth.
 }


\references{

  Wilhelm, D. (2015), Optimal Bandwidth Selection for Robust Generalized
  Method of Moments Estimation.
  \emph{Econometric Theory}, \bold{31}, 1054--1077

  Zeileis A (2006), Object-oriented Computation of Sandwich Estimators.
  \emph{Journal of Statistical Software}, \bold{16}(9), 1--16.
  URL \doi{10.18637/jss.v016.i09}.
}

\note{
  The function was written by Daniel Wilhelm and is based on \link{bwAndrews}.
}

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




}