[Gmm-commits] r131 - in pkg/gmm4: . R man vignettes
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Sep 14 22:53:53 CEST 2018
Author: chaussep
Date: 2018-09-14 22:53:53 +0200 (Fri, 14 Sep 2018)
New Revision: 131
Added:
pkg/gmm4/man/modelFit-methods.Rd
Removed:
pkg/gmm4/man/gmmFit-methods.Rd
Modified:
pkg/gmm4/NAMESPACE
pkg/gmm4/R/gel.R
pkg/gmm4/R/gmm4.R
pkg/gmm4/R/gmmModels-methods.R
pkg/gmm4/R/gmmfit-methods.R
pkg/gmm4/R/rGmmModel-methods.R
pkg/gmm4/R/rsysGmmModels-methods.R
pkg/gmm4/R/sysGmmModels-methods.R
pkg/gmm4/man/.Rhistory
pkg/gmm4/man/CigarettesSW.Rd
pkg/gmm4/man/ConsumptionG.Rd
pkg/gmm4/man/HealthRWM.Rd
pkg/gmm4/man/ThreeSLS-methods.Rd
pkg/gmm4/man/bread-methods.Rd
pkg/gmm4/man/coef-methods.Rd
pkg/gmm4/man/getRestrict-methods.Rd
pkg/gmm4/man/gmm4.Rd
pkg/gmm4/man/gmmfit-class.Rd
pkg/gmm4/man/hypothesisTest-methods.Rd
pkg/gmm4/man/meatGmm-methods.Rd
pkg/gmm4/man/residuals-methods.Rd
pkg/gmm4/man/restGmmModel-methods.Rd
pkg/gmm4/man/rgmmModels-class.Rd
pkg/gmm4/man/rnonlinearGmm-class.Rd
pkg/gmm4/man/smoothGel.Rd
pkg/gmm4/man/solveGel-methods.Rd
pkg/gmm4/man/specTest-methods.Rd
pkg/gmm4/man/summary-methods.Rd
pkg/gmm4/man/systemGmm.Rd
pkg/gmm4/man/update-methods.Rd
pkg/gmm4/man/vcov-methods.Rd
pkg/gmm4/vignettes/gmmS4.Rnw
pkg/gmm4/vignettes/gmmS4.pdf
Log:
changing the name of gmmFit method to modelFit. Makes more sense as it applies to many estimation methods
Modified: pkg/gmm4/NAMESPACE
===================================================================
--- pkg/gmm4/NAMESPACE 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/NAMESPACE 2018-09-14 20:53:53 UTC (rev 131)
@@ -28,7 +28,7 @@
export(gmmModel, evalMoment, Dresiduals, evalDMoment, momentVcov, estfun.gmmFct,
evalWeights, quadra, evalObjective, solveGmm, momentStrength,evalGmm,
- tsls, gmmFit, meatGmm, specTest, gmm4, restGmmModel, modelResponse, DWH,
+ tsls, modelFit, meatGmm, specTest, gmm4, restGmmModel, modelResponse, DWH,
modelDims, printRestrict, getRestrict, sysGmmModel, ThreeSLS, gelModel,
rhoET, rhoEL, rhoEEL, rhoHD, EL.Wu, getLambda, gmmToGel, smoothGel,
solveGel)
Modified: pkg/gmm4/R/gel.R
===================================================================
--- pkg/gmm4/R/gel.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/gel.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -170,7 +170,7 @@
return(sx)
}
if (is.null(theta))
- theta <- gmmFit(as(object, "gmmModels"), weights="ident")@theta
+ theta <- modelFit(as(object, "gmmModels"), weights="ident")@theta
gt <- evalMoment(object, theta)
gt <- scale(gt, scale=FALSE)
Modified: pkg/gmm4/R/gmm4.R
===================================================================
--- pkg/gmm4/R/gmm4.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/gmm4.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -54,7 +54,7 @@
if (!is.null(cstLHS))
model <- restGmmModel(model, cstLHS, cstRHS)
- fit <- gmmFit(object=model, type=type, itertol=itertol, initW=initW,
+ fit <- modelFit(object=model, type=type, itertol=itertol, initW=initW,
weights=weights, itermaxit=itermaxit,
efficientWeights=efficientWeights, ...)
fit at call <- Call
Modified: pkg/gmm4/R/gmmModels-methods.R
===================================================================
--- pkg/gmm4/R/gmmModels-methods.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/gmmModels-methods.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -652,11 +652,11 @@
x at n <- nrow(x at modelF)
x})
-## gmmFit
+## modelFit
-setGeneric("gmmFit", function(object, ...) standardGeneric("gmmFit"))
+setGeneric("modelFit", function(object, ...) standardGeneric("modelFit"))
-setMethod("gmmFit", signature("formulaGmm"), valueClass="gmmfit",
+setMethod("modelFit", signature("formulaGmm"), valueClass="gmmfit",
definition = function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, start=NULL, ...)
@@ -667,7 +667,7 @@
{
spec <- modelDims(object)
wObj <- evalWeights(object, spec$theta0, "optimal")
- met <- getMethod("gmmFit", "gmmModels")
+ met <- getMethod("modelFit", "gmmModels")
res <- met(object, weights=wObj, efficientWeights=TRUE,
...)
res at type <- "mde"
@@ -680,7 +680,7 @@
}
})
-setMethod("gmmFit", signature("gmmModels"), valueClass="gmmfit",
+setMethod("modelFit", signature("gmmModels"), valueClass="gmmfit",
definition = function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, start=NULL, ...)
Modified: pkg/gmm4/R/gmmfit-methods.R
===================================================================
--- pkg/gmm4/R/gmmfit-methods.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/gmmfit-methods.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -153,7 +153,7 @@
stop("Th model without the tested conditions is under-identified")
mod2 <- object at model[-which]
w <- object at wObj
- obj2 <- gmmFit(mod2, weights=w[-which])
+ obj2 <- modelFit(mod2, weights=w[-which])
J <- specTest(object, wObj=w)@test[1]
J1 <- specTest(obj2, wObj=w[-which])@test[1]
j <- J-J1
@@ -218,7 +218,7 @@
isValid <- validObject(model)
fct[["object"]] <- quote(model)
ev$model <- model
- fct[[1L]] <- quote(gmmFit)
+ fct[[1L]] <- quote(modelFit)
arg <- arg[-modarg]
if (length(arg) > 0)
for (n in names(arg))
Modified: pkg/gmm4/R/rGmmModel-methods.R
===================================================================
--- pkg/gmm4/R/rGmmModel-methods.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/rGmmModel-methods.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -734,7 +734,7 @@
## gmmfit
-setMethod("gmmFit", signature("rlinearGmm"), valueClass="gmmfit",
+setMethod("modelFit", signature("rlinearGmm"), valueClass="gmmfit",
definition = function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, ...) {
@@ -753,7 +753,7 @@
}
})
-setMethod("gmmFit", signature("rnonlinearGmm"), valueClass="gmmfit",
+setMethod("modelFit", signature("rnonlinearGmm"), valueClass="gmmfit",
definition = function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, start=NULL, ...) {
@@ -772,7 +772,7 @@
}
})
-setMethod("gmmFit", signature("rformulaGmm"), valueClass="gmmfit",
+setMethod("modelFit", signature("rformulaGmm"), valueClass="gmmfit",
definition = function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, start=NULL, ...) {
Modified: pkg/gmm4/R/rsysGmmModels-methods.R
===================================================================
--- pkg/gmm4/R/rsysGmmModels-methods.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/rsysGmmModels-methods.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -304,9 +304,9 @@
callNextMethod()
})
- ## gmmFit. Almost like sysGmmModels method, bu we need to check a few things
+ ## modelFit. Almost like sysGmmModels method, bu we need to check a few things
-setMethod("gmmFit", signature("rslinearGmm"), valueClass="sgmmfit",
+setMethod("modelFit", signature("rslinearGmm"), valueClass="sgmmfit",
function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
weights="optimal", itermaxit=100,
@@ -323,7 +323,7 @@
if (type=="onestep" || (is.character(weights) && weights=="ident"))
{
wObj <- evalWeights(object, w="ident")
- return(gmmFit(object, w=wObj))
+ return(modelFit(object, w=wObj))
}
}
callNextMethod()
Modified: pkg/gmm4/R/sysGmmModels-methods.R
===================================================================
--- pkg/gmm4/R/sysGmmModels-methods.R 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/R/sysGmmModels-methods.R 2018-09-14 20:53:53 UTC (rev 131)
@@ -703,9 +703,9 @@
})
-## gmmFit
+## modelFit
-setMethod("gmmFit", signature("sysGmmModels"), valueClass="sgmmfit",
+setMethod("modelFit", signature("sysGmmModels"), valueClass="sgmmfit",
function(object, type=c("twostep", "iter","cue", "onestep"),
itertol=1e-7, initW=c("ident", "tsls", "EbyE"), weights="optimal",
itermaxit=100, efficientWeights=FALSE, start=NULL,
@@ -741,7 +741,7 @@
{
neqn <- length(object at eqnNames)
res <- lapply(1:neqn, function(i)
- gmmFit(object[i], type=type, weights=weights,itertol=itertol,
+ modelFit(object[i], type=type, weights=weights,itertol=itertol,
initW=initW, itermaxit=itermaxit,
efficientWeights=efficientWeights, start=start, ...))
theta <- lapply(res, coef)
@@ -801,7 +801,7 @@
} else if (initW == "EbyE") {
neqn <- length(object at eqnNames)
res <- lapply(1:neqn, function(i)
- gmmFit(object[i], type=type, weights=weights,itertol=itertol,
+ modelFit(object[i], type=type, weights=weights,itertol=itertol,
itermaxit=itermaxit,
efficientWeights=efficientWeights, start=start, ...))
theta0 <- lapply(res, coef)
Modified: pkg/gmm4/man/.Rhistory
===================================================================
--- pkg/gmm4/man/.Rhistory 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/.Rhistory 2018-09-14 20:53:53 UTC (rev 131)
@@ -5,3 +5,10 @@
n
q()
n
+library(gmm4)
+theta0
+res
+res2
+res3
+q()
+n
Modified: pkg/gmm4/man/CigarettesSW.Rd
===================================================================
--- pkg/gmm4/man/CigarettesSW.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/CigarettesSW.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -50,7 +50,7 @@
## Equation 12.15
model1 <- gmmModel(log(packs)~log(rprice)+log(rincome),
~log(rincome)+tdiff, data = c1995, vcov="MDS")
-res1 <- gmmFit(model1)
+res1 <- modelFit(model1)
## HC0 robust se (different from the textbook)
summary(res1, sandwich=TRUE)
Modified: pkg/gmm4/man/ConsumptionG.Rd
===================================================================
--- pkg/gmm4/man/ConsumptionG.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/ConsumptionG.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -52,7 +52,7 @@
model <- gmmModel(C~alpha+beta*Y^gamma, ~C1+Y1+Y2, data=dat, tet0=theta0, vcov="iid")
### Scaling the parameters increase the speed of convergence
-res <- gmmFit(model, control=list(parscale=c(1000,.1,1)))
+res <- modelFit(model, control=list(parscale=c(1000,.1,1)))
### It also seems that there is a degree of freedom adjustment for the
### estimate of the variance of the error term.
Modified: pkg/gmm4/man/HealthRWM.Rd
===================================================================
--- pkg/gmm4/man/HealthRWM.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/HealthRWM.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -83,7 +83,7 @@
## Who is right?
h1 <- ~age+educ+female
model1 <- gmmModel(g, h1, thet0, vcov="MDS", data=dat88)
-res1 <- gmmFit(model1, control=list(reltol=1e-10, abstol=1e-10))
+res1 <- modelFit(model1, control=list(reltol=1e-10, abstol=1e-10))
summary(res1)@coef
## Table 13.2 third column (close enough)
@@ -91,11 +91,11 @@
## efficient GMM
h2 <- ~age+educ+female+hsat+married
model2 <- gmmModel(g, h2, thet0, vcov="MDS", data=dat88)
-res2 <- gmmFit(model2, type="onestep")
+res2 <- modelFit(model2, type="onestep")
summary(res2, sandwich=TRUE)@coef
## Table 13.2 fourth column (Can't get closer than that)
-res3 <- gmmFit(model2)
+res3 <- modelFit(model2)
summary(res3)@coef
# Lets see what happens if we start on Greene solution
Modified: pkg/gmm4/man/ThreeSLS-methods.Rd
===================================================================
--- pkg/gmm4/man/ThreeSLS-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/ThreeSLS-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -22,7 +22,7 @@
\item{coefOnly}{Should the method return the only the coefficients or
create an object of class \code{"sgmmfit"}.}
\item{qrZ}{The qr decomposition of the common instruments. It is
- mostly used by \code{\link{gmmFit}} to avoid recomputing it in
+ mostly used by \code{\link{modelFit}} to avoid recomputing it in
iterative GMM or CUE. It should not be used directly unless the user
knows what he is doing.}
\item{Sigma}{The covariance matrix of the residuals. If not provided,
Modified: pkg/gmm4/man/bread-methods.Rd
===================================================================
--- pkg/gmm4/man/bread-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/bread-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -38,7 +38,7 @@
theta <- c(beta0=1,beta1=2)
model1 <- gmmModel(y~x1, ~z1+z2, data=simData)
-res <- gmmFit(model1)
+res <- modelFit(model1)
m <- meatGmm(res)
b <- bread(res)
Modified: pkg/gmm4/man/coef-methods.Rd
===================================================================
--- pkg/gmm4/man/coef-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/coef-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -49,12 +49,12 @@
\examples{
data(simData)
model1 <- gmmModel(y~x1+x2+x3+z1, ~x1+x2+z1+z2+z3+z4, data=simData)
-res1 <- gmmFit(model1)
+res1 <- modelFit(model1)
coef(res1)
### Restricted models
rmodel1 <- restGmmModel(model1, R=c("x1=1", "x2=2*x3"))
-res2 <- gmmFit(rmodel1)
+res2 <- modelFit(rmodel1)
res2
coef(rmodel1, coef(res2))
}
Modified: pkg/gmm4/man/getRestrict-methods.Rd
===================================================================
--- pkg/gmm4/man/getRestrict-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/getRestrict-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -87,7 +87,7 @@
## The restricted model
R1 <- c("x1","2*x2+z1=2", "4+x3*5=3")
-res <- gmmFit(model1)
+res <- modelFit(model1)
rest <- getRestrict(model1, coef(res), R1)
## it allows to test the restriction
@@ -102,7 +102,7 @@
## the linear model into a nonlinear one
NLmodel <- as(model1, "nonlinearGmm")
R1 <- c("theta2=2", "theta3=theta4^2")
-res <- gmmFit(NLmodel)
+res <- modelFit(NLmodel)
rest <- getRestrict(NLmodel, coef(res), R1)
g <- rest$R-rest$q
Modified: pkg/gmm4/man/gmm4.Rd
===================================================================
--- pkg/gmm4/man/gmm4.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/gmm4.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -8,7 +8,7 @@
}
\description{
The main functions and methods to fit any model with GMM. As opposed to
-\code{\link{gmmFit}}, models don't need to be created. It is all done by
+\code{\link{modelFit}}, 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
}
@@ -168,7 +168,7 @@
}
\seealso{
-\code{\link{gmmFit}}, \code{\link{gmmModel}}
+\code{\link{modelFit}}, \code{\link{gmmModel}}
}
\examples{
data(simData)
Deleted: pkg/gmm4/man/gmmFit-methods.Rd
===================================================================
--- pkg/gmm4/man/gmmFit-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/gmmFit-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -1,156 +0,0 @@
-\name{gmmFit-methods}
-\docType{methods}
-\alias{gmmFit}
-\alias{gmmFit-methods}
-\alias{gmmFit,gmmModels-method}
-\alias{gmmFit,formulaGmm-method}
-\alias{gmmFit,sysGmmModels-method}
-\alias{gmmFit,rlinearGmm-method}
-\alias{gmmFit,rformulaGmm-method}
-\alias{gmmFit,rslinearGmm-method}
-\alias{gmmFit,rnonlinearGmm-method}
-\title{ ~~ Methods for Function \code{gmmFit} in Package \pkg{gmm4} ~~}
-\description{
-Method to fit a model using GMM, from an object of class \code{"gmmModels"}.
-}
-\usage{
-\S4method{gmmFit}{gmmModels}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, \dots)
-
-\S4method{gmmFit}{formulaGmm}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, \dots)
-
-\S4method{gmmFit}{sysGmmModels}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, EbyE=FALSE, \dots)
-
-\S4method{gmmFit}{rnonlinearGmm}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, \dots)
-
-\S4method{gmmFit}{rlinearGmm}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, \dots)
-
-\S4method{gmmFit}{rformulaGmm}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, \dots)
-
-\S4method{gmmFit}{rslinearGmm}(object, type=c("twostep", "iter","cue",
- "onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
- weights="optimal", itermaxit=100,
- efficientWeights=FALSE, start=NULL, EbyE=FALSE, \dots)
-}
-\arguments{
- \item{object}{An object of class \code{"gmmModels"}}
- \item{type}{What GMM methods should we use? for
- \code{type=="onestep"}, if \code{"weights"} is not a matrix, the
- model will be estimated with the weights equals to the identity
- matrix. For restricted }
- \item{itertol}{Tolance for the stopping rule in iterative GMM}
- \item{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, \code{"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 \code{"type"}.}
- \item{weights}{What weighting matrix to use? The choices are
- \code{"optimal"}, in which case it is the inverse of the moment
- vovariance matrix, \code{"ident"} for the identity matrix, or a
- fixed matrix. It is also possible for weights to be an object of
- class \code{gmmWeights}.}
- \item{itermaxit}{Maximum iterations for iterative GMM}
- \item{efficientWeights}{If \code{weights} is a matrix or a
- \code{gmmWeights} class object, setting \code{efficientWeights} to
- \code{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.}
- \item{start}{An optional initial vector for \code{\link{optim}} when
- the model is nonlinear. By default, the theta0 argument of the model
- is used}
- \item{EbyE}{Should we estimate the system equation by equation?}
- \item{\dots}{Arguments to pass to other methods}
- }
-\section{Methods}{
-\describe{
-\item{\code{signature(object = "gmmModels")}}{
-The main method for all GMM-type models.
-}
-
-\item{\code{signature(object = "rnonlinearGmm")}}{
-It makes a difference only if the number of contraints is equal to the
-number of coefficients, in which case, the method \code{\link{evalGmm}}
-is called at the contrained vector. If not, the next method is called.
-}
-
-\item{\code{signature(object = "rformulaGmm")}}{
-It makes a difference only if the number of contraints is equal to the
-number of coefficients, in which case, the method \code{\link{evalGmm}}
-is called at the contrained vector. If not, the next method is called.
-}
-
-\item{\code{signature(object = "rlinearGmm")}}{
-It makes a difference only if the number of contraints is equal to the
-number of coefficients, in which case, the method \code{\link{evalGmm}}
-is called at the contrained vector. If not, the next method is called.
-}
-
-\item{\code{signature(object = "sysGmmModels")}}{
-Method to estimate system of equations using GMM methods.
-}
-
-}}
-\examples{
-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 <- 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 <- gmmModel(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 <- gmmModel(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 <- restGmmModel(model1, R, q)
-gmmFit(rmodel1)
-
-## Only one constraint
-R <- matrix(c(0,1), ncol=2)
-q <- 2
-rmodel1 <- restGmmModel(model1, R, q)
-gmmFit(rmodel1)
-
-}
-\keyword{methods}
Modified: pkg/gmm4/man/gmmfit-class.Rd
===================================================================
--- pkg/gmm4/man/gmmfit-class.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/gmmfit-class.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -38,7 +38,7 @@
}
\seealso{
-\code{\link{gmmFit}}, \code{\link{tsls}}, and \code{\link{gmm4}} to fit
+\code{\link{modelFit}}, \code{\link{tsls}}, and \code{\link{gmm4}} to fit
a model with GMM and then create an object of class \code{"gmmfit"}..
%% ~~or \code{\linkS4class{CLASSNAME}} for links to other classes ~~~
}
Modified: pkg/gmm4/man/hypothesisTest-methods.Rd
===================================================================
--- pkg/gmm4/man/hypothesisTest-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/hypothesisTest-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -126,7 +126,7 @@
## Unrestricted model
model1 <- gmmModel(y~x1+x2+x3, ~x2+x3+z1+z2+z3, data=simData, vcov="MDS")
-res1 <- gmmFit(model1)
+res1 <- modelFit(model1)
## Wald test
R <- c("x1=0.5","x2=x3")
@@ -135,17 +135,17 @@
## LR tests
rmodel1 <- restGmmModel(model1, R)
-res2 <- gmmFit(rmodel1)
+res2 <- modelFit(rmodel1)
hypothesisTest(object.u=res1, object.r=res2, type="LR")
### LR and Wald should be the same as long as the same weighting
### matrix if used for both GMM fits, for the LR and Wald as well
# Unrestricted model and save the weights
-res1 <- gmmFit(model1)
+res1 <- modelFit(model1)
w <- res1 at wObj
# estimate models with the same weights
-res2 <- gmmFit(rmodel1, weights=w)
+res2 <- modelFit(rmodel1, weights=w)
# LR test with the same weights
hypothesisTest(res1, res2, type="LR", wObj=w)
@@ -161,8 +161,8 @@
R <- c("educ=0","I(exper^2)=0")
rmodel <- restGmmModel(model, R)
-res1 <- gmmFit(model)
-res2 <- gmmFit(rmodel, weights=res1 at wObj)
+res1 <- modelFit(model)
+res2 <- modelFit(rmodel, weights=res1 at wObj)
hypothesisTest(object.u=res1, object.r=res2, type="LR", wObj=res1 at wObj)
hypothesisTest(object.u=res1, object.r=res2, type="Wald",
@@ -180,8 +180,8 @@
NLmodel <- as(model1, "nonlinearGmm")
R1 <- c("theta2=2", "theta3=theta4^2")
rNLmodel <- restGmmModel(NLmodel, R1)
-res.u <- gmmFit(NLmodel)
-res.r <- gmmFit(rNLmodel)
+res.u <- modelFit(NLmodel)
+res.r <- modelFit(rNLmodel)
hypothesisTest(object.u=res.u, R=R1)
## LM
Modified: pkg/gmm4/man/meatGmm-methods.Rd
===================================================================
--- pkg/gmm4/man/meatGmm-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/meatGmm-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -60,7 +60,7 @@
theta <- c(beta0=1,beta1=2)
model1 <- gmmModel(y~x1, ~z1+z2, data=simData)
-res <- gmmFit(model1)
+res <- modelFit(model1)
meatGmm(res)
## It is a slightly different because the weighting matrix
Added: pkg/gmm4/man/modelFit-methods.Rd
===================================================================
--- pkg/gmm4/man/modelFit-methods.Rd (rev 0)
+++ pkg/gmm4/man/modelFit-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -0,0 +1,156 @@
+\name{modelFit-methods}
+\docType{methods}
+\alias{modelFit}
+\alias{modelFit-methods}
+\alias{modelFit,gmmModels-method}
+\alias{modelFit,formulaGmm-method}
+\alias{modelFit,sysGmmModels-method}
+\alias{modelFit,rlinearGmm-method}
+\alias{modelFit,rformulaGmm-method}
+\alias{modelFit,rslinearGmm-method}
+\alias{modelFit,rnonlinearGmm-method}
+\title{ ~~ Methods for Function \code{modelFit} in Package \pkg{gmm4} ~~}
+\description{
+Method to fit a model using GMM, from an object of class \code{"gmmModels"}.
+}
+\usage{
+\S4method{modelFit}{gmmModels}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, \dots)
+
+\S4method{modelFit}{formulaGmm}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, \dots)
+
+\S4method{modelFit}{sysGmmModels}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, EbyE=FALSE, \dots)
+
+\S4method{modelFit}{rnonlinearGmm}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, \dots)
+
+\S4method{modelFit}{rlinearGmm}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, \dots)
+
+\S4method{modelFit}{rformulaGmm}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, \dots)
+
+\S4method{modelFit}{rslinearGmm}(object, type=c("twostep", "iter","cue",
+ "onestep"), itertol=1e-7, initW=c("ident", "tsls", "EbyE"),
+ weights="optimal", itermaxit=100,
+ efficientWeights=FALSE, start=NULL, EbyE=FALSE, \dots)
+}
+\arguments{
+ \item{object}{An object of class \code{"gmmModels"}}
+ \item{type}{What GMM methods should we use? for
+ \code{type=="onestep"}, if \code{"weights"} is not a matrix, the
+ model will be estimated with the weights equals to the identity
+ matrix. For restricted }
+ \item{itertol}{Tolance for the stopping rule in iterative GMM}
+ \item{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, \code{"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 \code{"type"}.}
+ \item{weights}{What weighting matrix to use? The choices are
+ \code{"optimal"}, in which case it is the inverse of the moment
+ vovariance matrix, \code{"ident"} for the identity matrix, or a
+ fixed matrix. It is also possible for weights to be an object of
+ class \code{gmmWeights}.}
+ \item{itermaxit}{Maximum iterations for iterative GMM}
+ \item{efficientWeights}{If \code{weights} is a matrix or a
+ \code{gmmWeights} class object, setting \code{efficientWeights} to
+ \code{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.}
+ \item{start}{An optional initial vector for \code{\link{optim}} when
+ the model is nonlinear. By default, the theta0 argument of the model
+ is used}
+ \item{EbyE}{Should we estimate the system equation by equation?}
+ \item{\dots}{Arguments to pass to other methods}
+ }
+\section{Methods}{
+\describe{
+\item{\code{signature(object = "gmmModels")}}{
+The main method for all GMM-type models.
+}
+
+\item{\code{signature(object = "rnonlinearGmm")}}{
+It makes a difference only if the number of contraints is equal to the
+number of coefficients, in which case, the method \code{\link{evalGmm}}
+is called at the contrained vector. If not, the next method is called.
+}
+
+\item{\code{signature(object = "rformulaGmm")}}{
+It makes a difference only if the number of contraints is equal to the
+number of coefficients, in which case, the method \code{\link{evalGmm}}
+is called at the contrained vector. If not, the next method is called.
+}
+
+\item{\code{signature(object = "rlinearGmm")}}{
+It makes a difference only if the number of contraints is equal to the
+number of coefficients, in which case, the method \code{\link{evalGmm}}
+is called at the contrained vector. If not, the next method is called.
+}
+
+\item{\code{signature(object = "sysGmmModels")}}{
+Method to estimate system of equations using GMM methods.
+}
+
+}}
+\examples{
+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 <- restGmmModel(model1, R, q)
+modelFit(rmodel1)
+
+## Only one constraint
+R <- matrix(c(0,1), ncol=2)
+q <- 2
+rmodel1 <- restGmmModel(model1, R, q)
+modelFit(rmodel1)
+
+}
+\keyword{methods}
Modified: pkg/gmm4/man/residuals-methods.Rd
===================================================================
--- pkg/gmm4/man/residuals-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/residuals-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -47,7 +47,7 @@
e <- residuals(model1, theta)
## residuals of the fit
-res <- gmmFit(model1)
+res <- modelFit(model1)
e <- residuals(res)
}
Modified: pkg/gmm4/man/restGmmModel-methods.Rd
===================================================================
--- pkg/gmm4/man/restGmmModel-methods.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/restGmmModel-methods.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -93,7 +93,7 @@
R1 <- c("theta2=2", "theta3=theta4^2")
rmod1 <- restGmmModel(NLmodel, R1)
-res1 <- gmmFit(rmod1)
+res1 <- modelFit(rmod1)
res1
## recover the orignial form
coef(rmod1, coef(res1))
@@ -102,7 +102,7 @@
R2 <- list(theta2~2, theta3~1/theta4)
rmod2 <- restGmmModel(NLmodel, R2)
-res2 <- gmmFit(rmod2)
+res2 <- modelFit(rmod2)
res2
coef(rmod2, coef(res2))
Modified: pkg/gmm4/man/rgmmModels-class.Rd
===================================================================
--- pkg/gmm4/man/rgmmModels-class.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/rgmmModels-class.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -9,7 +9,7 @@
\section{Objects from the Class}{A virtual Class: No objects may be created from it.}
\section{Methods}{
\describe{
- \item{gmmFit}{\code{signature(object = "rgmmModels")}: ... }
+ \item{modelFit}{\code{signature(object = "rgmmModels")}: ... }
}
}
\seealso{
Modified: pkg/gmm4/man/rnonlinearGmm-class.Rd
===================================================================
--- pkg/gmm4/man/rnonlinearGmm-class.Rd 2018-09-14 17:54:19 UTC (rev 130)
+++ pkg/gmm4/man/rnonlinearGmm-class.Rd 2018-09-14 20:53:53 UTC (rev 131)
@@ -47,7 +47,7 @@
\describe{
\item{coef}{\code{signature(object = "rnonlinearGmm")}: ... }
\item{Dresiduals}{\code{signature(object = "rnonlinearGmm")}: ... }
- \item{gmmFit}{\code{signature(object = "rnonlinearGmm")}: ... }
+ \item{modelFit}{\code{signature(object = "rnonlinearGmm")}: ... }
\item{modelDims}{\code{signature(object = "rnonlinearGmm")}: ... }
\item{print}{\code{signature(x = "rnonlinearGmm")}: ... }
\item{residuals}{\code{signature(object = "rnonlinearGmm")}: ... }
Modified: pkg/gmm4/man/smoothGel.Rd
===================================================================
--- pkg/gmm4/man/smoothGel.Rd 2018-09-14 17:54:19 UTC (rev 130)
[TRUNCATED]
To get the complete diff run:
svnlook diff /svnroot/gmm -r 131
More information about the Gmm-commits
mailing list