[Gmm-commits] r18 - in pkg/gmm: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jan 8 21:01:57 CET 2010


Author: chaussep
Date: 2010-01-08 21:01:56 +0100 (Fri, 08 Jan 2010)
New Revision: 18

Modified:
   pkg/gmm/NEWS
   pkg/gmm/R/momentEstim.R
   pkg/gmm/man/gmm.Rd
Log:
Added the possibility to name the parameters


Modified: pkg/gmm/NEWS
===================================================================
--- pkg/gmm/NEWS	2010-01-08 17:53:12 UTC (rev 17)
+++ pkg/gmm/NEWS	2010-01-08 20:01:56 UTC (rev 18)
@@ -7,6 +7,8 @@
     For the former, the optimal bandwidth of Andrews(91) for Bartlett is used and for the latter, it is the bandwidth proposed
     for the Parzen. See Smith(2004) for more details. Also, the option vcov as been removed since it is irrelevant for GEL. By setting smooth to
     FALSE, it is implied that the data are iid.     
+  o It is now possible to give names to the parameters when the model is nonlinear. It is done through the starting values. For example
+    res <- gmm(..., t0 = c(mu=0,sig=1) ,...
 
 Changes in version 1.2-0
 

Modified: pkg/gmm/R/momentEstim.R
===================================================================
--- pkg/gmm/R/momentEstim.R	2010-01-08 17:53:12 UTC (rev 17)
+++ pkg/gmm/R/momentEstim.R	2010-01-08 20:01:56 UTC (rev 18)
@@ -79,8 +79,12 @@
 
      z = list(coefficients = res2$par, objective = res2$value, k=k, k2=k2, n=n, q=q, df=df)	
     }
+    
+  if(is.null(names(P$t0)))
+    names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
+  else
+    names(z$coefficients) <- names(P$t0)
 
-  names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
   z$x <- P$x
   z$gt <- P$g(z$coefficients, P$x)
   z$gradv <- P$gradv
@@ -311,7 +315,11 @@
     z = list(coefficients = res$par, objective = res$value,k=k, k2=k2, n=n, q=q, df=df)	
     }
 
-  names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
+  if(is.null(names(P$t0)))
+    names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
+  else
+    names(z$coefficients) <- names(P$t0)
+
   z$x <- P$x
   z$gt <- P$g(z$coefficients, P$x)
   z$gradv <- P$gradv
@@ -452,7 +460,11 @@
     z = list(coefficients=res2$par,objective=res2$value, k=k, k2=k2, n=n, q=q, df=df)	
     }
 
-  names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
+  if(is.null(names(P$t0)))
+    names(z$coefficients) <- paste("Theta[" ,1:k, "]", sep = "")
+  else
+    names(z$coefficients) <- names(P$t0)
+  
   z$x <- P$x
   z$gradv <- P$gradv
   z$gt <- P$g(z$coefficients, P$x)
@@ -655,7 +667,11 @@
   z$bwVal <- P$bwVal
   names(z$bwVal) <- "Bandwidth"
  
-  names(z$coefficients) <- paste("Theta[",1:P$k,"]", sep = "")
+  if(is.null(names(P$t0)))
+    names(z$coefficients) <- paste("Theta[" ,1:P$k, "]", sep = "")
+  else
+    names(z$coefficients) <- names(P$t0)
+
   colnames(z$gt) <- paste("gt[",1:ncol(z$gt),"]", sep = "")
   names(z$lambda) <- paste("Lambda[",1:ncol(z$gt),"]", sep = "")
   dimnames(z$vcov_par) <- list(names(z$coefficients), names(z$coefficients))

Modified: pkg/gmm/man/gmm.Rd
===================================================================
--- pkg/gmm/man/gmm.Rd	2010-01-08 17:53:12 UTC (rev 17)
+++ pkg/gmm/man/gmm.Rd	2010-01-08 20:01:56 UTC (rev 18)
@@ -174,7 +174,7 @@
 	return(gmat) }
 
 x <- as.matrix(cbind(rm, r))
-res_black <- gmm(g, x = x, t0 = rep(0, 11))
+res_black <- gmm(g, x = x, t0 = c(zero_beta = 0, beta = rep(0, 10)))
 
 summary(res_black)$coefficients
 
@@ -213,6 +213,6 @@
         return(jacobian)
         }
 # Now we want to estimate the two parameters using the GMM.
-gmm(g, x, c(0, 0), grad = Dg)
+gmm(g, x, c(mu = 0, sig = 0), grad = Dg)
 }
 



More information about the Gmm-commits mailing list