gmmModel: Constructor for '"gmmModels"' classes

Description Usage Arguments Value References Examples

View source: R/gmmModel.R

Description

It builds the object of either class "linearGmm", "nonlinearGmm" or "functionGmm". This is the first step before running any estimation algorithm.

Usage

1
2
3
4
gmmModel(g, x=NULL, theta0=NULL,grad=NULL,
         vcov = c("iid", "HAC", "MDS", "CL"), vcovOptions=list(),
         centeredVcov = TRUE, data=parent.frame(), na.action="na.omit",
         survOptions=list())

Arguments

g

A function of the form g(θ,x) and which returns a n \times q matrix with typical element g_i(θ,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 (see detailsbelow).

x

The matrix or vector of data from which the function g(θ,x) is computed. If "g" is a formula, it is an n \times Nh matrix of instruments or a formula (see details below).

theta0

A k \times 1 vector of starting values. It is required only when "g" is a function because only then a numerical algorithm is used to minimize the objective function. If the dimension of θ is one, see the argument "optfct".

grad

A function of the form G(θ,x) which returns a q\times k matrix of derivatives of \bar{g}(θ) with respect to θ. 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{θ} 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).

vcov

Assumption on the properties of the moment conditions. By default, they are weakly dependant processes. For MDS, we assume that the conditions are martingale difference sequences, which implies they are serially uncorrelated, but may be heteroscedastic. There is a difference between iid and MDS only when g is a formula. In that case, residuals are assumed homoscedastic as well as serially uncorrelated. For type CL, clustered covariance matrix is computed. The options are then included in vcovOptions (see meatCL).

vcovOptions

A list of options for the covariance matrix of the moment conditions. See vcovHAC for the default values.

centeredVcov

Should the moment function be centered when computing its covariance matrix. Doing so may improve inference.

data

A data.frame or a matrix with column names (Optional).

na.action

Action to take for missing values. If missing values are present and the option is set to "na.pass", the model won't be estimable.

survOptions

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".

Value

'gmmModel' returns an object of one of the subclasses of "gmmModels".

References

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.

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
data(simData)
theta <- c(beta0=1,beta1=2)

## A linearGmm
model1 <- gmmModel(y~x1, ~z1+z2, data=simData)

## A nonlinearGmm
g <- y~beta0+x1^beta1
h <- ~z1+z2
model2 <- gmmModel(g, h, c(beta0=1, beta1=2), data=simData)

## A functionGmm
fct <- function(tet, x)
    {
        m1 <- (tet[1] - x)
        m2 <- (tet[2]^2 - (x - tet[1])^2)
        m3 <- x^3 - tet[1]*(tet[1]^2 + 3*tet[2]^2)
        f <- cbind(m1, m2, m3)
        return(f)
    }
dfct <- function(tet, x)
        {
        jacobian <- matrix(c( 1, 2*(-tet[1]+mean(x)), -3*tet[1]^2-3*tet[2]^2,0, 2*tet[2],
			   -6*tet[1]*tet[2]), nrow=3,ncol=2)
        return(jacobian)
        }
model3 <- gmmModel(fct, simData$x3, theta0=c(beta0=1, beta1=2), grad=dfct)

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