[Gmm-commits] r112 - in pkg/gmm: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Fri Jul 7 19:07:21 CEST 2017
Author: chaussep
Date: 2017-07-07 19:07:20 +0200 (Fri, 07 Jul 2017)
New Revision: 112
Modified:
pkg/gmm/NEWS
pkg/gmm/R/ategel.R
pkg/gmm/R/gel.R
pkg/gmm/R/gmm.R
pkg/gmm/R/momentEstim.R
pkg/gmm/man/gel.Rd
pkg/gmm/man/gmm.Rd
Log:
Added the option to avoid the computation of the covariance matrix
Modified: pkg/gmm/NEWS
===================================================================
--- pkg/gmm/NEWS 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/NEWS 2017-07-07 17:07:20 UTC (rev 112)
@@ -1,3 +1,9 @@
+Changes in version 1.6-2
+
+o Fixed a bug with iterative GMM from the previous version
+o Added the option onlyCoefficients=FALSE to gmm() and gel(). If set to TRUE, no covariance matrix is computed. Only the coefficients
+ objective and the lambdas (for gel only) are returned.
+
Changes in version 1.6-1
o Added the function bwWilhelm() to compute the optimal bandwidth of Wilhelm(2015).
Modified: pkg/gmm/R/ategel.R
===================================================================
--- pkg/gmm/R/ategel.R 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/R/ategel.R 2017-07-07 17:07:20 UTC (rev 112)
@@ -24,7 +24,7 @@
approx = "AR(1)", prewhite = 1, ar.method = "ols",
tol_weights = 1e-7, alpha = NULL, eqConst = NULL,
eqConstFullVcov = FALSE, momType=momType, popMom=popMom,
- family=family)
+ family=family, onlyCoefficients=FALSE)
class(all_args)<-TypeGel
Model_info<-getModel(all_args)
z <- momentEstim(Model_info, ...)
Modified: pkg/gmm/R/gel.R
===================================================================
--- pkg/gmm/R/gel.R 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/R/gel.R 2017-07-07 17:07:20 UTC (rev 112)
@@ -281,7 +281,7 @@
optfct = c("optim", "optimize", "nlminb"),
optlam = c("nlminb", "optim", "iter", "Wu"), data, Lambdacontrol = list(),
model = TRUE, X = FALSE, Y = FALSE, TypeGel = "baseGel", alpha = NULL,
- eqConst = NULL, eqConstFullVcov = FALSE, ...)
+ eqConst = NULL, eqConstFullVcov = FALSE, onlyCoefficients=FALSE, ...)
{
type <- match.arg(type)
optfct <- match.arg(optfct)
@@ -303,12 +303,12 @@
optlam = optlam, model = model, X = X, Y = Y,
TypeGel = TypeGel, call = match.call(),
Lambdacontrol = Lambdacontrol, alpha = alpha, data = data,
- eqConst = eqConst, eqConstFullVcov = eqConstFullVcov)
+ eqConst = eqConst, eqConstFullVcov = eqConstFullVcov, onlyCoefficients=onlyCoefficients)
class(all_args)<-TypeGel
Model_info<-getModel(all_args)
z <- momentEstim(Model_info, ...)
-
- class(z) <- "gel"
+ if (!onlyCoefficients)
+ class(z) <- "gel"
return(z)
}
Modified: pkg/gmm/R/gmm.R
===================================================================
--- pkg/gmm/R/gmm.R 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/R/gmm.R 2017-07-07 17:07:20 UTC (rev 112)
@@ -15,7 +15,7 @@
kernel=c("Quadratic Spectral","Truncated", "Bartlett", "Parzen", "Tukey-Hanning"),crit=10e-7,bw = bwAndrews,
prewhite = 1, ar.method = "ols", approx="AR(1)",tol = 1e-7, itermax=100,optfct=c("optim","optimize","nlminb", "constrOptim"),
model=TRUE, X=FALSE, Y=FALSE, TypeGmm = "baseGmm", centeredVcov = TRUE, weightsMatrix = NULL, traceIter = FALSE, data, eqConst = NULL,
- eqConstFullVcov = FALSE, mustar = NULL, ...)
+ eqConstFullVcov = FALSE, mustar = NULL, onlyCoefficients=FALSE, ...)
{
type <- match.arg(type)
kernel <- match.arg(kernel)
@@ -41,7 +41,8 @@
class(all_args)<-TypeGmm
Model_info<-getModel(all_args, ...)
z <- momentEstim(Model_info, ...)
-
+ if (onlyCoefficients)
+ return(z[c("coefficients","objective")])
z <- FinRes(z, Model_info)
z
}
Modified: pkg/gmm/R/momentEstim.R
===================================================================
--- pkg/gmm/R/momentEstim.R 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/R/momentEstim.R 2017-07-07 17:07:20 UTC (rev 112)
@@ -757,8 +757,11 @@
z$typeDesc <- P$typeDesc
z$specMod <- P$specMod
z$df <- df
+ names(z$coefficients) <- object$namesCoef
+ if (P$onlyCoefficients)
+ return(z[c("coefficients","lambda","conv_lambda","conv_par","objective")])
- names(z$coefficients) <- object$namesCoef
+
if (!is.null(object$namesgt))
{
colnames(z$gt) <- object$namesgt
@@ -880,6 +883,9 @@
attr(x,"eqConst") <- NULL
z$specMod <- paste(z$specMod, "** Note: Covariance matrix computed for all coefficients based on restricted values \n Tests non-valid**\n\n")
}
+ if (P$onlyCoefficients)
+ return(z[c("coefficients", "lambda", "conv_lambda", "conv_par", "objective")])
+
if(P$gradvf)
G <- P$gradv(z$coefficients, x)
else
Modified: pkg/gmm/man/gel.Rd
===================================================================
--- pkg/gmm/man/gel.Rd 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/man/gel.Rd 2017-07-07 17:07:20 UTC (rev 112)
@@ -18,7 +18,7 @@
"nlminb"), optlam = c("nlminb", "optim", "iter", "Wu"), data,
Lambdacontrol = list(), model = TRUE, X = FALSE, Y = FALSE,
TypeGel = "baseGel", alpha = NULL, eqConst = NULL,
- eqConstFullVcov = FALSE, ...)
+ eqConstFullVcov = FALSE, onlyCoefficients=FALSE, ...)
evalGel(g, x, tet0, gradv = NULL, smooth = FALSE,
type = c("EL", "ET", "CUE", "ETEL", "HD", "ETHD"),
kernel = c("Truncated", "Bartlett"), bw = bwAndrews,
@@ -89,6 +89,9 @@
\item{eqConstFullVcov}{If FALSE, the constrained coefficients are assumed to be fixed and only the covariance of the unconstrained coefficients is computed. If TRUE, the covariance matrix of the full set of coefficients is computed.}
+\item{onlyCoefficients}{If \code{TRUE}, only the vector of coefficients
+ and Lagrange multipliers are returned}
+
\item{...}{More options to give to \code{\link{optim}}, \code{\link{optimize}} or \code{\link{constrOptim}}.}
}
Modified: pkg/gmm/man/gmm.Rd
===================================================================
--- pkg/gmm/man/gmm.Rd 2017-06-18 12:56:45 UTC (rev 111)
+++ pkg/gmm/man/gmm.Rd 2017-07-07 17:07:20 UTC (rev 112)
@@ -17,7 +17,7 @@
tol = 1e-7, itermax=100,optfct=c("optim","optimize","nlminb", "constrOptim"),
model=TRUE, X=FALSE, Y=FALSE, TypeGmm = "baseGmm", centeredVcov = TRUE,
weightsMatrix = NULL, traceIter = FALSE, data, eqConst = NULL,
- eqConstFullVcov = FALSE, mustar = NULL, ...)
+ eqConstFullVcov = FALSE, mustar = NULL, onlyCoefficients=FALSE, ...)
evalGmm(g, x, t0, tetw=NULL, gradv=NULL, wmatrix = c("optimal","ident"),
vcov=c("HAC","iid","TrueFixed"), kernel=c("Quadratic Spectral","Truncated",
"Bartlett", "Parzen", "Tukey-Hanning"),crit=10e-7,bw = bwAndrews,
@@ -96,6 +96,10 @@
procedure.
}
+\item{onlyCoefficients}{If set to \code{TRUE}, the function only returns
+ the coefficient estimates. It may be of interest when the standard
+ errors are not needed}
+
\item{...}{More options to give to \code{\link{optim}}.}
}
More information about the Gmm-commits
mailing list