[Yuima-commits] r420 - pkg/yuimaGUI/inst/yuimaGUI
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Mar 16 23:29:43 CET 2016
Author: phoenix844
Date: 2016-03-16 23:29:42 +0100 (Wed, 16 Mar 2016)
New Revision: 420
Modified:
pkg/yuimaGUI/inst/yuimaGUI/global.R
pkg/yuimaGUI/inst/yuimaGUI/server.R
Log:
added maximum number of iterations before stopping estimation
Modified: pkg/yuimaGUI/inst/yuimaGUI/global.R
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/global.R 2016-03-16 20:34:48 UTC (rev 419)
+++ pkg/yuimaGUI/inst/yuimaGUI/global.R 2016-03-16 22:29:42 UTC (rev 420)
@@ -319,7 +319,7 @@
}
-addModel <- function(modName, symbName, data, delta, start, startMin, startMax, tries, seed, method="BFGS", fixed = list(), lower, upper, joint=FALSE, aggregation=TRUE, threshold=NULL, session, anchorId, alertId){
+addModel <- function(modName, symbName, data, delta, start, startMin, startMax, tries, seed, method="BFGS", fixed = list(), lower, upper, joint=FALSE, aggregation=TRUE, threshold=NULL, session, anchorId){
info <- list(
modName = modName,
method=method,
@@ -354,7 +354,7 @@
QMLE <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
threshold = threshold))
if (class(QMLE)=="try-error"){
- createAlert(session = session, anchorId = anchorId, alertId = alertId, content = paste("Unable to estimate", modName,"on", symbName), style = "danger")
+ createAlert(session = session, anchorId = anchorId, content = paste("Unable to estimate", modName,"on", symbName), style = "danger")
return()
}
}
@@ -369,7 +369,7 @@
QMLE <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
threshold = threshold))
if (class(QMLE)=="try-error"){
- createAlert(session = session, anchorId = anchorId, alertId = alertId, content = paste("Unable to estimate", modName,"on", symbName), style = "danger")
+ createAlert(session = session, anchorId = anchorId, content = paste("Unable to estimate", modName,"on", symbName), style = "danger")
return()
}
#} else if (modName == "Brownian Motion" | modName == "Bm") {
@@ -386,49 +386,59 @@
m2logL_prec <- NA
na_prec <- NA
withProgress(message = 'Step: ', value = 0, {
- for(iter in 1:tries){
- incProgress(1/tries, detail = paste(iter,"(/", tries ,")"))
- repeat{
- for (i in miss)
- start[[i]] <- runif(1, min = max(lower[[i]],ifelse(is.null(startMin[[i]]),-10,startMin[[i]])), max = min(upper[[i]],ifelse(is.null(startMax[[i]]), 10, startMax[[i]])))
- QMLEtemp <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
- threshold = threshold))
- if (class(QMLEtemp)!="try-error")
- break
- }
- repeat{
- m2logL <- summary(QMLEtemp)@m2logL
- coefTable <- summary(QMLEtemp)@coef
- for (param in names(start))
- start[[param]] <- as.numeric(coefTable[param,"Estimate"])
- QMLEtemp <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
- threshold = threshold))
- if (class(QMLEtemp)=="try-error")
- break
- else if (summary(QMLEtemp)@m2logL>=0.999*m2logL)
- break
- }
- if(is.na(m2logL_prec & class(QMLEtemp)!="try-error")){
- QMLE <- QMLEtemp
- m2logL_prec <- summary(QMLE)@m2logL
- na_prec <- sum(is.na(coefTable))
- }
- else if (class(QMLEtemp)!="try-error"){
- if (sum(is.na(coefTable)) < na_prec){
- QMLE <- QMLEtemp
- m2logL_prec <- summary(QMLE)@m2logL
- na_prec <- sum(is.na(coefTable))
+ for(iter in 1:tries){
+ incProgress(1/tries, detail = paste(iter,"(/", tries ,")"))
+ for(j in 1:3){
+ for (i in miss)
+ start[[i]] <- runif(1, min = max(lower[[i]],startMin[[i]]), max = min(upper[[i]],startMax[[i]]))
+ QMLEtemp <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
+ threshold = threshold))
+ if (class(QMLEtemp)!="try-error")
+ break
}
- else if(summary(QMLEtemp)@m2logL < m2logL_prec & sum(is.na(coefTable))==na_prec){
- QMLE <- QMLEtemp
- m2logL_prec <- summary(QMLE)@m2logL
- na_prec <- sum(is.na(coefTable))
+ if (class(QMLEtemp)!="try-error"){
+ repeat{
+ m2logL <- summary(QMLEtemp)@m2logL
+ coefTable <- summary(QMLEtemp)@coef
+ for (param in names(start))
+ start[[param]] <- as.numeric(coefTable[param,"Estimate"])
+ QMLEtemp <- try(qmle(model, start = start, fixed = fixed, method = method, lower = lower, upper = upper, #joint = joint, aggregation = aggregation,
+ threshold = threshold))
+ if (class(QMLEtemp)=="try-error")
+ break
+ else if (summary(QMLEtemp)@m2logL>=0.999*m2logL)
+ break
+ }
+ if(is.na(m2logL_prec) & class(QMLEtemp)!="try-error"){
+ QMLE <- QMLEtemp
+ m2logL_prec <- summary(QMLE)@m2logL
+ na_prec <- sum(is.na(coefTable))
+ }
+ else if (class(QMLEtemp)!="try-error"){
+ if (sum(is.na(coefTable)) < na_prec){
+ QMLE <- QMLEtemp
+ m2logL_prec <- summary(QMLE)@m2logL
+ na_prec <- sum(is.na(coefTable))
+ }
+ else if(summary(QMLEtemp)@m2logL < m2logL_prec & sum(is.na(coefTable))==na_prec){
+ QMLE <- QMLEtemp
+ m2logL_prec <- summary(QMLE)@m2logL
+ na_prec <- sum(is.na(coefTable))
+ }
+ }
}
+ if (iter==tries & class(QMLEtemp)=="try-error"){
+ createAlert(session = session, anchorId = anchorId, content = paste("Unable to estimate", modName,"on", symbName), style = "danger")
+ return()
+ }
}
- }
})
}
}
+
+ if(!exists("QMLE"))
+ return()
+
yuimaGUIdata$model[[symbName]][[ifelse(is.null(length(yuimaGUIdata$model[[symbName]])),1,length(yuimaGUIdata$model[[symbName]])+1)]] <<- list(
model = model,
qmle = QMLE,
Modified: pkg/yuimaGUI/inst/yuimaGUI/server.R
===================================================================
--- pkg/yuimaGUI/inst/yuimaGUI/server.R 2016-03-16 20:34:48 UTC (rev 419)
+++ pkg/yuimaGUI/inst/yuimaGUI/server.R 2016-03-16 22:29:42 UTC (rev 420)
@@ -678,8 +678,7 @@
aggregation = estimateSettings[[modName]][[symb]][["aggregation"]],
threshold = estimateSettings[[modName]][[symb]][["threshold"]],
session = session,
- anchorId = "modelsAlert",
- alertId = "modelsAlert_qmle"
+ anchorId = "modelsAlert"
)
}
}
More information about the Yuima-commits
mailing list