gmmFit-methods {momentfit} | R Documentation |
~~ Methods for Function gmmFit
in Package momentfit ~~
Description
Method to fit a model using GMM, from an object of class
"momentModel"
or "sysModel"
.
Usage
## S4 method for signature 'momentModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, ...)
## S4 method for signature 'formulaModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, ...)
## S4 method for signature 'sysModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, EbyE=FALSE, ...)
## S4 method for signature 'rnonlinearModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, ...)
## S4 method for signature 'rlinearModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, ...)
## S4 method for signature 'rformulaModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, ...)
## S4 method for signature 'rslinearModel'
gmmFit(model, type=c("twostep", "iter","cue",
"onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
weights="optimal", itermaxit=100,
efficientWeights=FALSE, theta0=NULL, EbyE=FALSE, ...)
Arguments
model |
A model class object. |
type |
What GMM methods should we use? for
|
itertol |
Tolance for the stopping rule in iterative GMM |
initW |
How should be compute the initial coefficient vector in
the first. For single equation GMM, it only makes a difference for
linear models for which the choice is GMM with identity matrix or
two-stage least quares. For system of equations, |
weights |
What weighting matrix to use? The choices are
|
itermaxit |
Maximum iterations for iterative GMM |
EbyE |
Should the system be estimated equation by equation? |
efficientWeights |
If |
theta0 |
An optional initial vector for |
... |
Arguments to pass to other methods (mostly the optimization algorithm) |
Methods
signature(model = "momentModel")
-
The main method for all moment-based models.
signature(model = "rnonlinearModel")
-
It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method
evalGmm
is called at the contrained vector. If not, the next method is called. signature(model = "rformulaModel")
-
It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method
evalGmm
is called at the contrained vector. If not, the next method is called. signature(model = "rlinearModel")
-
It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method
evalGmm
is called at the contrained vector. If not, the next method is called. signature(model = "sysModel")
-
Method to estimate system of equations using GMM methods.
Examples
data(simData)
theta <- c(beta0=1,beta1=2)
model1 <- momentModel(y~x1, ~z1+z2, data=simData)
## Efficient GMM with HAC vcov and tsls as first step.
res1 <- gmmFit(model1, init="tsls")
## GMM with identity. Two ways.
res2 <- gmmFit(model1, type="onestep")
res3 <- gmmFit(model1, weights=diag(3))
## nonlinear regression with iterative GMM.
g <- y~beta0+x1^beta1
h <- ~z1+z2
model2 <- momentModel(g, h, c(beta0=1, beta1=2), data=simData)
res4 <- gmmFit(model2, type="iter")
## GMM for with no endogenous vaiables is
## OLS with Robust standard error
library(lmtest)
model3 <- momentModel(y~x1, ~x1, data=simData, vcov="MDS")
resGmm <- gmmFit(model3)
resLm <- lm(y~x1, simData)
summary(resGmm)
coeftest(resLm, vcov=vcovHC(resLm, "HC0"))
summary(resGmm, df.adj=TRUE)
coeftest(resLm, vcov=vcovHC(resLm, "HC1"))
### All constrained
R <- diag(2)
q <- c(1,2)
rmodel1 <- restModel(model1, R, q)
gmmFit(rmodel1)
## Only one constraint
R <- matrix(c(0,1), ncol=2)
q <- 2
rmodel1 <- restModel(model1, R, q)
gmmFit(rmodel1)