aboutsummaryrefslogtreecommitdiff
path: root/R/mkinfit.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-05-11 05:15:19 +0200
committerJohannes Ranke <jranke@uni-bremen.de>2020-05-11 05:18:32 +0200
commit234c9059a95e104917e488a6ddd2313234a96cdc (patch)
treef6e54098f79d94578434ef727b62f7cc5d5e79b7 /R/mkinfit.R
parentd113cd79b178fdc91aecb894707ed356129dfb75 (diff)
Avoid merge() and data.frame() in cost function
also for deSolve and eigenvalue based solutions. This noticeably increases performance for these methods, see test.log and benchmark vignette.
Diffstat (limited to 'R/mkinfit.R')
-rw-r--r--R/mkinfit.R8
1 files changed, 2 insertions, 6 deletions
diff --git a/R/mkinfit.R b/R/mkinfit.R
index e1089673..f6691b1b 100644
--- a/R/mkinfit.R
+++ b/R/mkinfit.R
@@ -592,12 +592,8 @@ mkinfit <- function(mkinmod, observed,
method.ode = method.ode,
atol = atol, rtol = rtol, ...)
- out_long <- mkin_wide_to_long(out, time = "time")
-
- out_merged <- merge(observed[c("name", "time")], out_long)
- out_merged$name <- ordered(out_merged$name, levels = obs_vars)
- out_merged <- out_merged[order(out_merged$name, out_merged$time), ]
- observed$predicted <- out_merged$value
+ observed_index <- cbind(as.character(observed$time), as.character(observed$name))
+ observed$predicted <- out[observed_index]
}
# Define standard deviation for each observation

Contact - Imprint