[Gmm-commits] r227 - in pkg/momentfit: . R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Feb 21 20:47:21 CET 2024
Author: chaussep
Date: 2024-02-21 20:47:21 +0100 (Wed, 21 Feb 2024)
New Revision: 227
Modified:
pkg/momentfit/NAMESPACE
pkg/momentfit/R/momentModel-methods.R
pkg/momentfit/R/momentModel.R
pkg/momentfit/R/weak.R
pkg/momentfit/man/weakTest.Rd
Log:
working on weak instrument test again. Added the df adjustment to HAC
Modified: pkg/momentfit/NAMESPACE
===================================================================
--- pkg/momentfit/NAMESPACE 2024-02-16 22:44:26 UTC (rev 226)
+++ pkg/momentfit/NAMESPACE 2024-02-21 19:47:21 UTC (rev 227)
@@ -19,7 +19,7 @@
"constrOptim", "kernel", "confint", "qnorm", "uniroot", "getCall", "qchisq", "optimize")
importFrom("sandwich", "vcovHAC", "estfun","kernHAC","vcovCL", "meatCL",
"bread","bwAndrews","bwNeweyWest","weightsAndrews",
- "weightsLumley", "vcovHC")
+ "weightsLumley", "vcovHC", "meatHAC")
### S4 Methods and Classes
exportClasses("nonlinearModel", "linearModel", "functionModel", "momentModel",
Modified: pkg/momentfit/R/momentModel-methods.R
===================================================================
--- pkg/momentfit/R/momentModel-methods.R 2024-02-16 22:44:26 UTC (rev 226)
+++ pkg/momentfit/R/momentModel-methods.R 2024-02-21 19:47:21 UTC (rev 227)
@@ -546,9 +546,9 @@
}
weights <- weightsAndrews(x = gmat, bw = bw, kernel = options$kernel,
prewhite = options$prewhite, tol = options$tol)
- w <- vcovHAC(x = gmat, order.by = NULL, weights = weights,
- prewhite = options$prewhite, sandwich = FALSE,
- ar.method = options$ar.method)
+ w <- meatHAC(x = gmat, order.by = NULL, weights = weights,
+ prewhite = options$prewhite, ar.method = options$ar.method,
+ adjust = options$adjust, diagnostics = FALSE)
attr(w, "Spec") <- list(weights = weights, bw = bw, kernel = options$kernel)
w
})
Modified: pkg/momentfit/R/momentModel.R
===================================================================
--- pkg/momentfit/R/momentModel.R 2024-02-16 22:44:26 UTC (rev 226)
+++ pkg/momentfit/R/momentModel.R 2024-02-21 19:47:21 UTC (rev 227)
@@ -9,7 +9,7 @@
crit = 1e-06,
bw = "Andrews", prewhite = 1L,
ar.method = "ols", approx = "AR(1)",
- tol = 1e-07)
+ tol = 1e-07, adjust=TRUE)
if (length(addO) > 0)
{
if (!all(names(addO) %in% names(option)))
Modified: pkg/momentfit/R/weak.R
===================================================================
--- pkg/momentfit/R/weak.R 2024-02-16 22:44:26 UTC (rev 226)
+++ pkg/momentfit/R/weak.R 2024-02-21 19:47:21 UTC (rev 227)
@@ -594,7 +594,8 @@
LewMertest <- function(object, tau=0.10, size=0.05, print=TRUE,
estMethod = c("TSLS", "LIML"), simplified = TRUE,
- digits = max(3L, getOption("digits") - 3L), ...)
+ digits = max(3L, getOption("digits") - 3L),
+ dfCorr = TRUE, ...)
{
estMethod <- match.arg(estMethod)
if (!inherits(object, "linearModel"))
@@ -631,6 +632,8 @@
v <- cbind(y-Z2%*%b1, X2-Z2%*%Pi2)
omega <- crossprod(v)/nrow(v)
w <- vcov(m, c(list(b1),lapply(1:ncol(Pi2), function(i) Pi2[,i])))
+ if (dfCorr)
+ w <- w*nrow(Z2)/(nrow(Z2)-ncol(X1)-ncol(Z2))
w2 <- w[(ncol(Z2)+1):ncol(w),(ncol(Z2)+1):ncol(w)]
phi <- phiMat(w2, ncol(X2), ncol(Z2))
if (dim(phi)[1] == 1)
Modified: pkg/momentfit/man/weakTest.Rd
===================================================================
--- pkg/momentfit/man/weakTest.Rd 2024-02-16 22:44:26 UTC (rev 226)
+++ pkg/momentfit/man/weakTest.Rd 2024-02-21 19:47:21 UTC (rev 227)
@@ -28,7 +28,8 @@
LewMertest(object, tau=0.10, size=0.05, print=TRUE,
estMethod = c("TSLS", "LIML"), simplified = TRUE,
- digits = max(3L, getOption("digits") - 3L), ...)
+ digits = max(3L, getOption("digits") - 3L),
+ dfCorr = TRUE, ...)
SYTables(object, print=TRUE, SWcrit=FALSE)
@@ -62,10 +63,13 @@
below for details on what the functions return when it is set to
\code{FALSE}
}
-
+
\item{digits}{The number of digits to print when \code{print} is set
to \code{TRUE}.}
+\item{dfCorr}{Should we correct the covariance matrix estimator for the
+ degrees of freedom?}
+
\item{SWcrit}{If true, the critical values and the test are ajusted to
Sanderson and Windmeijer (2016). See details.}
More information about the Gmm-commits
mailing list