From b2ced3712b06118a15d32c586bbc1deeac2c304f Mon Sep 17 00:00:00 2001 From: Suraj Yerramilli Date: Sun, 14 Feb 2016 11:19:39 +0530 Subject: changed termination criteria --- R/estUtil.R | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/R/estUtil.R b/R/estUtil.R index 6beb8a8..2d1a76f 100644 --- a/R/estUtil.R +++ b/R/estUtil.R @@ -31,7 +31,7 @@ levbmqdt <- function(...,obj,theta0,N,opt){ # Update Parameters H <- 1/N*t(l$grad)%*%l$grad + d*diag(dim(theta0)[1]) Hinv <- solve(H); - if(termPar < tol) break + theta <- theta0 + Hinv%*%g # Evaulate sum square error @@ -40,6 +40,7 @@ levbmqdt <- function(...,obj,theta0,N,opt){ sumSqDiff <- sumsq0-sumsq countObj <- countObj + 1 + if(termPar < tol) break # no major improvement if(abs(sumSqDiff) < 0.01*sumsq0) break @@ -56,14 +57,14 @@ levbmqdt <- function(...,obj,theta0,N,opt){ d <- d*mu } } - if(abs(sumSqDiff) < 0.01*sumsq0){ - WhyStop <- "No significant change" - break - } if(termPar < tol) { WhyStop <- "Tolerance" break } + if(abs(sumSqDiff) < 0.01*sumsq0){ + WhyStop <- "No significant change" + break + } if(i == maxIter){ WhyStop <- "Maximum Iteration Limit" break -- cgit