Learn R Programming

momentfit (version 0.5)

solveGmm-methods: ~~ Methods for Function solveGmm in Package momentfit ~~

Description

The main function to get the GMM solution for a given weighting matrix.

Usage

# S4 method for linearModel,momentWeights
solveGmm(object, wObj, theta0=NULL,
...)

# S4 method for allNLModel,momentWeights solveGmm(object, wObj, theta0=NULL, algo=c("optim","nlminb"), ...)

# S4 method for rnonlinearModel,momentWeights solveGmm(object, wObj, theta0=NULL, ...)

# S4 method for slinearModel,sysMomentWeights solveGmm(object, wObj, theta0=NULL)

# S4 method for rslinearModel,sysMomentWeights solveGmm(object, wObj, theta0=NULL)

# S4 method for snonlinearModel,sysMomentWeights solveGmm(object, wObj, theta0=NULL, ...)

# S4 method for sfunctionModel,sysMomentWeights solveGmm(object, wObj, theta0=NULL, ...)

Value

A list with the following:

theta

The vector of solution

convergence

convergence code. 0 means normal convergence. For higher numbers, see optim

Arguments

object

A moment-based model

theta0

The vector of coefficients for the starting values used in optim. If NULL, the starting values in the object if used. For system of equations, it is a list of vectors.

wObj

An object of class "momentWeights" or "sysMomentWeights".

algo

The numerical algorithm to minimize the objective function.

...

Arguments to pass to optim.

Methods

signature(object = "allNLMoment", wObj = "momentWeights")

Method to solve either nonlinear regressions or models in which moments are computed with a function. The objective is minimized using optim.

signature(object = "rnonlinearModel", wObj = "momentWeights")

Method to solve restricted nonlinear models. It computes the analytical solution.

signature(object = "linearModel", wObj = "momentWeights")

Method to solve linear models. It computes the analytical solution.

signature(object = "slinearModel", wObj = "sysMomentWeights")

Method to solve system of linear models. It computes the analytical solution.

signature(object = "rslinearModel", wObj = "sysMomentWeights")

Method to solve system of linear models in which restrictions have been imposed on the coefficients. It computes the analytical solution.

signature(object = "slinearModel", wObj = "sysMomentWeights")

Method to solve system of nonlinear models. The solution is obtained with optim using the analytical derivatives.

Examples

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

## A manual two-step GMM
w0 <- evalWeights(model1, w="ident")
theta0 <- solveGmm(model1, w0)$theta
w <- evalWeights(model1, theta0)
theta1 <- solveGmm(model1, w)$theta 

Run the code above in your browser using DataLab