modelFit-methods: ~~ Methods for Function 'modelFit' in Package 'gmm4' ~~

Description Usage Arguments Methods Examples

Description

Method to fit a model using GMM, from an object of class "gmmModels".

Usage

 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
## S4 method for signature 'gmmModels'
modelFit(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 'formulaGmm'
modelFit(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 'sysGmmModels'
modelFit(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 'rnonlinearGmm'
modelFit(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 'rlinearGmm'
modelFit(model, type=c("twostep", "iter","cue",
              "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
              weights="optimal", itermaxit=100,
              efficientWeights=FALSE, ...)

## S4 method for signature 'rformulaGmm'
modelFit(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 'rslinearGmm'
modelFit(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 'gelModels'
modelFit(model, gelType=NULL, rhoFct=NULL,
              initTheta=c("gmm", "modelTheta0"), theta0=NULL,
              lambda0=NULL, vcov=FALSE, ...)

## S4 method for signature 'rgelModels'
modelFit(model, gelType=NULL, rhoFct=NULL,
              initTheta=c("gmm", "modelTheta0"), theta0=NULL,
              lambda0=NULL, vcov=FALSE, ...)

Arguments

model

An object of class "gmmModels"

type

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. For restricted

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, "tsls", refers to equation by equation two-stage least squares. It is also possible to start at the equation by equation estimate using the same GMM type as specified by "type".

weights

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. It is also possible for weights to be an object of class gmmWeights.

itermaxit

Maximum iterations for iterative GMM

efficientWeights

If weights is a matrix or a gmmWeights class object, setting efficientWeights to TRUE implies that the resulting one-step GMM is efficient. As a result, the default covariance matrix for the coefficient estimates will not be a sandwich type.

theta0

An optional initial vector for optim when the model is nonlinear. By default, the theta0 argument of the model is used

EbyE

Should we estimate the system equation by equation?

...

Arguments to pass to other methods (mostly the optimization algorithm)

gelType

The type of GEL. This argument is only used if we want to fit the model with a different GEL method. see gelModel.

rhoFct

An alternative objective function for GEL. This argument is only used if we want to fit the model with a different GEL method. see gelModel.

initTheta

Method to obtain the starting values for the coefficient vector. By default the GMM estimate with identity matrix is used. The second argument means that the theta0 of the object, if any, should be used.

lambda0

Manual starting values for the Lagrange multiplier. By default, it is a vector of zeros.

vcov

Should the method computes the covariance matrices of the coefficients and Lagrange multipliers.

Methods

signature(model = "gmmModels")

The main method for all GMM-type models.

signature(model = "gelModels")

The main method for all GEL-type models.

signature(model = "rnonlinearGmm")

It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method evalModel is called at the contrained vector. If not, the next method is called.

signature(model = "rformulaGmm")

It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method evalModel is called at the contrained vector. If not, the next method is called.

signature(model = "rlinearGmm")

It makes a difference only if the number of contraints is equal to the number of coefficients, in which case, the method evalModel is called at the contrained vector. If not, the next method is called.

signature(model = "sysGmmModels")

Method to estimate system of equations using GMM methods.

Examples

 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
data(simData)

theta <- c(beta0=1,beta1=2)
model1 <- gmmModel(y~x1, ~z1+z2, data=simData)

## Efficient GMM with HAC vcov and tsls as first step.
res1 <- modelFit(model1, init="tsls")

## GMM with identity. Two ways.
res2 <- modelFit(model1, type="onestep")
res3 <- modelFit(model1, weights=diag(3))

## nonlinear regression with iterative GMM.
g <- y~beta0+x1^beta1
h <- ~z1+z2
model2 <- gmmModel(g, h, c(beta0=1, beta1=2), data=simData)
res4 <- modelFit(model2, type="iter")

## GMM for with no endogenous vaiables is
## OLS with Robust standard error

library(lmtest)
model3 <- gmmModel(y~x1, ~x1, data=simData, vcov="MDS")
resGmm <- modelFit(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)
modelFit(rmodel1)

## Only one constraint
R <- matrix(c(0,1), ncol=2)
q <- 2
rmodel1 <- restModel(model1, R, q)
modelFit(rmodel1)

gmm4 documentation built on Dec. 6, 2019, 3:01 a.m.