aboutsummaryrefslogtreecommitdiff
path: root/R/mkinpredict.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-11-07 11:54:13 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-11-07 11:54:13 +0100
commitcda47972e2b6a9610e3118dcd2270d7a1c76de3d (patch)
tree171a0bf2f7386b5451a581a40667bdb6a5d5a991 /R/mkinpredict.R
parentfcf06c40ec314e91ad3fdae3392f008509d70b2e (diff)
Make deSolve predictions within saemix robust
Also, exclude the saemix function when loading saemix in the example code, to prevent overriding our generic
Diffstat (limited to 'R/mkinpredict.R')
-rw-r--r--R/mkinpredict.R13
1 files changed, 11 insertions, 2 deletions
diff --git a/R/mkinpredict.R b/R/mkinpredict.R
index 350ee56a..a6e7ca1c 100644
--- a/R/mkinpredict.R
+++ b/R/mkinpredict.R
@@ -34,6 +34,7 @@
#' the observed variables (default) or for all state variables (if set to
#' FALSE). Setting this to FALSE has no effect for analytical solutions,
#' as these always return mapped output.
+#' @param na_stop Should it be an error if deSolve::ode returns NaN values
#' @param \dots Further arguments passed to the ode solver in case such a
#' solver is used.
#' @import deSolve
@@ -121,6 +122,7 @@ mkinpredict.mkinmod <- function(x,
solution_type = "deSolve",
use_compiled = "auto",
method.ode = "lsoda", atol = 1e-8, rtol = 1e-10,
+ na_stop = TRUE,
map_output = TRUE, ...)
{
@@ -208,9 +210,16 @@ mkinpredict.mkinmod <- function(x,
...
)
}
- if (sum(is.na(out)) > 0) {
+ n_out_na <- sum(is.na(out))
+ if (n_out_na > 0 & na_stop) {
+ cat("odeini:\n")
+ print(odeini)
+ cat("odeparms:\n")
+ print(odeparms)
+ cat("out:\n")
+ print(out)
stop("Differential equations were not integrated for all output times because\n",
- "NaN values occurred in output from ode()")
+ n_out_na, " NaN values occurred in output from ode()")
}
}

Contact - Imprint