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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 30 16:04:54 CET 2010


Author: chaussep
Date: 2010-01-30 16:04:54 +0100 (Sat, 30 Jan 2010)
New Revision: 20

Modified:
   pkg/gmm/R/FinRes.R
   pkg/gmm/R/PlotMethods.R
Log:
Bug fixed in plot.gmm, can get results even if the covariance matrix cannot be computed.


Modified: pkg/gmm/R/FinRes.R
===================================================================
--- pkg/gmm/R/FinRes.R	2010-01-08 20:31:19 UTC (rev 19)
+++ pkg/gmm/R/FinRes.R	2010-01-30 15:04:54 UTC (rev 20)
@@ -47,12 +47,17 @@
     }
   if (P$wmatrix == "optimal")
     {
-    z$vcov <- solve(crossprod(G, solve(v, G)))
+    z$vcov <- try(solve(crossprod(G, solve(v, G))))
+    if(class(z$vcov) == "try-error")
+      z$vcov <- matrix(Inf,length(z$coef),length(z$coef))
     }
   else
     {
-    GGG <- solve(crossprod(G), t(G))
-    z$vcov <- GGG %*% v %*% t(GGG)
+    GGG <- try(solve(crossprod(G), t(G)))
+    if(class(GGG) == "try-error")
+      z$vcov <- matrix(Inf,length(z$coef),length(z$coef))
+    else
+      z$vcov <- GGG %*% v %*% t(GGG)
     }
   dimnames(z$vcov) <- list(names(z$coefficients), names(z$coefficients))
   z$call <- P$call

Modified: pkg/gmm/R/PlotMethods.R
===================================================================
--- pkg/gmm/R/PlotMethods.R	2010-01-08 20:31:19 UTC (rev 19)
+++ pkg/gmm/R/PlotMethods.R	2010-01-30 15:04:54 UTC (rev 20)
@@ -78,7 +78,7 @@
 		plot(pt, type='l',main = main[4L],ylab="Implied Prob.", ...)
 		emp_pt <- rep(1/length(pt),length(pt))
 		lines(emp_pt,col=2)
-		legend("topright",c("Imp. Prob.","Empirical (1/T)"),col=1:2,lty=c(1,1))
+		legend("topleft",c("Imp. Prob.","Empirical (1/T)"),col=1:2,lty=c(1,1))
     		}
 	}
 



More information about the Gmm-commits mailing list