From d113cd79b178fdc91aecb894707ed356129dfb75 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sun, 10 May 2020 21:53:00 +0200 Subject: Default to analytical for coupled models if available This revealed that transforming rates is necessary for fitting the analytical solution of the SFO-SFO model to the FOCUS D dataset. Benchmarks show that fitting coupled models with deSolve got a bit slower through the latest changes --- R/create_deg_func.R | 3 ++- R/mkinfit.R | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'R') diff --git a/R/create_deg_func.R b/R/create_deg_func.R index 886c5e8b..6c0ae40b 100644 --- a/R/create_deg_func.R +++ b/R/create_deg_func.R @@ -51,7 +51,8 @@ create_deg_func <- function(spec, use_of_ff = c("min", "max")) { n10 <- paste0("odeini['", parent, "']") n20 <- paste0("odeini['", n2, "']") - if (all(use_of_ff == "max", spec[[1]]$sink == TRUE, length(obs_vars) == 2, spec[[2]]$type == "SFO")) { + if (all(use_of_ff == "max", spec[[1]]$sink == TRUE, length(obs_vars) == 2, + spec[[1]]$type == "SFO", spec[[2]]$type == "SFO")) { supported <- TRUE k1 <- paste0("k_", n1) k2 <- paste0("k_", n2) diff --git a/R/mkinfit.R b/R/mkinfit.R index c33afbf0..e1089673 100644 --- a/R/mkinfit.R +++ b/R/mkinfit.R @@ -464,7 +464,7 @@ mkinfit <- function(mkinmod, observed, if (solution_type == "eigen" && !is.matrix(mkinmod$coefmat)) stop("Eigenvalue based solution not possible, coefficient matrix not present.") if (solution_type == "auto") { - if (length(mkinmod$spec) == 1) { + if (length(mkinmod$spec) == 1 || is.function(mkinmod$deg_func)) { solution_type = "analytical" } else { if (!is.null(mkinmod$cf) & use_compiled[1] != FALSE) { @@ -694,7 +694,7 @@ mkinfit <- function(mkinmod, observed, # Show parameter names if tracing is requested if(trace_parms) cat(names_optim, "\n") - # browser() + #browser() # Do the fit and take the time until the hessians are calculated fit_time <- system.time({ -- cgit v1.2.1