[Gmm-commits] r135 - in pkg/gmm4: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Sep 26 16:34:00 CEST 2018
Author: chaussep
Date: 2018-09-26 16:34:00 +0200 (Wed, 26 Sep 2018)
New Revision: 135
Modified:
pkg/gmm4/R/allClasses.R
pkg/gmm4/R/gmmData.R
pkg/gmm4/R/gmmModel.R
pkg/gmm4/R/sysGmmModel.R
pkg/gmm4/man/formulaGel-class.Rd
pkg/gmm4/man/formulaGmm-class.Rd
pkg/gmm4/man/functionGel-class.Rd
pkg/gmm4/man/functionGmm-class.Rd
pkg/gmm4/man/linearGel-class.Rd
pkg/gmm4/man/linearGmm-class.Rd
pkg/gmm4/man/nonlinearGel-class.Rd
pkg/gmm4/man/nonlinearGmm-class.Rd
pkg/gmm4/man/slinearGmm-class.Rd
pkg/gmm4/man/snonlinearGmm-class.Rd
Log:
added omit slot to all model classes
Modified: pkg/gmm4/R/allClasses.R
===================================================================
--- pkg/gmm4/R/allClasses.R 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/R/allClasses.R 2018-09-26 14:34:00 UTC (rev 135)
@@ -15,7 +15,8 @@
vcov="character",n="integer", q="integer", k="integer",
parNames="character", momNames="character",
vcovOptions="list", centeredVcov="logical",
- varNames="character", isEndo="logical"))
+ varNames="character", isEndo="logical",
+ omit='integer'))
setClass("nonlinearGmm", representation(modelF="data.frame", instF="data.frame",
vcov="character",theta0="numeric",
n="integer", q="integer",k="integer",
@@ -23,14 +24,14 @@
fRHS="expression", fLHS="expressionORNULL",
vcovOptions="list",
centeredVcov="logical", varNames="character",
- isEndo="logical"))
+ isEndo="logical",omit='integer'))
setClass("functionGmm", representation(X="ANY", fct="function",dfct="functionORNULL",
vcov="character",theta0="numeric",
n="integer", q="integer",k="integer",
parNames="character", momNames="character",
vcovOptions="list",
centeredVcov="logical", varNames="character",
- isEndo="logical"))
+ isEndo="logical",omit='integer'))
setClass("formulaGmm", representation(modelF="data.frame",
vcov="character",theta0="numeric",
n="integer", q="integer",k="integer",
@@ -38,7 +39,7 @@
fRHS="list", fLHS="list",
vcovOptions="list",
centeredVcov="logical", varNames="character",
- isEndo="logical", isMDE="logical"))
+ isEndo="logical", isMDE="logical",omit='integer'))
setClassUnion("regGmm", c("linearGmm", "nonlinearGmm"))
setClassUnion("allNLGmm", c("nonlinearGmm", "functionGmm", "formulaGmm"))
setClassUnion("gmmModels", c("linearGmm", "nonlinearGmm", "functionGmm", "formulaGmm"))
@@ -123,7 +124,8 @@
momNames="list", eqnNames="character",
vcovOptions="list",
centeredVcov="logical", sameMom="logical",
- SUR="logical", varNames="list", isEndo="list"))
+ SUR="logical", varNames="list", isEndo="list",
+ omit='integer'))
setClass("snonlinearGmm", representation(data="data.frame", instT="list",
vcov="character",theta0="list",
@@ -133,7 +135,8 @@
vcovOptions="list",
centeredVcov="logical", sameMom="logical",
SUR="logical",
- varNames="list", isEndo="list"))
+ varNames="list", isEndo="list",
+ omit='integer'))
setClassUnion("sysGmmModels", c("slinearGmm", "snonlinearGmm"))
## Restricted System GMM
@@ -178,7 +181,7 @@
theta0=theta0, n=spec$n, q=spec$q, k=spec$k, parNames=names(theta0),
momNames=spec$momNames, fRHS=rhs, fLHS=lhs,
vcovOptions=from at vcovOptions, centeredVcov=from at centeredVcov,
- isEndo=from at isEndo, varNames=from at varNames)
+ isEndo=from at isEndo, varNames=from at varNames,omit=from at omit)
})
setAs("linearGmm", "functionGmm",
@@ -200,7 +203,7 @@
new("functionGmm", X=x, fct=fct, dfct=dfct, vcov=from at vcov,
theta0=theta0, n=spec$n, q=spec$q, k=spec$k, parNames=names(theta0),
momNames=spec$momNames,vcovOptions=from at vcovOptions,
- centeredVcov=from at centeredVcov)
+ centeredVcov=from at centeredVcov,omit=integer())
})
setAs("allNLGmm", "functionGmm",
@@ -221,7 +224,7 @@
theta0=from at theta0, n=spec$n, q=spec$q, k=spec$k,
parNames=names(from at theta0),
momNames=spec$momNames, vcovOptions=from at vcovOptions,
- centeredVcov=from at centeredVcov)
+ centeredVcov=from at centeredVcov,omit=integer())
})
setAs("slinearGmm", "linearGmm",
Modified: pkg/gmm4/R/gmmData.R
===================================================================
--- pkg/gmm4/R/gmmData.R 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/R/gmmData.R 2018-09-26 14:34:00 UTC (rev 135)
@@ -77,19 +77,19 @@
momNames <- colnames(model.matrix(terms(instF), instF))
q <- length(momNames)
isEndo <- !(parNames %in% momNames)
- na <- attr(na.omit(cbind(modelF, instF)), "na.action")
+ na <- attr(na.omit(cbind(modelF, instF)), "na.action")[]
if (!is.null(na) && omit)
{
modelF <- modelF[-na,,drop=FALSE]
instF <- instF[-na,,drop=FALSE]
}
+ if (is.null(na))
+ na <- integer()
n <- nrow(modelF)
list(modelF=modelF, instF=instF, n=n, k=k, q=q, momNames=momNames,
parNames=parNames, isEndo=isEndo, varNames=parNames, na.action=na)
}
-
-
.formGmmData <- function(formula, tet0, data,omit=TRUE)
{
res <- lapply(formula, function(f) .nlGmmData(f, ~1, tet0, data))
@@ -103,9 +103,11 @@
isMDE <- all(chkLHS) | all(chkRHS)
modelF <- sapply(varNames, function(n) data[[n]])
modelF <- as.data.frame(modelF)
- na <- attr(na.omit(modelF), "na.action")
+ na <- attr(na.omit(modelF), "na.action")[]
if (!is.null(na) && omit)
modelF <- modelF[-na,,drop=FALSE]
+ if (is.null(na))
+ na <- integer()
k <- length(tet0)
q <- length(formula)
if (is.null(names(formula)))
@@ -175,12 +177,14 @@
momNames <- colnames(model.matrix(terms(instF), instF))
isEndo <- !(varNames %in% momNames)
q <- length(momNames)
- na <- attr(na.omit(cbind(modelF, instF)), "na.action")
+ na <- attr(na.omit(cbind(modelF, instF)), "na.action")[]
if (!is.null(na) && omit)
{
modelF <- modelF[-na,,drop=FALSE]
instF <- instF[-na,,drop=FALSE]
}
+ if (is.null(na))
+ na <- integer()
n <- nrow(modelF)
list(modelF=modelF, instF=instF, fRHS=fRHS, fLHS=fLHS, n=n, k=k, q=q,
momNames=momNames, parNames=parNames, varNames=varNames, isEndo=isEndo,
@@ -198,8 +202,10 @@
if (any(class(mom)=="try-error"))
{
msg <- paste("Cannot evaluate the moments at thet0\n",
- attr(mom,"conditon"))
+ attr(mom,"condition"))
stop(msg)
+ } else if (any(is.na(mom))) {
+ stop("Some moments are NA's. Make sure you remove missing values from x")
} else {
q <- ncol(mom)
n <- nrow(mom)
@@ -209,7 +215,7 @@
momNames <- paste("h", 1:q, sep="")
}
list(q=q,n=n,k=k, momNames=momNames, parNames=parNames,
- varNames=character(), isEndo=logical())
+ varNames=character(), isEndo=logical(), na.action=integer())
}
.slGmmData <- function(g,h,data,omit=TRUE)
@@ -220,9 +226,11 @@
allDat <- do.call(cbind, lapply(res, function(x) cbind(x$modelF, x$instF)))
allDat <- allDat[,!duplicated(colnames(allDat))]
allDat <- na.omit(allDat)
- na <- attr(allDat, "na.action")
+ na <- attr(allDat, "na.action")[]
if (omit && !is.null(na))
allDat <- allDat[-na,]
+ if (is.null(na))
+ na <- integer()
parNames <- lapply(1:length(g), function(i) res[[i]]$parNames)
momNames <- lapply(1:length(g), function(i) res[[i]]$momNames)
isEndo <- lapply(1:length(g), function(i) res[[i]]$isEndo)
@@ -249,9 +257,11 @@
allDat <- do.call(cbind, lapply(res, function(x) cbind(x$modelF, x$instF)))
allDat <- allDat[,!duplicated(colnames(allDat))]
allDat <- na.omit(allDat)
- na <- attr(allDat, "na.action")
+ na <- attr(allDat, "na.action")[]
if (omit && !is.null(na))
allDat <- allDat[-na,]
+ if (is.null(na))
+ na <- integer()
parNames <- lapply(1:length(g), function(i) res[[i]]$parNames)
momNames <- lapply(1:length(g), function(i) res[[i]]$momNames)
isEndo <- lapply(1:length(g), function(i) res[[i]]$isEndo)
Modified: pkg/gmm4/R/gmmModel.R
===================================================================
--- pkg/gmm4/R/gmmModel.R 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/R/gmmModel.R 2018-09-26 14:34:00 UTC (rev 135)
@@ -69,7 +69,7 @@
momNames = model$momNames,eqnNames=model$eqnNames,
sameMom = TRUE, SUR = FALSE,
varNames = model$varNames,
- isEndo = model$isEndo)
+ isEndo = model$isEndo, omit=model$na.action)
else
gmodel <- new("linearGmm", modelF=model$modelF,
instF=model$instF,
@@ -77,7 +77,7 @@
centeredVcov = centeredVcov, k=model$k,
q=model$q, n=model$n, parNames=model$parNames,
momNames=model$momNames, varNames=model$varNames,
- isEndo=model$isEndo)
+ isEndo=model$isEndo, omit=model$na.action)
} else {
if (!all(chk))
stop("All parameters in tet0 must be in g for nl Gmm")
@@ -88,7 +88,7 @@
centeredVcov = centeredVcov, k=model$k, q=model$q,
n=model$n, parNames=model$parNames,
momNames=model$momNames, varNames=model$varNames,
- isEndo=model$isEndo)
+ isEndo=model$isEndo, omit=model$na.action)
}
} else if (class(g)=="function") {
model <- .fGmmData(g, x, tet0)
@@ -97,7 +97,7 @@
centeredVcov = centeredVcov, k=model$k, q=model$q,
n=model$n, parNames=model$parNames,
momNames=model$momNames, varNames=model$varNames,
- isEndo=model$isEndo)
+ isEndo=model$isEndo, omit=model$na.action)
} else {
if (!is.null(x))
stop("For formula GMM, x must be NULL. The moments are only defined as a list of formulas")
@@ -112,7 +112,7 @@
centeredVcov = centeredVcov, k=model$k, q=model$q,
n=model$n, parNames=model$parNames,
momNames=model$momNames, varNames=model$varNames,
- isEndo=model$isEndo, isMDE=model$isMDE)
+ isEndo=model$isEndo, isMDE=model$isMDE, omit=model$na.action)
}
gmodel
}
Modified: pkg/gmm4/R/sysGmmModel.R
===================================================================
--- pkg/gmm4/R/sysGmmModel.R 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/R/sysGmmModel.R 2018-09-26 14:34:00 UTC (rev 135)
@@ -95,7 +95,7 @@
q=model$q, n=model$n, parNames=model$parNames,
momNames=model$momNames, eqnNames=model$eqnNames,
sameMom=sameMom, SUR=SUR, varNames=model$varNames,
- isEndo=model$isEndo)
+ isEndo=model$isEndo, omit=model$na.action)
} else {
model <- .snlGmmData(g, h, tet0, data)
gmodel <- new("snonlinearGmm", data=model$data, instT=model$instT,
@@ -104,7 +104,7 @@
centeredVcov = centeredVcov, k=model$k, q=model$q,
n=model$n, parNames=model$parNames,
momNames=model$momNames, sameMom=sameMom, SUR=SUR,
- varNames=model$varNames, isEndo=model$isEndo)
+ varNames=model$varNames, isEndo=model$isEndo, omit=model$na.action)
}
gmodel
}
Modified: pkg/gmm4/man/formulaGel-class.Rd
===================================================================
--- pkg/gmm4/man/formulaGel-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/formulaGel-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -29,6 +29,7 @@
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
\item{\code{isMDE}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
Modified: pkg/gmm4/man/formulaGmm-class.Rd
===================================================================
--- pkg/gmm4/man/formulaGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/formulaGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -27,6 +27,7 @@
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
\item{\code{isMDE}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
Modified: pkg/gmm4/man/functionGel-class.Rd
===================================================================
--- pkg/gmm4/man/functionGel-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/functionGel-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -28,6 +28,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/functionGmm-class.Rd
===================================================================
--- pkg/gmm4/man/functionGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/functionGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -26,6 +26,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/linearGel-class.Rd
===================================================================
--- pkg/gmm4/man/linearGel-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/linearGel-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -26,6 +26,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/linearGmm-class.Rd
===================================================================
--- pkg/gmm4/man/linearGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/linearGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -24,6 +24,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/nonlinearGel-class.Rd
===================================================================
--- pkg/gmm4/man/nonlinearGel-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/nonlinearGel-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -29,6 +29,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/nonlinearGmm-class.Rd
===================================================================
--- pkg/gmm4/man/nonlinearGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/nonlinearGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -27,6 +27,7 @@
\item{\code{centeredVcov}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"character"} ~~ }
\item{\code{isEndo}:}{Object of class \code{"logical"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/slinearGmm-class.Rd
===================================================================
--- pkg/gmm4/man/slinearGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/slinearGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -28,7 +28,8 @@
\item{\code{SUR}:}{Object of class \code{"logical"} ~~}
\item{\code{sameMom}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"list"} ~~ }
- \item{\code{isEndo}:}{Object of class \code{"list"} ~~ }
+ \item{\code{isEndo}:}{Object of class \code{"list"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
Modified: pkg/gmm4/man/snonlinearGmm-class.Rd
===================================================================
--- pkg/gmm4/man/snonlinearGmm-class.Rd 2018-09-21 21:16:45 UTC (rev 134)
+++ pkg/gmm4/man/snonlinearGmm-class.Rd 2018-09-26 14:34:00 UTC (rev 135)
@@ -30,7 +30,8 @@
\item{\code{SUR}:}{Object of class \code{"logical"} ~~}
\item{\code{sameMom}:}{Object of class \code{"logical"} ~~ }
\item{\code{varNames}:}{Object of class \code{"list"} ~~ }
- \item{\code{isEndo}:}{Object of class \code{"list"} ~~ }
+ \item{\code{isEndo}:}{Object of class \code{"list"} ~~ }
+ \item{\code{omit}:}{Object of class \code{"integer"} ~~ }
}
}
\section{Extends}{
More information about the Gmm-commits
mailing list