[Depmix-commits] r497 - pkg/depmixS4/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Oct 26 15:31:19 CEST 2011


Author: ingmarvisser
Date: 2011-10-26 15:31:18 +0200 (Wed, 26 Oct 2011)
New Revision: 497

Modified:
   pkg/depmixS4/R/EM.R
Log:
Fixed a bug in the relative stopping criterion for EM, this time for good.

Modified: pkg/depmixS4/R/EM.R
===================================================================
--- pkg/depmixS4/R/EM.R	2011-10-25 12:41:38 UTC (rev 496)
+++ pkg/depmixS4/R/EM.R	2011-10-26 13:31:18 UTC (rev 497)
@@ -91,7 +91,7 @@
 		}
 		
 		if(LL >= LL.old) {
-		  if((crit == "absolute" &&  LL - LL.old < tol) || (crit == "relative" && (LL.old - LL)/LL.old  < tol)) {
+		  if((crit == "absolute" &&  LL - LL.old < tol) || (crit == "relative" && (LL - LL.old)/abs(LL.old)  < tol)) {
 			  cat("iteration",j,"logLik:",LL,"\n")
 			  converge <- TRUE
 			}
@@ -214,8 +214,8 @@
 				
 		if(verbose&((j%%5)==0)) cat("iteration",j,"logLik:",LL,"\n")
 		
-		if( (LL >= LL.old&j>25)) {
-		  if((crit == "absolute" &&  LL - LL.old < tol) || (crit == "relative" && abs((LL.old - LL)/LL.old)  < tol)) {
+		if( (LL >= LL.old)) {
+		  if((crit == "absolute" &&  LL - LL.old < tol) || (crit == "relative" && (LL - LL.old)/abs(LL.old)  < tol)) {
 			  cat("iteration",j,"logLik:",LL,"\n")
 			  converge <- TRUE
 			}



More information about the depmix-commits mailing list