aboutsummaryrefslogtreecommitdiff
path: root/R/multistart.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-09-28 16:34:57 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2022-09-28 16:34:57 +0200
commit3529f5ff498d7d054c7b1911ddfc4b242902b85d (patch)
tree4c642bfddcc68e353fe75e8037d39ad8f269d56e /R/multistart.R
parent75f361bed527b91bec205c5452add13247760d61 (diff)
Fix handling of multistart fits with failures
Diffstat (limited to 'R/multistart.R')
-rw-r--r--R/multistart.R48
1 files changed, 42 insertions, 6 deletions
diff --git a/R/multistart.R b/R/multistart.R
index cc55feae..b65c0bee 100644
--- a/R/multistart.R
+++ b/R/multistart.R
@@ -92,15 +92,51 @@ multistart.saem.mmkin <- function(object, n = 50, cores = 1,
return(res)
}
-#' @rdname multistart
#' @export
-print.multistart <- function(x, ...) {
- cat("Multistart object with", length(x), "fits of the following type:\n\n")
- print(x[[1]])
+convergence.multistart <- function(object, ...) {
+ all_summary_warnings <- character()
+
+ result <- lapply(object,
+ function(fit) {
+ if (inherits(fit, "try-error")) return("E")
+ else {
+ return("OK")
+ }
+ })
+ result <- unlist(result)
+
+ class(result) <- "convergence.multistart"
+ return(result)
+}
+
+#' @export
+convergence.multistart.saem.mmkin <- function(object, ...) {
+ all_summary_warnings <- character()
+
+ result <- lapply(object,
+ function(fit) {
+ if (inherits(fit$so, "try-error")) return("E")
+ else {
+ return("OK")
+ }
+ })
+ result <- unlist(result)
+
+ class(result) <- "convergence.multistart"
+ return(result)
+}
+
+#' @export
+print.convergence.multistart <- function(x, ...) {
+ class(x) <- NULL
+ print(table(x, dnn = NULL))
+ if (any(x == "OK")) cat("OK: Fit terminated successfully\n")
+ if (any(x == "E")) cat("E: Error\n")
}
#' @rdname multistart
#' @export
-parms.multistart <- function(object, ...) {
- t(sapply(object, parms))
+print.multistart <- function(x, ...) {
+ cat("<multistart> object with", length(x), "fits:\n")
+ print(convergence(x))
}

Contact - Imprint