[Gmm-commits] r176 - in pkg: causalGel causalGel/R causalGel/man causalGel/vignettes momentfit momentfit/R momentfit/man momentfit/vignettes

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Nov 4 22:55:14 CET 2020


Author: chaussep
Date: 2020-11-04 22:55:14 +0100 (Wed, 04 Nov 2020)
New Revision: 176

Modified:
   pkg/causalGel/DESCRIPTION
   pkg/causalGel/R/causalGel.R
   pkg/causalGel/man/causalGEL.Rd
   pkg/causalGel/man/causalGelfit-class.Rd
   pkg/causalGel/vignettes/causalGel.pdf
   pkg/momentfit/DESCRIPTION
   pkg/momentfit/R/allClasses.R
   pkg/momentfit/R/gel.R
   pkg/momentfit/R/gelfit-methods.R
   pkg/momentfit/R/momentModel-methods.R
   pkg/momentfit/man/gelfit-class.Rd
   pkg/momentfit/man/lambdaAlgo.Rd
   pkg/momentfit/man/summaryGel-class.Rd
   pkg/momentfit/vignettes/gelS4.Rnw
   pkg/momentfit/vignettes/gelS4.pdf
   pkg/momentfit/vignettes/gmmS4.pdf
Log:
added zero-restrictions on the lambdas to both packages

Modified: pkg/causalGel/DESCRIPTION
===================================================================
--- pkg/causalGel/DESCRIPTION	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/causalGel/DESCRIPTION	2020-11-04 21:55:14 UTC (rev 176)
@@ -6,7 +6,7 @@
 Author: Pierre Chausse <pchausse at uwaterloo.ca>
 Maintainer: Pierre Chausse <pchausse at uwaterloo.ca>
 Description: Methods for causal inference in which covariates are balanced using generalized empirical likelihod methods.
-Depends: R (>= 3.0.0), momentfit (>= 0.1.1)
+Depends: R (>= 3.0.0), momentfit (>= 0.2)
 Imports: stats, methods
 Suggests: lmtest, knitr, texreg
 Collate: 'allClasses.R' 'causalMethods.R' 'rcausalMethods.R' 'causalGel.R'

Modified: pkg/causalGel/R/causalGel.R
===================================================================
--- pkg/causalGel/R/causalGel.R	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/causalGel/R/causalGel.R	2020-11-04 21:55:14 UTC (rev 176)
@@ -23,7 +23,7 @@
     if (!is.null(theta0))
     {
         if (length(theta0) != ncoef)
-            stop(paste("The leangth of theta0 must be ", ncoef, sep=""))
+            stop(paste("The length of theta0 must be ", ncoef, sep=""))
         if (is.null(names(theta0)))
             names(theta0) <- name_coef
     } else {
@@ -67,7 +67,7 @@
                    initTheta = c("gmm","theta0"), getVcov=FALSE,
                    lambda0=NULL, cstLHS=NULL, cstRHS=NULL,
                    lamSlv=NULL, coefSlv= c("optim","nlminb","constrOptim"),
-                   lControl=list(), tControl=list())
+                   lControl=list(), tControl=list(), restrictLam=FALSE)
 {
     Call <- try(match.call(call=sys.call(sys.parent())), silent=TRUE)
     if (class(Call)=="try-error")
@@ -108,7 +108,17 @@
         spec <- modelDims(model)
         if (!is.null(theta0)) 
             theta0 <- theta0[(names(theta0) %in% spec$parNames)]
-    }    
+        if (inherits(model, "rcausalModel") & restrictLam)
+        {
+            warning(paste("restrictLam=TRUE is not recommended for restricted model.",
+                          "\nIt is then set to FALSE. Use gelFit if you really what it",
+                          sep=""))
+            restrictLam <- FALSE
+        }        
+    }
+    if (restrictLam)
+        lControl$restrictedLam <- grep("control|causalEffect",
+                                       modelDims(model)$momNames)
     fit <- gelFit(model=model, gelType=gelType, rhoFct=rhoFct,
                   initTheta=initTheta, theta0=theta0,
                   lambda0=lambda0, vcov=getVcov, coefSlv=coefSlv,

Modified: pkg/causalGel/man/causalGEL.Rd
===================================================================
--- pkg/causalGel/man/causalGEL.Rd	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/causalGel/man/causalGEL.Rd	2020-11-04 21:55:14 UTC (rev 176)
@@ -17,7 +17,7 @@
           initTheta = c("gmm","theta0"), getVcov=FALSE,
           lambda0=NULL, cstLHS=NULL, cstRHS=NULL,
           lamSlv=NULL, coefSlv= c("optim","nlminb","constrOptim"),
-          lControl=list(), tControl=list())
+          lControl=list(), tControl=list(), restrictLam=FALSE)
 }
 \arguments{
 
@@ -90,6 +90,9 @@
     algorithm.}
   
   \item{tControl}{A list of controls for the coefficient algorithm.}
+
+  \item{restrictLam}{Should we restrict the lambdas for which the
+  analytical solution is 0 to be fixed at 0?}
 	    
 }
 

Modified: pkg/causalGel/man/causalGelfit-class.Rd
===================================================================
--- pkg/causalGel/man/causalGelfit-class.Rd	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/causalGel/man/causalGelfit-class.Rd	2020-11-04 21:55:14 UTC (rev 176)
@@ -20,6 +20,7 @@
     \item{\code{gelType}:}{Object of class \code{"list"} ~~ }
     \item{\code{vcov}:}{Object of class \code{"list"} ~~ }
     \item{\code{model}:}{Object of class \code{"momentModel"} ~~ }
+    \item{\code{restrictedLam}:}{Object of class \code{"integer"} ~~ }    
   }
 }
 \section{Extends}{

Modified: pkg/causalGel/vignettes/causalGel.pdf
===================================================================
(Binary files differ)

Modified: pkg/momentfit/DESCRIPTION
===================================================================
--- pkg/momentfit/DESCRIPTION	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/DESCRIPTION	2020-11-04 21:55:14 UTC (rev 176)
@@ -1,6 +1,6 @@
 Package: momentfit
-Version: 0.1-2
-Date: 2020-11-02
+Version: 0.2
+Date: 2020-11-03
 Title: Methods of Moments
 Author: Pierre Chausse <pchausse at uwaterloo.ca>
 Maintainer: Pierre Chausse <pchausse at uwaterloo.ca>

Modified: pkg/momentfit/R/allClasses.R
===================================================================
--- pkg/momentfit/R/allClasses.R	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/R/allClasses.R	2020-11-04 21:55:14 UTC (rev 176)
@@ -197,12 +197,13 @@
 setClass("gelfit", representation(theta = "numeric", convergence = "numeric",
                                   lambda = "numeric", lconvergence = "numeric",
                                   call="callORNULL", gelType="list", vcov="list",
-                                  model="momentModel"))
+                                  model="momentModel", restrictedLam="integer"))
 
 setClass("summaryGel", representation(coef="matrix", specTest = "specTest",
                                       model="momentModel", lambda="matrix",
                                       convergence="numeric",lconvergence="numeric",
-                                      impProb="list", gelType="list"))
+                                      impProb="list", gelType="list",
+                                      restrictedLam="integer"))
 
 
 ## class converted
@@ -374,8 +375,8 @@
       })
           
 
-setAs("rslinearModel", "rlinearModel",
-      function(from) {
+setAs("rslinearModel", "rlinearModel", 
+     function(from) {
           m <- as(from, "slinearModel")
           m <- as(m, "linearModel")
           restModel(m, from at cstLHS, from at cstRHS)

Modified: pkg/momentfit/R/gel.R
===================================================================
--- pkg/momentfit/R/gel.R	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/R/gel.R	2020-11-04 21:55:14 UTC (rev 176)
@@ -127,7 +127,8 @@
 
 getLambda <- function (gmat, lambda0=NULL, gelType=NULL, rhoFct=NULL, 
                        tol = 1e-07, maxiter = 100, k = 1, method="BFGS", 
-                       algo = c("nlminb", "optim", "Wu"), control = list()) 
+                       algo = c("nlminb", "optim", "Wu"), control = list(),
+                       restrictedLam=integer()) 
 {
     if (!is.null(gelType))
     {
@@ -135,9 +136,25 @@
             algo <- "Wu"
     }
     algo <- match.arg(algo)
-    gmat <- as.matrix(gmat)
+    gmat <- as.matrix(gmat)    
+    if (length(restrictedLam))
+    {
+        if (length(restrictedLam) > ncol(gmat))
+            stop("The number of restricted Lambda exceeds the number of moments")
+        if (!all(restrictedLam %in% (1:ncol(gmat))))
+            stop(paste("restrictedLam must be a vector of integers between 1 and ",
+                       ncol(gmat), sep=""))
+        gmat <- gmat[,-restrictedLam,drop=FALSE]
+    } else {
+        restrictedLam <- integer()
+    }
     if (is.null(lambda0))
+    {
         lambda0 <- rep(0, ncol(gmat))
+    } else {
+        if (length(restrictedLam))
+            lambda0 <- lambda0[-restrictedLam]
+    }
     if (is.null(rhoFct))
     {
         if (is.null(gelType))
@@ -148,55 +165,65 @@
     }
     if (algo == "Wu" & gelType != "EL") 
         stop("Wu (2005) algo to compute Lambda is for EL only")
-    if (algo == "Wu") 
-        return(Wu_lam(gmat, tol, maxiter, k))
-    if (gelType == "EEL")
-        return(EEL_lam(gmat, k))
-    if (gelType == "REEL")
-        return(REEL_lam(gmat, NULL, maxiter, k))
-    if (gelType %in% c("ETEL", "ETHD"))
-        return(ETXX_lam(gmat, lambda0, k, gelType, algo, method, control))
-    
-    fct <- function(l, X, rhoFct, k) {
-        r0 <- rhoFct(X, l, derive = 0, k = k)
-        -mean(r0)
-    }
-    Dfct <-  function(l, X, rhoFct, k)
+    if ((algo == "Wu") | (gelType %in% c("EEL","REEL","ETEL","ETHD")))
     {
-        r1 <- rhoFct(X, l, derive = 1, k = k)
-        -colMeans(r1 * X)
-    }
-    DDfct <-  function(l, X, rhoFct, k)
-    {
-        r2 <- rhoFct(X, l, derive = 2, k = k)
-        -crossprod(X * r2, X)/nrow(X)
-    }
-    if (algo == "optim") {
-        if (gelType == "EL")
+        if (algo == "Wu")
+            res <- Wu_lam(gmat, tol, maxiter, k)
+        if (gelType == "EEL")
+            res <- EEL_lam(gmat, k)
+        if (gelType == "REEL")
+            res <- REEL_lam(gmat, NULL, maxiter, k)
+        if (gelType %in% c("ETEL", "ETHD"))
+            res <- ETXX_lam(gmat, lambda0, k, gelType, algo, method, control)
+    } else {    
+        fct <- function(l, X, rhoFct, k) {
+            r0 <- rhoFct(X, l, derive = 0, k = k)
+            -mean(r0)
+        }
+        Dfct <-  function(l, X, rhoFct, k)
         {
-            ci <- -rep(1, nrow(gmat))
-            res <- constrOptim(lambda0, fct, Dfct, -gmat, ci, control = control,
-                               X = gmat, rhoFct = rhoFct, k = k)
-        } else if (gelType == "HD") {
-            ci <- -rep(1, nrow(gmat))
-            res <- constrOptim(lambda0, fct, Dfct, -gmat, ci, control = control,
-                               X = gmat, rhoFct = rhoFct, k = k)
+            r1 <- rhoFct(X, l, derive = 1, k = k)
+            -colMeans(r1 * X)
+        }
+        DDfct <-  function(l, X, rhoFct, k)
+        {
+            r2 <- rhoFct(X, l, derive = 2, k = k)
+            -crossprod(X * r2, X)/nrow(X)
+        }
+        if (algo == "optim") {
+            if (gelType == "EL")
+            {
+                ci <- -rep(1, nrow(gmat))
+                res <- constrOptim(lambda0, fct, Dfct, -gmat, ci, control = control,
+                                   X = gmat, rhoFct = rhoFct, k = k)
+            } else if (gelType == "HD") {
+                ci <- -rep(1, nrow(gmat))
+                res <- constrOptim(lambda0, fct, Dfct, -gmat, ci, control = control,
+                                   X = gmat, rhoFct = rhoFct, k = k)
+            } else {
+                res <- optim(lambda0, fct, gr = Dfct, X = gmat, rhoFct = rhoFct,
+                             k = k, method = method, control = control)
+            }
         } else {
-            res <- optim(lambda0, fct, gr = Dfct, X = gmat, rhoFct = rhoFct,
-                         k = k, method = method, control = control)
+            res <- nlminb(lambda0, fct, gradient = Dfct, hessian = DDfct,
+                          X = gmat, rhoFct = rhoFct, k = k, control = control)
         }
-    } else {
-        res <- nlminb(lambda0, fct, gradient = Dfct, hessian = DDfct,
-                      X = gmat, rhoFct = rhoFct, k = k, control = control)
+        lambda0 <- res$par
+        if (algo == "optim") 
+            conv <- list(convergence = res$convergence, counts = res$counts, 
+                         message = res$message)
+        else
+            conv <- list(convergence = res$convergence, counts = res$evaluations, 
+                         message = res$message)    
+        res <- list(lambda = lambda0, convergence = conv,
+                    obj= mean(rhoFct(gmat,lambda0,0,k)))
     }
-    lambda0 <- res$par
-    if (algo == "optim") 
-        conv <- list(convergence = res$convergence, counts = res$counts, 
-                     message = res$message)
-    else
-        conv <- list(convergence = res$convergence, counts = res$evaluations, 
-                     message = res$message)    
-    return(list(lambda = lambda0, convergence = conv,
-                obj= mean(rhoFct(gmat,lambda0,0,k))))
+    if (length(restrictedLam))
+    {
+        lambda <- numeric(ncol(gmat)+length(restrictedLam))
+        lambda[-restrictedLam] <- res$lambda
+        res$lambda <- lambda
+    }
+    res
 }
 

Modified: pkg/momentfit/R/gelfit-methods.R
===================================================================
--- pkg/momentfit/R/gelfit-methods.R	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/R/gelfit-methods.R	2020-11-04 21:55:14 UTC (rev 176)
@@ -127,14 +127,20 @@
                   type <- paste("Just-Identified ", type, sep="")
               cat("\nEstimation: ", type,"\n")
               cat("Convergence Theta: ", x at convergence, "\n")
-              cat("Convergence Lambda: ", x at lconvergence, "\n")              
+              cat("Convergence Lambda: ", x at lconvergence, "\n")
+              if (length(x at restrictedLam))
+              {
+                  cat("Lambda's fixed at 0: ",
+                      paste(x at restrictedLam, collapse=", ", sep=""),
+                      "\n", sep="")
+              }
               cat("coefficients:\n")
               print.default(format(theta, ...), print.gap=2L, quote=FALSE)
               if (lambda)
-                  {
-                      cat("lambdas:\n")
-                      print.default(format(x at lambda, ...), print.gap=2L, quote=FALSE)
-                  }
+              {
+                  cat("lambdas:\n")
+                  print.default(format(x at lambda, ...), print.gap=2L, quote=FALSE)
+              }
           })
 
 ## show
@@ -267,9 +273,11 @@
                   tval.t <- theta/se.t
                   tval.l <- lambda/se.l
                   coef <- cbind(theta, se.t, tval.t,
-                                2*pnorm(abs(tval.t), lower.tail = FALSE))
+                                2*pnorm(abs(tval.t), lower.tail = FALSE))                 
                   coefl <- cbind(lambda, se.l, tval.l,
                                  2*pnorm(abs(tval.l), lower.tail = FALSE))
+                  if (length(object at restrictedLam))
+                      coefl[object at restrictedLam,-1] <- NA
                   stest <- specTest(object)
                   dimnames(coef) <- list(names(theta), c("Estimate", "Std. Error", 
                                                          "t value", "Pr(>|t|)"))
@@ -280,7 +288,8 @@
                   ans <- new("summaryGel", coef = coef, specTest = stest,
                              model = object at model, lambda=coefl,
                              convergence=object at convergence,gelType=object at gelType,
-                             lconvergence=object at lconvergence, impProb=pt)
+                             lconvergence=object at lconvergence, impProb=pt,
+                             restrictedLam=object at restrictedLam)
                   ans})
 
 ## confint
@@ -510,7 +519,7 @@
               type <- match.arg(type)
               spec <- modelDims(object at model)
               gelType <- object at gelType
-              q <- spec$q
+              q <- spec$q-length(object at restrictedLam)
               n <- spec$n
               df <- q-spec$k              
               test <- numeric()
@@ -557,6 +566,12 @@
               cat("\nEstimation: ", type,"\n")            
               cat("Convergence Theta: ", x at convergence, "\n", sep="")
               cat("Convergence Lambda: ", x at lconvergence, "\n", sep="")
+              if (length(x at restrictedLam))
+              {
+                  cat("Lambda's fixed at 0: ",
+                      paste(x at restrictedLam, collapse=", ", sep=""),
+                      "\n", sep="")
+              }              
               cat("Average |Sum of pt*gt()]|: ", format(mean(abs(x at impProb$convMom)),
                                                         digits=5), "\n", sep="")
               cat("|Sum of pt - 1|: ", format(mean(abs(x at impProb$convProb)),

Modified: pkg/momentfit/R/momentModel-methods.R
===================================================================
--- pkg/momentfit/R/momentModel-methods.R	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/R/momentModel-methods.R	2020-11-04 21:55:14 UTC (rev 176)
@@ -1230,14 +1230,22 @@
                    lControl=list(), tControl=list())
           {
               coefSlv <- match.arg(coefSlv)
+              if ("restrictedLam" %in% names(lControl))
+              {
+                  .restrictedLam <- lControl[["restrictedLam"]]
+                  lControl["restrictedLam"] <- NULL
+              } else {
+                  .restrictedLam <- integer()
+              }
               f <- function(theta, model, lambda0, slv, lcont, gelType, rhoFct,
-                            returnL=FALSE)
+                            returnL=FALSE, restrictedLam)
               {
                   names(theta) <- modelDims(model)$parNames
                   gt <- evalMoment(model, theta)
                   k <- model at sSpec@k
                   args <- c(list(gmat=gt, lambda0=lambda0, gelType=gelType,
-                                 rhoFct=rhoFct), lcont, k=k[1]/k[2])
+                                 rhoFct=rhoFct, restrictedLam=restrictedLam),
+                            lcont, k=k[1]/k[2])
                   res <- do.call(slv, args)
                   if (returnL)
                       return(res)
@@ -1248,28 +1256,31 @@
               if (is.null(theta0))
               {
                   if (!("theta0"%in%slotNames(object)))
-                      stop("Theta0 must be provided")
+                      stop("theta0 must be provided")
                   theta0 <- modelDims(object)$theta0
               }
               if (is.null(lamSlv))
                   lamSlv <- getLambda
               if (coefSlv == "nlminb")
+              {
                   args <- c(list(start=theta0, objective=f, gelType=gelType,
                                  model=object, lambda0=lambda0, rhoFct=rhoFct,
-                                 slv=lamSlv, lcont=lControl), tControl)
-              else
+                                 slv=lamSlv, lcont=lControl,
+                                 restrictedLam=.restrictedLam), tControl)
+              } else {
                   args <- c(list(par=theta0, fn=f, model=object, lambda0=lambda0,
                                  slv=lamSlv, lcont=lControl, gelType=gelType,
-                                 rhoFct=rhoFct), tControl)
-              
+                                 rhoFct=rhoFct, restrictedLam=.restrictedLam), tControl)
+              }
               res <- do.call(get(coefSlv), args)
               resl <- f(res$par,  object, lambda0, lamSlv, gelType=gelType,
-                        rhoFct=rhoFct, lControl, TRUE)
+                        rhoFct=rhoFct, lControl, TRUE, .restrictedLam)
               names(resl$lambda) <- modelDims(object)$momNames
               theta <- res$par
               names(theta) <- modelDims(object)$parNames                  
               list(theta=theta, convergence=res$convergence,
-                   lambda=resl$lambda, lconvergence=resl$convergence)
+                   lambda=resl$lambda, lconvergence=resl$convergence,
+                   restrictedLam=.restrictedLam)
           })
 
 ################ model fit ###########
@@ -1303,7 +1314,8 @@
                             lconvergence=res$lconvergence$convergence,
                             lambda=res$lambda, call=Call,
                             gelType=list(name=gelType, rhoFct=rhoFct),
-                            vcov=list(), model=model)
+                            vcov=list(), model=model,
+                            restrictedLam = res$restrictedLam)
               if (vcov)
                   gelfit at vcov <- vcov(gelfit)
               gelfit
@@ -1326,10 +1338,18 @@
               type <- paste("Eval-", gelType, sep="")
               if (is.null(lambda))
               {
+                  if ("restrictedLam" %in% names(lControl))
+                  {
+                      .restrictedLam <- lControl[["restrictedLam"]]
+                      lControl["restrictedLam"] <- NULL
+                  } else {
+                      .restrictedLam <- integer()
+                  }
                   gt <- evalMoment(model, theta)
                   k <- model at sSpec@k
                   args <- c(list(gmat=gt, gelType=gelType,
-                                 rhoFct=rhoFct), lControl, k=k[1]/k[2])
+                                 rhoFct=rhoFct, restrictedLam=.restrictedLam),
+                            lControl, k=k[1]/k[2])
                   if (is.null(lamSlv))
                       lamSlv <- getLambda
                   res <- do.call(lamSlv, args)
@@ -1339,6 +1359,7 @@
               } else {
                   lconvergence <- 1
                   type <- paste(type, " with fixed lambda", sep="")
+                  .restrictedLam <- integer()
               }
               names(lambda) <- spec$momNames
               if (!is.null(rhoFct))
@@ -1345,7 +1366,7 @@
                   gelType <- "Other"
               new("gelfit", theta=theta, convergence=1, lconvergence=lconvergence,
                   lambda=lambda, call=Call, gelType=list(name=gelType, rhoFct=rhoFct),
-                  vcov=list(), model=model)
+                  vcov=list(), model=model, restrictedLam = .restrictedLam)
           })
 
 

Modified: pkg/momentfit/man/gelfit-class.Rd
===================================================================
--- pkg/momentfit/man/gelfit-class.Rd	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/man/gelfit-class.Rd	2020-11-04 21:55:14 UTC (rev 176)
@@ -20,6 +20,7 @@
     \item{\code{gelType}:}{Object of class \code{"list"} ~~ }
     \item{\code{vcov}:}{Object of class \code{"list"} ~~ }
     \item{\code{model}:}{Object of class \code{"momentModel"} ~~ }
+    \item{\code{restrictedLam}:}{Object of class \code{"integer"} ~~ }
   }
 }
 \section{Methods}{

Modified: pkg/momentfit/man/lambdaAlgo.Rd
===================================================================
--- pkg/momentfit/man/lambdaAlgo.Rd	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/man/lambdaAlgo.Rd	2020-11-04 21:55:14 UTC (rev 176)
@@ -23,7 +23,8 @@
 
 getLambda(gmat, lambda0=NULL, gelType=NULL, rhoFct=NULL, 
           tol = 1e-07, maxiter = 100, k = 1, method="BFGS", 
-          algo = c("nlminb", "optim", "Wu"), control = list()) 
+          algo = c("nlminb", "optim", "Wu"), control = list(),
+          restrictedLam=integer()) 
 }
 \arguments{
 \item{gmat}{The \eqn{n \times q} matrix of moments}
@@ -61,6 +62,9 @@
 
 \item{control}{A list of control to pass to either \code{\link{optim}}
   or \code{\link{nlminb}}.}
+
+\item{restrictedLam}{A vector of integers indicating which
+  \code{"lambda"} are restricted to be equal to 0.}
   
 }
 

Modified: pkg/momentfit/man/summaryGel-class.Rd
===================================================================
--- pkg/momentfit/man/summaryGel-class.Rd	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/man/summaryGel-class.Rd	2020-11-04 21:55:14 UTC (rev 176)
@@ -20,6 +20,7 @@
     \item{\code{lconvergence}:}{Object of class \code{"numeric"} ~~ }
     \item{\code{impProb}:}{Object of class \code{"list"} ~~ }
     \item{\code{gelType}:}{Object of class \code{"list"} ~~ }
+    \item{\code{restrictedLam}:}{Object of class \code{"integer"} ~~ }
   }
 }
 \section{Methods}{

Modified: pkg/momentfit/vignettes/gelS4.Rnw
===================================================================
--- pkg/momentfit/vignettes/gelS4.Rnw	2020-11-03 22:54:14 UTC (rev 175)
+++ pkg/momentfit/vignettes/gelS4.Rnw	2020-11-04 21:55:14 UTC (rev 176)
@@ -368,6 +368,23 @@
 solveGel(lin, theta0=c(1,1,0), lControl=list(algo="nlminb"))$theta
 @   
 
+It is also possible to restrict some $\lambda$'s to be equal to
+zero. This is like removing the associated moment conditions, so the
+degrees of freedom of the specification tests are adjusted
+accordingly.
+
+<<>>=
+res <- solveGel(lin, theta0=c(1,1,0), lControl=list(restrictedLam=c(2L,3L)))
+res$lambda
+@ 
+
+The argument restrictedLam is a vector of integers specifying which
+$\lambda$ to set to 0. Of course, it is an argument to use with
+caution. If a coefficient is only present in the moment conditions
+associated with the $\lambda$'s set to zero, their estimates are not
+reliable because they no longer affect the value of the objective
+function.
+
 \item tControl: A list of control for the coefSlv function. We could,
   for example, use the following options:
 

Modified: pkg/momentfit/vignettes/gelS4.pdf
===================================================================
(Binary files differ)

Modified: pkg/momentfit/vignettes/gmmS4.pdf
===================================================================
(Binary files differ)



More information about the Gmm-commits mailing list