The main functions and methods to fit any model with GMM. As opposed to
gmmFit
, models don't need to be created. It is all done by
the functions. It is meant to be more user friendly. This document
needs to changed. It is just a copy and paste from the gmm package
gmm4(g, x, theta0 = NULL, grad = NULL,
type = c("twostep", "iter", "cue", "onestep"),
vcov = c("iid", "HAC", "MDS", "TrueFixed", "CL"),
initW = c("ident", "tsls", "EbyE"), weights = "optimal",
itermaxit = 50, cstLHS=NULL, cstRHS=NULL,
vcovOptions=list(), survOptions=list(),
itertol = 1e-07, centeredVcov = TRUE,
data = parent.frame(), ...)# S4 method for formula
tsls(model, x, vcov = c("iid", "HAC", "MDS", "CL"),
vcovOptions=list(), survOptions=list(), centeredVcov = TRUE,
data = parent.frame())
# S4 method for list
tsls(model, x=NULL, vcov = c("iid", "HAC", "MDS",
"CL"), vcovOptions=list(), survOptions=list(),
centeredVcov = TRUE, data = parent.frame())
# S4 method for list
ThreeSLS(model, x=NULL, vcov = c("iid", "HAC", "MDS",
"CL"), vcovOptions=list(), survOptions=list(),
centeredVcov = TRUE, data = parent.frame())
It returns an object of class "gmmfit"
A formula or a list of formulas.
A function of the form \(g(\theta,x)\) and which returns a \(n \times q\) matrix with typical element \(g_i(\theta,x_t)\) for \(i=1,...q\) and \(t=1,...,n\). This matrix is then used to build the q sample moment conditions. It can also be a formula if the model is linear or nonlinear, or a list of formulas for systems of equations.
The matrix or vector of data from which the function \(g(\theta,x)\) is computed. If "g" is a formula, it is an \(n \times Nh\) matrix of instruments or a formula (see details below).
A \(k \times 1\) vector of starting values. It is required only when "g" is a function or a nonlinear equation defined by a formula, in which case, it must be a named vector
A function of the form \(G(\theta,x)\) which returns a
\(q\times k\) matrix of derivatives of \(\bar{g}(\theta)\) with
respect to \(\theta\). By default, the numerical algorithm
numericDeriv
is used. It is of course strongly suggested to
provide this function when it is possible. This gradient is used to
compute the asymptotic covariance matrix of \(\hat{\theta}\) and to
obtain the analytical gradient of the objective function if the method
is set to "CG" or "BFGS" in optim
and if "type" is not
set to "cue". If "g" is a formula, the gradiant is not required (see
the details below).
What GMM methods should we use? for
type=="onestep"
, if "weights"
is not a matrix, the
model will be estimated with the weights equals to the identity
matrix
Assumption on the properties of the random vector x. By
default, x is a weakly dependant process. The "iid" option will avoid
using the HAC matrix which will accelerate the estimation if one is
ready to make that assumption. The option "TrueFixed" is used only
when the matrix of weights is provided and it is the optimal one. For
type CL
, clustered covariance matrix is computed. The options
are then included in vcovOptions
(see meatCL
).
How should be compute the initial coefficient vector in the first. It only makes a difference for linear models for which the choice is GMM with identity matrix or two-stage least quares.
What weighting matrix to use? The
choices are "optimal"
, in which case it is the inverse of the
moment vovariance matrix, "ident"
for the identity matrix, or
a fixed matrix.
Maximum iterations for iterative GMM
Tolance for the stopping rule in iterative GMM
Should the moment function be centered when computing its covariance matrix. Doing so may improve inference.
A data.frame or a matrix with column names (Optional).
The left hand side of the constraints to impose on the
coefficients. See restModel
for more details.
The right hand side of the constraints to impose on the
coefficients. See restModel
for more details.
A list of options for the covariance matrix of the
moment conditions. See vcovHAC
for the default values.
If needed, a list with the type of survey weights and
the weights as a numeric vector, data.frame or formula. The type is either
"sampling"
or "fequency"
.
Arguments to pass to optim
when the model
is nonlinear.
Zeileis A (2006), Object-oriented Computation of Sandwich Estimators. Journal of Statistical Software, 16(9), 1--16. URL tools:::Rd_expr_doi("10.18637/jss.v016.i09").
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.
Newey WK & West KD (1994), Automatic Lag Selection in Covariance Matrix Estimation. Review of Economic Studies, 61, 631-653.
Hansen, L.P. (1982), Large Sample Properties of Generalized Method of Moments Estimators. Econometrica, 50, 1029-1054,
Hansen, L.P. and Heaton, J. and Yaron, A.(1996), Finite-Sample Properties of Some Alternative GMM Estimators. Journal of Business and Economic Statistics, 14 262-280.
gmmFit
, momentModel
data(simData)
res <- gmm4(y~x1, ~z1+z2, vcov="MDS", type="iter", data=simData)
res
Run the code above in your browser using DataLab