[Gmm-commits] r242 - in pkg/momentfit: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Jun 18 17:35:50 CEST 2025
Author: chaussep
Date: 2025-06-18 17:35:49 +0200 (Wed, 18 Jun 2025)
New Revision: 242
Modified:
pkg/momentfit/DESCRIPTION
pkg/momentfit/R/momentData.R
pkg/momentfit/R/momentModel.R
pkg/momentfit/R/sysMomentModel-methods.R
pkg/momentfit/man/gel4.Rd
pkg/momentfit/man/gmm4.Rd
pkg/momentfit/man/momentModel.Rd
pkg/momentfit/man/sysMomentModel.Rd
Log:
fixed a bug for systems of equations with HAC vcov
Modified: pkg/momentfit/DESCRIPTION
===================================================================
--- pkg/momentfit/DESCRIPTION 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/DESCRIPTION 2025-06-18 15:35:49 UTC (rev 242)
@@ -1,8 +1,10 @@
Package: momentfit
Version: 1.0
-Date: 2024-05-27
+Date: 2025-06-17
Title: Methods of Moments
-Author: Pierre Chausse <pchausse at uwaterloo.ca>
+Authors at R: person(given="Pierre", family="Chausse", role=c("aut","cre"),
+ email="pchausse at uwaterloo.ca")
+Author: Pierre Chausse [aut, cre]
Maintainer: Pierre Chausse <pchausse at uwaterloo.ca>
Description: Several classes for moment-based models are defined. The classes are defined for moment conditions derived from a single equation or a system of equations. The conditions can also be expressed as functions or formulas. Several methods are also offered to facilitate the development of different estimation techniques. The methods that are currently provided are the Generalized method of moments (Hansen 1982; <doi:10.2307/1912775>), for single equations and systems of equation, and the Generalized Empirical Likelihood (Smith 1997; <doi:10.1111/j.0013-0133.1997.174.x>, Kitamura 1997; <doi:10.1214/aos/1069362388>, Newey and Smith 2004; <doi:10.1111/j.1468-0262.2004.00482.x>, and Anatolyev 2005 <doi:10.1111/j.1468-0262.2005.00601.x>).Some work is being done to add tools to deal with weak and/or many instruments. This include K-Class estimators (LIML and Fuller), Anderson and Rubin statistics test, etc.
Depends: R (>= 3.5), sandwich
Modified: pkg/momentfit/R/momentData.R
===================================================================
--- pkg/momentfit/R/momentData.R 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/R/momentData.R 2025-06-18 15:35:49 UTC (rev 242)
@@ -49,8 +49,9 @@
{
modelF <- model.frame(formula, data, na.action="na.pass",
drop.unused.levels=TRUE)
+
if (is.matrix(modelF[[1]]))
- return(.multiToSys(formula, h, data))
+ return(.multiToSys(formula, h, data, survOptions, vcovOptions, na.action))
parNames <- colnames(model.matrix(attr(modelF, "terms"), modelF))
k <- length(parNames)
if (any(class(h) == "formula"))
Modified: pkg/momentfit/R/momentModel.R
===================================================================
--- pkg/momentfit/R/momentModel.R 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/R/momentModel.R 2025-06-18 15:35:49 UTC (rev 242)
@@ -130,7 +130,7 @@
{
model <- .lModelData(g,x,data, survOptions, vcovOptions, na.action)
if (!is.null(model$eqnNames))
- {
+ {
gmodel <- new("slinearModel", data = model$data,
instT=model$instT,
modelT = model$modelT, vcov = vcov,
Modified: pkg/momentfit/R/sysMomentModel-methods.R
===================================================================
--- pkg/momentfit/R/sysMomentModel-methods.R 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/R/sysMomentModel-methods.R 2025-06-18 15:35:49 UTC (rev 242)
@@ -533,6 +533,7 @@
sameMom <- object at sameMom
n <- object at n
neqn <- length(spec$eqnNames)
+ wSpec <- list()
if (is.matrix(w))
{
if (!all(dim(w) == sum(spec$q)))
@@ -573,10 +574,13 @@
w <- qr(do.call(cbind, gt)/sqrt(n))
Sigma <- NULL
} else {
- stop("Only identity, iid and MDS if allowed for now")
+ w <- vcovHAC(object, theta)
+ wSpec <- attr(w,"Spec")
+ type <- "vcov"
+ Sigma <- NULL
}
return(new("sysMomentWeights", type=type,momNames=object at momNames,
- wSpec=list(), w=w, Sigma=Sigma, sameMom=sameMom,
+ wSpec=wSpec, w=w, Sigma=Sigma, sameMom=sameMom,
eqnNames=object at eqnNames))
})
Modified: pkg/momentfit/man/gel4.Rd
===================================================================
--- pkg/momentfit/man/gel4.Rd 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/man/gel4.Rd 2025-06-18 15:35:49 UTC (rev 242)
@@ -52,7 +52,7 @@
respect to \eqn{\theta}.}
\item{vcovOptions}{A list of options for the covariance matrix of the
- moment conditions. See \code{\link{vcovHAC}} for the default values.}
+ moment conditions. See \code{\link[sandwich]{vcovHAC}} for the default values.}
\item{centeredVcov}{Should the moment function be centered when
computing its covariance matrix. Doing so may improve inference.}
Modified: pkg/momentfit/man/gmm4.Rd
===================================================================
--- pkg/momentfit/man/gmm4.Rd 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/man/gmm4.Rd 2025-06-18 15:35:49 UTC (rev 242)
@@ -72,7 +72,7 @@
ready to make that assumption. The option "TrueFixed" is used only
when the matrix of weights is provided and it is the optimal one. For
type \code{CL}, clustered covariance matrix is computed. The options
- are then included in \code{vcovOptions} (see \code{\link{meatCL}}).}
+ are then included in \code{vcovOptions} (see \code{\link[sandwich]{meatCL}}).}
\item{initW}{How should be compute the initial coefficient vector in
the first. It only makes a difference for linear models for which
@@ -99,7 +99,7 @@
coefficients. See \code{\link{restModel}} for more details.}
\item{vcovOptions}{A list of options for the covariance matrix of the
- moment conditions. See \code{\link{vcovHAC}} for the default values.}
+ moment conditions. See \code{\link[sandwich]{vcovHAC}} for the default values.}
\item{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
Modified: pkg/momentfit/man/momentModel.Rd
===================================================================
--- pkg/momentfit/man/momentModel.Rd 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/man/momentModel.Rd 2025-06-18 15:35:49 UTC (rev 242)
@@ -52,10 +52,10 @@
\code{MDS} only when \code{g} is a formula. In that case, residuals
are assumed homoscedastic as well as serially uncorrelated. For type
\code{CL}, clustered covariance matrix is computed. The options are
- then included in \code{vcovOptions} (see \code{\link{meatCL}}). }
+ then included in \code{vcovOptions} (see \code{\link[sandwich]{meatCL}}). }
\item{vcovOptions}{A list of options for the covariance matrix of the
- moment conditions. See \code{\link{vcovHAC}} for the default values.}
+ moment conditions. See \code{\link[sandwich]{vcovHAC}} for the default values.}
\item{centeredVcov}{Should the moment function be centered when
computing its covariance matrix. Doing so may improve inference.}
Modified: pkg/momentfit/man/sysMomentModel.Rd
===================================================================
--- pkg/momentfit/man/sysMomentModel.Rd 2024-07-04 19:19:48 UTC (rev 241)
+++ pkg/momentfit/man/sysMomentModel.Rd 2025-06-18 15:35:49 UTC (rev 242)
@@ -39,10 +39,10 @@
\code{MDS} only when \code{g} is a formula. In that case, residuals
are assumed homoscedastic as well as serially uncorrelated. For type
\code{CL}, clustered covariance matrix is computed. The options are
- then included in \code{vcovOptions} (see \code{\link{meatCL}}).}
+ then included in \code{vcovOptions} (see \code{\link[sandwich]{meatCL}}).}
\item{vcovOptions}{A list of options for the covariance matrix of the
- moment conditions. See \code{\link{vcovHAC}} for the default values.}
+ moment conditions. See \code{\link[sandwich]{vcovHAC}} for the default values.}
\item{centeredVcov}{Should the moment function be centered when
computing its covariance matrix. Doing so may improve inference.}
More information about the Gmm-commits
mailing list