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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jun 18 14:56:45 CEST 2017


Author: chaussep
Date: 2017-06-18 14:56:45 +0200 (Sun, 18 Jun 2017)
New Revision: 111

Modified:
   pkg/gmm/R/momentEstim.R
Log:
fixed a bug in nonlinear iterative gmm

Modified: pkg/gmm/R/momentEstim.R
===================================================================
--- pkg/gmm/R/momentEstim.R	2017-06-15 15:24:21 UTC (rev 110)
+++ pkg/gmm/R/momentEstim.R	2017-06-18 12:56:45 UTC (rev 111)
@@ -465,15 +465,20 @@
             {
                 z <- list(coefficients = res$par, objective = res$value, k=k, k2=k2, n=n, q=q, df=df)
                 if (chkOptim)
-                    z$algoInfo <- list(convergence = res$convergence, counts = res$counts, message = res$message)
+                    z$algoInfo <- list(convergence = res$convergence, counts = res$counts,
+                                       message = res$message)
                 else if(P$optfct == "nlminb")
-                    z$algoInfo <- list(convergence = res$convergence, counts = res$evaluations, message = res$message)
+                    z$algoInfo <- list(convergence = res$convergence, counts = res$evaluations,
+                                       message = res$message)
             } else {                
                 initTheta = res$par
+                z <- list()
                 if (chkOptim)
-                    z$initialAlgoInfo <- list(convergence = res$convergence, counts = res$counts, message = res$message)
+                    z$initialAlgoInfo <- list(convergence = res$convergence, counts = res$counts,
+                                              message = res$message)
                 else if(P$optfct == "nlminb")
-                    z$initialAlgoInfo <- list(convergence = res$convergence, counts = res$evaluations, message = res$message)                
+                    z$initialAlgoInfo <- list(convergence = res$convergence, counts = res$evaluations,
+                                              message = res$message)                
                 ch <- 100000
                 j <- 1
                 while(ch > P$crit)
@@ -507,11 +512,15 @@
                             cat("Iter :",j,": value=",res$value,", Coef = ", res$par,"\n") 
                         j <- j+1	
                     }
-                z = list(coefficients = res$par, objective = res$value,k=k, k2=k2, n=n, q=q, df=df, initTheta=initTheta)	
+                z2 = list(coefficients = res$par, objective = res$value,k=k, k2=k2, n=n, q=q,
+                    df=df, initTheta=initTheta)
+                z <- c(z, z2)
                 if (chkOptim)
-                    z$algoInfo <- list(convergence = res$convergence, counts = res$counts, message = res$message)
+                    z$algoInfo <- list(convergence = res$convergence, counts = res$counts,
+                                       message = res$message)
                 else if(P$optfct == "nlminb")
-                    z$algoInfo <- list(convergence = res$convergence, counts = res$evaluations, message = res$message)
+                    z$algoInfo <- list(convergence = res$convergence, counts = res$evaluations,
+                                       message = res$message)
                 
             }
         z$dat <- P$x



More information about the Gmm-commits mailing list