From 679cf716192cdfd91dfd232578cbd4e30d7eac12 Mon Sep 17 00:00:00 2001
From: Johannes Ranke
Date: Tue, 15 Nov 2022 08:01:52 +0100
Subject: Import saemix for easier profiling, update online docs
---
NAMESPACE | 1 +
R/saem.R | 3 +-
docs/dev/articles/web_only/benchmarks.html | 29 +++---
docs/dev/articles/web_only/saem_benchmarks.html | 29 +++---
docs/dev/pkgdown.yml | 2 +-
docs/dev/reference/Rplot001.png | Bin 1011 -> 22432 bytes
docs/dev/reference/logLik.saem.mmkin.html | 5 +-
docs/dev/reference/mkinpredict.html | 13 ++-
docs/dev/reference/saem.html | 11 ++-
log/test.log | 16 ++--
vignettes/web_only/benchmarks.rmd | 2 +-
vignettes/web_only/mkin_benchmarks.rda | Bin 1597 -> 1586 bytes
vignettes/web_only/saem_benchmarks.R | 121 ------------------------
vignettes/web_only/saem_benchmarks.html | 22 ++---
vignettes/web_only/saem_benchmarks.rda | Bin 366 -> 359 bytes
vignettes/web_only/saem_benchmarks.rmd | 2 +-
16 files changed, 76 insertions(+), 180 deletions(-)
delete mode 100644 vignettes/web_only/saem_benchmarks.R
diff --git a/NAMESPACE b/NAMESPACE
index 9c85945e..107ffc54 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -160,6 +160,7 @@ importFrom(parallel,detectCores)
importFrom(parallel,mclapply)
importFrom(parallel,parLapply)
importFrom(rlang,"!!!")
+importFrom(saemix,saemix)
importFrom(stats,AIC)
importFrom(stats,BIC)
importFrom(stats,aggregate)
diff --git a/R/saem.R b/R/saem.R
index e980ed1f..696ea0ee 100644
--- a/R/saem.R
+++ b/R/saem.R
@@ -14,6 +14,7 @@ utils::globalVariables(c("predicted", "std"))
#' using [mmkin].
#'
#' @importFrom utils packageVersion
+#' @importFrom saemix saemix
#' @param object An [mmkin] row object containing several fits of the same
#' [mkinmod] model to different datasets
#' @param verbose Should we print information about created objects of
@@ -175,7 +176,7 @@ saem.mmkin <- function(object,
fit_failed <- FALSE
FIM_failed <- NULL
fit_time <- system.time({
- utils::capture.output(f_saemix <- try(saemix::saemix(m_saemix, d_saemix, control)), split = !quiet)
+ utils::capture.output(f_saemix <- try(saemix(m_saemix, d_saemix, control)), split = !quiet)
if (inherits(f_saemix, "try-error")) fit_failed <- TRUE
})
diff --git a/docs/dev/articles/web_only/benchmarks.html b/docs/dev/articles/web_only/benchmarks.html
index cb048453..5c7aa3dc 100644
--- a/docs/dev/articles/web_only/benchmarks.html
+++ b/docs/dev/articles/web_only/benchmarks.html
@@ -78,7 +78,10 @@
Example evaluation of NAFTA SOP Attachment examples
- Some benchmark timings
+ Benchmark timings for mkin
+
+
+ Benchmark timings for saem.mmkin
@@ -109,7 +112,7 @@
Benchmark timings for mkin
Johannes Ranke
- Last change 14 July 2022 (rebuilt 2022-11-14)
+ Last change 14 July 2022 (rebuilt 2022-11-15)
Source: vignettes/web_only/benchmarks.rmd
benchmarks.rmd
@@ -348,8 +351,8 @@
Ryzen 7 1700 |
4.2.2 |
1.2.0 |
-2.030 |
-3.791 |
+2.129 |
+3.784 |
@@ -527,9 +530,9 @@
Ryzen 7 1700 |
4.2.2 |
1.2.0 |
-1.579 |
-6.591 |
-3.107 |
+1.559 |
+6.097 |
+2.841 |
@@ -761,12 +764,12 @@
Ryzen 7 1700 |
4.2.2 |
1.2.0 |
-0.915 |
-1.426 |
-1.613 |
-3.224 |
-2.068 |
-2.962 |
+0.911 |
+1.328 |
+1.519 |
+2.986 |
+1.957 |
+2.769 |
diff --git a/docs/dev/articles/web_only/saem_benchmarks.html b/docs/dev/articles/web_only/saem_benchmarks.html
index 97ea6fd4..e54bc38c 100644
--- a/docs/dev/articles/web_only/saem_benchmarks.html
+++ b/docs/dev/articles/web_only/saem_benchmarks.html
@@ -78,7 +78,10 @@
Example evaluation of NAFTA SOP Attachment examples
- Some benchmark timings
+ Benchmark timings for mkin
+
+
+ Benchmark timings for saem.mmkin
@@ -109,7 +112,7 @@
Benchmark timings for saem.mmkin
Johannes Ranke
- Last change 14 November 2022 (rebuilt 2022-11-14)
+ Last change 14 November 2022 (rebuilt 2022-11-15)
Source: vignettes/web_only/saem_benchmarks.rmd
saem_benchmarks.rmd
@@ -306,10 +309,10 @@
Linux |
1.2.0 |
3.2 |
-2.589 |
-4.945 |
-4.786 |
-4.484 |
+2.11 |
+4.632 |
+4.264 |
+4.93 |
Two-component error fits for SFO, DFOP, SFORB and HS.
@@ -329,10 +332,10 @@
Linux |
1.2.0 |
3.2 |
-5.645 |
-8.115 |
-7.737 |
-7.782 |
+5.602 |
+7.373 |
+7.815 |
+7.831 |
@@ -354,8 +357,8 @@
Linux |
1.2.0 |
3.2 |
-25.921 |
-766.034 |
+24.014 |
+749.699 |
@@ -376,7 +379,7 @@
Linux |
1.2.0 |
3.2 |
-1269.799 |
+1249.834 |
diff --git a/docs/dev/pkgdown.yml b/docs/dev/pkgdown.yml
index ad0d8b19..e0c11a84 100644
--- a/docs/dev/pkgdown.yml
+++ b/docs/dev/pkgdown.yml
@@ -13,7 +13,7 @@ articles:
dimethenamid_2018: web_only/dimethenamid_2018.html
multistart: web_only/multistart.html
saem_benchmarks: web_only/saem_benchmarks.html
-last_built: 2022-11-14T20:49Z
+last_built: 2022-11-14T23:45Z
urls:
reference: https://pkgdown.jrwb.de/mkin/reference
article: https://pkgdown.jrwb.de/mkin/articles
diff --git a/docs/dev/reference/Rplot001.png b/docs/dev/reference/Rplot001.png
index 17a35806..b3448db0 100644
Binary files a/docs/dev/reference/Rplot001.png and b/docs/dev/reference/Rplot001.png differ
diff --git a/docs/dev/reference/logLik.saem.mmkin.html b/docs/dev/reference/logLik.saem.mmkin.html
index b1ea22ef..ebef3b10 100644
--- a/docs/dev/reference/logLik.saem.mmkin.html
+++ b/docs/dev/reference/logLik.saem.mmkin.html
@@ -59,7 +59,10 @@
Example evaluation of NAFTA SOP Attachment examples
- Some benchmark timings
+ Benchmark timings for mkin
+
+
+ Benchmark timings for saem.mmkin
diff --git a/docs/dev/reference/mkinpredict.html b/docs/dev/reference/mkinpredict.html
index 14f2b75b..37930912 100644
--- a/docs/dev/reference/mkinpredict.html
+++ b/docs/dev/reference/mkinpredict.html
@@ -61,7 +61,10 @@ kinetic parameters and initial values for the state variables.">Example evaluation of NAFTA SOP Attachment examples
- Some benchmark timings
+ Benchmark timings for mkin
+
+
+ Benchmark timings for saem.mmkin
@@ -371,10 +374,10 @@ as these always return mapped output.
}
#> Loading required package: rbenchmark
#> test relative elapsed
-#> 2 deSolve_compiled 1.00 0.004
-#> 4 analytical 5.25 0.021
-#> 1 eigen 6.00 0.024
-#> 3 deSolve 52.50 0.210
+#> 2 deSolve_compiled 1.0 0.005
+#> 1 eigen 4.2 0.021
+#> 4 analytical 4.2 0.021
+#> 3 deSolve 40.8 0.204
# \dontrun{
# Predict from a fitted model
diff --git a/docs/dev/reference/saem.html b/docs/dev/reference/saem.html
index 968dc68c..73382cba 100644
--- a/docs/dev/reference/saem.html
+++ b/docs/dev/reference/saem.html
@@ -61,7 +61,10 @@ Expectation Maximisation algorithm (SAEM).">Example evaluation of NAFTA SOP Attachment examples
- Some benchmark timings
+ Benchmark timings for mkin
+
+
+ Benchmark timings for saem.mmkin
@@ -429,8 +432,8 @@ using mmkin.
#> saemix version used for fitting: 3.2
#> mkin version used for pre-fitting: 1.2.0
#> R version used for fitting: 4.2.2
-#> Date of fit: Mon Nov 14 21:06:30 2022
-#> Date of summary: Mon Nov 14 21:06:30 2022
+#> Date of fit: Tue Nov 15 00:45:58 2022
+#> Date of summary: Tue Nov 15 00:45:58 2022
#>
#> Equations:
#> d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -445,7 +448,7 @@ using mmkin.
#>
#> Model predictions using solution type analytical
#>
-#> Fitted in 9.625 s
+#> Fitted in 9.189 s
#> Using 300, 100 iterations and 10 chains
#>
#> Variance model: Constant variance
diff --git a/log/test.log b/log/test.log
index f20a7f18..7005ac37 100644
--- a/log/test.log
+++ b/log/test.log
@@ -5,7 +5,7 @@
✔ | 5 | Calculation of Akaike weights
✔ | 3 | Export dataset for reading into CAKE
✔ | 12 | Confidence intervals and p-values [1.0s]
-✔ | 1 12 | Dimethenamid data from 2018 [32.1s]
+✔ | 1 12 | Dimethenamid data from 2018 [32.4s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_dmta.R:98'): Different backends get consistent results for SFO-SFO3+, dimethenamid data
Reason: Fitting this ODE model with saemix takes about 15 minutes on my system
@@ -14,9 +14,9 @@ Reason: Fitting this ODE model with saemix takes about 15 minutes on my system
✔ | 5 | Time step normalisation
✔ | 4 | Calculation of FOCUS chi2 error levels [0.6s]
✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [0.8s]
-✔ | 4 | Test fitting the decline of metabolites from their maximum [0.3s]
+✔ | 4 | Test fitting the decline of metabolites from their maximum [0.4s]
✔ | 1 | Fitting the logistic model [0.2s]
-✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [24.0s]
+✔ | 10 | Batch fitting and diagnosing hierarchical kinetic models [24.2s]
✔ | 1 12 | Nonlinear mixed-effects models [0.3s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_mixed.R:74'): saemix results are reproducible for biphasic fits
@@ -26,13 +26,13 @@ Reason: Fitting with saemix takes around 10 minutes when using deSolve
✔ | 10 | Special cases of mkinfit calls [0.5s]
✔ | 3 | mkinfit features [0.7s]
✔ | 8 | mkinmod model generation and printing [0.2s]
-✔ | 3 | Model predictions with mkinpredict [0.4s]
-✔ | 7 | Multistart method for saem.mmkin models [36.7s]
+✔ | 3 | Model predictions with mkinpredict [0.3s]
+✔ | 7 | Multistart method for saem.mmkin models [36.9s]
✔ | 16 | Evaluations according to 2015 NAFTA guidance [2.3s]
-✔ | 9 | Nonlinear mixed-effects models with nlme [8.5s]
+✔ | 9 | Nonlinear mixed-effects models with nlme [8.6s]
✔ | 16 | Plotting [9.8s]
✔ | 4 | Residuals extracted from mkinfit models
-✔ | 1 36 | saemix parent models [66.4s]
+✔ | 1 36 | saemix parent models [66.3s]
────────────────────────────────────────────────────────────────────────────────
Skip ('test_saemix_parent.R:143'): We can also use mkin solution methods for saem
Reason: This still takes almost 2.5 minutes although we do not solve ODEs
@@ -47,7 +47,7 @@ Reason: This still takes almost 2.5 minutes although we do not solve ODEs
✔ | 4 | Calculation of maximum time weighted average concentrations (TWAs) [2.2s]
══ Results ═════════════════════════════════════════════════════════════════════
-Duration: 211.1 s
+Duration: 211.7 s
── Skipped tests ──────────────────────────────────────────────────────────────
• Fitting this ODE model with saemix takes about 15 minutes on my system (1)
diff --git a/vignettes/web_only/benchmarks.rmd b/vignettes/web_only/benchmarks.rmd
index de8ee723..117dc96a 100644
--- a/vignettes/web_only/benchmarks.rmd
+++ b/vignettes/web_only/benchmarks.rmd
@@ -141,7 +141,7 @@ t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c),
```{r results, include = FALSE}
mkin_benchmarks[system_string, paste0("t", 1:11)] <-
c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
-save(mkin_benchmarks, file = benchmark_path)
+save(mkin_benchmarks, file = benchmark_path, version = 2)
# Hide rownames from kable for results section
rownames(mkin_benchmarks) <- NULL
```
diff --git a/vignettes/web_only/mkin_benchmarks.rda b/vignettes/web_only/mkin_benchmarks.rda
index a0d4c72c..2d3deb26 100644
Binary files a/vignettes/web_only/mkin_benchmarks.rda and b/vignettes/web_only/mkin_benchmarks.rda differ
diff --git a/vignettes/web_only/saem_benchmarks.R b/vignettes/web_only/saem_benchmarks.R
deleted file mode 100644
index 210e79e3..00000000
--- a/vignettes/web_only/saem_benchmarks.R
+++ /dev/null
@@ -1,121 +0,0 @@
-## ---- include = FALSE---------------------------------------------------------
-library("knitr") # For the kable() function
-opts_chunk$set(tidy = FALSE, cache = FALSE)
-library("mkin")
-
-## ----include = FALSE----------------------------------------------------------
-cpu_model <- benchmarkme::get_cpu()$model_name
-# Abbreviate CPU identifiers
-cpu_model <- gsub("AMD ", "", cpu_model)
-cpu_model <- gsub("Intel\\(R\\) Core\\(TM\\) ", "", cpu_model)
-cpu_model <- gsub(" Eight-Core Processor", "", cpu_model)
-cpu_model <- gsub(" CPU @ 2.50GHz", "", cpu_model)
-
-operating_system <- Sys.info()[["sysname"]]
-mkin_version <- as.character(packageVersion("mkin"))
-saemix_version <- as.character(packageVersion("saemix"))
-R_version <- paste0(R.version$major, ".", R.version$minor)
-system_string <- paste0(operating_system, ", ", cpu_model, ", mkin ", mkin_version, ", saemix ", saemix_version, ", R ", R_version)
-
-benchmark_path = normalizePath("~/git/mkin/vignettes/web_only/saem_benchmarks.rda")
-load(benchmark_path)
-
-# Initialization 14 November 2022
-#saem_benchmarks <- data.frame()
-
-saem_benchmarks[system_string, c("CPU", "OS", "mkin", "saemix", "R")] <-
- c(cpu_model, operating_system, mkin_version, saemix_version, R_version)
-
-## ----setup--------------------------------------------------------------------
-n_cores <- parallel::detectCores()
-
-## ----dimethenamid_data--------------------------------------------------------
-dmta_ds <- lapply(1:7, function(i) {
- ds_i <- dimethenamid_2018$ds[[i]]$data
- ds_i[ds_i$name == "DMTAP", "name"] <- "DMTA"
- ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i]
- ds_i
-})
-names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title)
-dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]])
-dmta_ds[["Elliot 1"]] <- NULL
-dmta_ds[["Elliot 2"]] <- NULL
-
-## ----parent_only--------------------------------------------------------------
-parent_mods <- c("SFO", "DFOP", "SFORB", "HS")
-parent_sep_const <- mmkin(parent_mods, dmta_ds, quiet = TRUE, cores = n_cores)
-parent_sep_tc <- update(parent_sep_const, error_model = "tc")
-
-t1 <- system.time(sfo_const <- saem(parent_sep_const["SFO", ]))[["elapsed"]]
-t2 <- system.time(dfop_const <- saem(parent_sep_const["DFOP", ]))[["elapsed"]]
-t3 <- system.time(sforb_const <- saem(parent_sep_const["SFORB", ]))[["elapsed"]]
-t4 <- system.time(hs_const <- saem(parent_sep_const["HS", ]))[["elapsed"]]
-t5 <- system.time(sfo_tc <- saem(parent_sep_tc["SFO", ]))[["elapsed"]]
-t6 <- system.time(dfop_tc <- saem(parent_sep_tc["DFOP", ]))[["elapsed"]]
-t7 <- system.time(sforb_tc <- saem(parent_sep_tc["SFORB", ]))[["elapsed"]]
-t8 <- system.time(hs_tc <- saem(parent_sep_tc["HS", ]))[["elapsed"]]
-
-## -----------------------------------------------------------------------------
-anova(
- sfo_const, dfop_const, sforb_const, hs_const,
- sfo_tc, dfop_tc, sforb_tc, hs_tc) |> kable(, digits = 1)
-
-## -----------------------------------------------------------------------------
-illparms(dfop_tc)
-illparms(sforb_tc)
-
-## ----one_metabolite, message = FALSE------------------------------------------
-one_met_mods <- list(
- DFOP_SFO = mkinmod(
- DMTA = mkinsub("DFOP", "M23"),
- M23 = mkinsub("SFO")),
- SFORB_SFO = mkinmod(
- DMTA = mkinsub("SFORB", "M23"),
- M23 = mkinsub("SFO")))
-
-one_met_sep_const <- mmkin(one_met_mods, dmta_ds, error_model = "const",
- cores = n_cores, quiet = TRUE)
-one_met_sep_tc <- mmkin(one_met_mods, dmta_ds, error_model = "tc",
- cores = n_cores, quiet = TRUE)
-
-t9 <- system.time(dfop_sfo_tc <- saem(one_met_sep_tc["DFOP_SFO", ],
- no_random_effect = "log_k2"))[["elapsed"]]
-t10 <- system.time(sforb_sfo_tc <- saem(one_met_sep_tc["SFORB_SFO", ],
- no_random_effect = "log_k_DMTA_bound_free"))[["elapsed"]]
-
-## -----------------------------------------------------------------------------
-illparms(sforb_sfo_tc)
-
-## ----three_metabolites, message = FALSE---------------------------------------
-three_met_mods <- list(
- SFORB_SFO3_plus = mkinmod(
- DMTA = mkinsub("SFORB", c("M23", "M27", "M31")),
- M23 = mkinsub("SFO"),
- M27 = mkinsub("SFO"),
- M31 = mkinsub("SFO", "M27", sink = FALSE)))
-
-three_met_sep_tc <- mmkin(three_met_mods, dmta_ds, error_model = "tc",
- cores = n_cores, quiet = TRUE)
-
-t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SFORB_SFO3_plus", ],
- no_random_effect = "log_k_DMTA_bound_free"))[["elapsed"]]
-
-## ----results, include = FALSE-------------------------------------------------
-saem_benchmarks[system_string, paste0("t", 1:11)] <-
- c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
-save(saem_benchmarks, file = benchmark_path)
-# Hide rownames from kable for results section
-rownames(saem_benchmarks) <- NULL
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(saem_benchmarks[, c(1:4, 6:9)])
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(saem_benchmarks[, c(1:4, 10:13)])
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(saem_benchmarks[, c(1:4, 14:15)])
-
-## ---- echo = FALSE------------------------------------------------------------
-kable(saem_benchmarks[, c(1:4, 16)])
-
diff --git a/vignettes/web_only/saem_benchmarks.html b/vignettes/web_only/saem_benchmarks.html
index 42d6f71f..4875bb1b 100644
--- a/vignettes/web_only/saem_benchmarks.html
+++ b/vignettes/web_only/saem_benchmarks.html
@@ -1781,10 +1781,10 @@ t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SF
Linux |
1.2.0 |
3.2 |
-3.025 |
-5.237 |
-5.459 |
-5.218 |
+2.996 |
+5.207 |
+5.317 |
+5.171 |
@@ -1808,10 +1808,10 @@ t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SF
Linux |
1.2.0 |
3.2 |
-5.645 |
-7.726 |
-7.952 |
-8.104 |
+5.671 |
+7.696 |
+8.166 |
+8.168 |
@@ -1836,8 +1836,8 @@ t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SF
Linux |
1.2.0 |
3.2 |
-24.84 |
-816.153 |
+24.883 |
+818.157 |
@@ -1861,7 +1861,7 @@ t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SF
Linux |
1.2.0 |
3.2 |
-1323.128 |
+1355.036 |
diff --git a/vignettes/web_only/saem_benchmarks.rda b/vignettes/web_only/saem_benchmarks.rda
index 1e75b20d..e8b139da 100644
Binary files a/vignettes/web_only/saem_benchmarks.rda and b/vignettes/web_only/saem_benchmarks.rda differ
diff --git a/vignettes/web_only/saem_benchmarks.rmd b/vignettes/web_only/saem_benchmarks.rmd
index 116713de..6e51fa66 100644
--- a/vignettes/web_only/saem_benchmarks.rmd
+++ b/vignettes/web_only/saem_benchmarks.rmd
@@ -164,7 +164,7 @@ t11 <- system.time(sforb_sfo3_plus_const <- saem(three_met_sep_tc["SFORB_SFO3_pl
```{r results, include = FALSE}
saem_benchmarks[system_string, paste0("t", 1:11)] <-
c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
-save(saem_benchmarks, file = benchmark_path)
+save(saem_benchmarks, file = benchmark_path, version = 2)
# Hide rownames from kable for results section
rownames(saem_benchmarks) <- NULL
```
--
cgit v1.2.1