[Gmm-commits] r97 - pkg/gmm/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 20 19:27:11 CET 2017


Author: chaussep
Date: 2017-01-20 19:27:11 +0100 (Fri, 20 Jan 2017)
New Revision: 97

Modified:
   pkg/gmm/R/getModel.R
   pkg/gmm/R/momentEstim.R
Log:
fixed a bug with opt=optimize, but optim should be used with Brent instead

Modified: pkg/gmm/R/getModel.R
===================================================================
--- pkg/gmm/R/getModel.R	2017-01-20 15:26:32 UTC (rev 96)
+++ pkg/gmm/R/getModel.R	2017-01-20 18:27:11 UTC (rev 97)
@@ -185,7 +185,6 @@
 
 getModel.baseGmm <- function(object, ...)
     {
-        
         object$allArg <- c(object, list(...))        
         if(is(object$g, "formula"))
             {
@@ -219,7 +218,10 @@
             } else {
                 attr(object$x,"ModelType") <- "nonlinear"
                 attr(object$x, "momentfct") <- object$g
-                attr(object$x, "k") <- length(object$t0)
+                if (object$optfct == "optimize")
+                    attr(object$x, "k") <- 1
+                else
+                    attr(object$x, "k") <- length(object$t0)
                 attr(object$x, "q") <- NCOL(object$g(object$t0, object$x))
                 attr(object$x, "n") <- NROW(object$x)
                 if (object$optfct == "optimize")

Modified: pkg/gmm/R/momentEstim.R
===================================================================
--- pkg/gmm/R/momentEstim.R	2017-01-20 15:26:32 UTC (rev 96)
+++ pkg/gmm/R/momentEstim.R	2017-01-20 18:27:11 UTC (rev 97)
@@ -185,7 +185,7 @@
                 res <- optimize(.obj1, P$t0, x = x, w = w, ...)
                 res$par <- res$minimum
                 res$value <- res$objective
-            }	
+            }
         if (q == k2 | P$wmatrix == "ident")
             {
                 z = list(coefficients = res$par, objective = res$value, k=k, k2=k2, n=n, q=q, df=df)	



More information about the Gmm-commits mailing list