diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2022-10-26 00:57:40 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2022-10-26 00:57:40 +0200 |
commit | 0d8521f3f60082f0fd27da00a7ac8bcef9ee5ba0 (patch) | |
tree | 2065de43684960b6c41d74a59d215b3bc0163ac8 /R/multistart.R | |
parent | 4030a3083d7ca51bc5d606dd95a877fb00967003 (diff) |
Make multistart work with testthat scopes
Also skip long-running test with saem using the analytical from mkin
Diffstat (limited to 'R/multistart.R')
-rw-r--r-- | R/multistart.R | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/R/multistart.R b/R/multistart.R index 4282de9c..4f5ecde3 100644 --- a/R/multistart.R +++ b/R/multistart.R @@ -74,17 +74,34 @@ multistart.saem.mmkin <- function(object, n = 50, cores = 1, call <- match.call() if (n <= 1) stop("Please specify an n of at least 2") - mmkin_parms <- parms(object$mmkin, errparms = FALSE, + mmkin_object <- object$mmkin + + mmkin_parms <- parms(mmkin_object, errparms = FALSE, transformed = object$transformations == "mkin") start_parms <- apply( mmkin_parms, 1, function(x) stats::runif(n, min(x), max(x))) + saem_call <- object$call + saem_call[[1]] <- saem + saem_call[[2]] <- mmkin_object + i_startparms <- which(names(saem_call) == "degparms_start") + fit_function <- function(x) { - ret <- update(object, degparms_start = start_parms[x, ], ...) - ret$call[[4]] <- str2lang( + + new_startparms <- str2lang( paste0(capture.output(dput(start_parms[x, ])), collapse = "")) + + if (length(i_startparms) == 0) { + saem_call <- c(as.list(saem_call), degparms_start = new_startparms) + saem_call <- as.call(saem_call) + } else { + saem_call[i_startparms] <- new_startparms + } + + ret <- eval(saem_call) + return(ret) } |