From 234c9059a95e104917e488a6ddd2313234a96cdc Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 11 May 2020 05:15:19 +0200 Subject: 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. --- docs/articles/FOCUS_D.html | 110 ++++--- docs/articles/FOCUS_D_files/figure-html/plot-1.png | Bin 101585 -> 101350 bytes .../FOCUS_D_files/figure-html/plot_2-1.png | Bin 14220 -> 15733 bytes docs/articles/mkin.html | 113 ++++--- .../mkin_files/figure-html/unnamed-chunk-2-1.png | Bin 113818 -> 116140 bytes docs/articles/web_only/benchmarks.html | 248 +++++++--------- docs/news/index.html | 1 - docs/pkgdown.yml | 2 +- docs/reference/create_deg_func.html | 16 +- docs/reference/index.html | 6 + docs/reference/mkinfit.html | 328 ++++++++++++++------- docs/reference/mkinmod.html | 4 +- docs/reference/mkinpredict.html | 253 ++++++++-------- docs/reference/plot.mkinfit-1.png | Bin 45157 -> 53973 bytes docs/reference/plot.mkinfit-2.png | Bin 62528 -> 75079 bytes docs/reference/plot.mkinfit-3.png | Bin 57593 -> 70266 bytes docs/reference/plot.mkinfit-4.png | Bin 61280 -> 74166 bytes docs/reference/plot.mkinfit-5.png | Bin 59080 -> 68692 bytes docs/reference/plot.mkinfit-6.png | Bin 64639 -> 75012 bytes docs/reference/plot.mkinfit-7.png | Bin 65273 -> 75692 bytes docs/reference/plot.mkinfit.html | 61 ++-- 21 files changed, 607 insertions(+), 535 deletions(-) (limited to 'docs') diff --git a/docs/articles/FOCUS_D.html b/docs/articles/FOCUS_D.html index e9c6b005..0a9ddf4a 100644 --- a/docs/articles/FOCUS_D.html +++ b/docs/articles/FOCUS_D.html @@ -31,7 +31,7 @@ mkin - 0.9.49.11 + 0.9.50 @@ -97,7 +97,7 @@

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

2020-05-07

+

2020-05-11

Source: vignettes/FOCUS_D.Rmd @@ -159,10 +159,10 @@
SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
print(SFO_SFO$diffs)
-
##                                                       parent 
-## "d_parent = - k_parent_sink * parent - k_parent_m1 * parent" 
-##                                                           m1 
-##             "d_m1 = + k_parent_m1 * parent - k_m1_sink * m1"
+
##                                                    parent 
+##                          "d_parent = - k_parent * parent" 
+##                                                        m1 
+## "d_m1 = + f_parent_to_m1 * k_parent * parent - k_m1 * m1"

We do the fitting without progress report (quiet = TRUE).

fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
## Warning in mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE): Observations with value
@@ -175,85 +175,83 @@
 

A comprehensive report of the results is obtained using the summary method for mkinfit objects.

summary(fit)
-
## mkin version used for fitting:    0.9.49.11 
+
## mkin version used for fitting:    0.9.50 
 ## R version used for fitting:       4.0.0 
-## Date of fit:     Thu May  7 08:59:27 2020 
-## Date of summary: Thu May  7 08:59:27 2020 
+## Date of fit:     Mon May 11 05:14:41 2020 
+## Date of summary: Mon May 11 05:14:41 2020 
 ## 
 ## Equations:
-## d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent
-## d_m1/dt = + k_parent_m1 * parent - k_m1_sink * m1
+## d_parent/dt = - k_parent * parent
+## d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1
 ## 
-## Model predictions using solution type deSolve 
+## Model predictions using solution type analytical 
 ## 
-## Fitted using 389 model solutions performed in 1.031 s
+## Fitted using 421 model solutions performed in 0.167 s
 ## 
 ## Error model: Constant variance 
 ## 
 ## Error model algorithm: OLS 
 ## 
 ## Starting values for parameters to be optimised:
-##                  value   type
-## parent_0      100.7500  state
-## k_parent_sink   0.1000 deparm
-## k_parent_m1     0.1001 deparm
-## k_m1_sink       0.1002 deparm
+##                   value   type
+## parent_0       100.7500  state
+## k_parent         0.1000 deparm
+## k_m1             0.1001 deparm
+## f_parent_to_m1   0.5000 deparm
 ## 
 ## Starting values for the transformed parameters actually optimised:
-##                        value lower upper
-## parent_0          100.750000  -Inf   Inf
-## log_k_parent_sink  -2.302585  -Inf   Inf
-## log_k_parent_m1    -2.301586  -Inf   Inf
-## log_k_m1_sink      -2.300587  -Inf   Inf
+##                     value lower upper
+## parent_0       100.750000  -Inf   Inf
+## log_k_parent    -2.302585  -Inf   Inf
+## log_k_m1        -2.301586  -Inf   Inf
+## f_parent_ilr_1   0.000000  -Inf   Inf
 ## 
 ## Fixed parameter values:
 ##      value  type
 ## m1_0     0 state
 ## 
+## Results:
+## 
+##        AIC      BIC    logLik
+##   204.4486 212.6365 -97.22429
+## 
 ## Optimised, transformed parameters with symmetric confidence intervals:
-##                   Estimate Std. Error  Lower   Upper
-## parent_0            99.600    1.57000 96.400 102.800
-## log_k_parent_sink   -3.038    0.07626 -3.193  -2.883
-## log_k_parent_m1     -2.980    0.04033 -3.062  -2.898
-## log_k_m1_sink       -5.248    0.13320 -5.518  -4.977
-## sigma                3.126    0.35850  2.396   3.855
+##                Estimate Std. Error    Lower    Upper
+## parent_0       99.60000    1.57000 96.40000 102.8000
+## log_k_parent   -2.31600    0.04087 -2.39900  -2.2330
+## log_k_m1       -5.24800    0.13320 -5.51800  -4.9770
+## f_parent_ilr_1  0.04096    0.06312 -0.08746   0.1694
+## sigma           3.12600    0.35850  2.39600   3.8550
 ## 
 ## Parameter correlation:
-##                     parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink
-## parent_0           1.000e+00         6.067e-01      -6.372e-02    -1.688e-01
-## log_k_parent_sink  6.067e-01         1.000e+00      -8.550e-02    -6.252e-01
-## log_k_parent_m1   -6.372e-02        -8.550e-02       1.000e+00     4.731e-01
-## log_k_m1_sink     -1.688e-01        -6.252e-01       4.731e-01     1.000e+00
-## sigma              5.287e-10         3.306e-09       4.421e-08    -3.319e-10
-##                        sigma
-## parent_0           5.287e-10
-## log_k_parent_sink  3.306e-09
-## log_k_parent_m1    4.421e-08
-## log_k_m1_sink     -3.319e-10
-## sigma              1.000e+00
+##                  parent_0 log_k_parent   log_k_m1 f_parent_ilr_1      sigma
+## parent_0        1.000e+00    5.174e-01 -1.688e-01     -5.471e-01 -3.214e-07
+## log_k_parent    5.174e-01    1.000e+00 -3.263e-01     -5.426e-01  3.168e-07
+## log_k_m1       -1.688e-01   -3.263e-01  1.000e+00      7.478e-01 -1.410e-07
+## f_parent_ilr_1 -5.471e-01   -5.426e-01  7.478e-01      1.000e+00  5.093e-10
+## sigma          -3.214e-07    3.168e-07 -1.410e-07      5.093e-10  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
 ## t-test (unrealistically) based on the assumption of normal distribution
 ## for estimators of untransformed parameters.
-##                Estimate t value    Pr(>t)     Lower     Upper
-## parent_0      99.600000  63.430 2.298e-36 96.400000 1.028e+02
-## k_parent_sink  0.047920  13.110 6.126e-15  0.041030 5.596e-02
-## k_parent_m1    0.050780  24.800 3.269e-23  0.046780 5.512e-02
-## k_m1_sink      0.005261   7.510 6.165e-09  0.004012 6.898e-03
-## sigma          3.126000   8.718 2.235e-10  2.396000 3.855e+00
+##                 Estimate t value    Pr(>t)     Lower     Upper
+## parent_0       99.600000  63.430 2.298e-36 96.400000 1.028e+02
+## k_parent        0.098700  24.470 4.955e-23  0.090820 1.073e-01
+## k_m1            0.005261   7.510 6.165e-09  0.004012 6.898e-03
+## f_parent_to_m1  0.514500  23.070 3.104e-22  0.469100 5.596e-01
+## sigma           3.126000   8.718 2.235e-10  2.396000 3.855e+00
 ## 
 ## FOCUS Chi2 error levels in percent:
 ##          err.min n.optim df
 ## All data   6.398       4 15
-## parent     6.827       3  6
-## m1         4.490       1  9
+## parent     6.459       2  7
+## m1         4.690       2  8
 ## 
 ## Resulting formation fractions:
 ##                 ff
-## parent_sink 0.4855
 ## parent_m1   0.5145
-## m1_sink     1.0000
+## parent_sink 0.4855
 ## 
 ## Estimated disappearance times:
 ##           DT50   DT90
@@ -266,10 +264,10 @@
 ##     0   parent   102.04  99.59848  2.442e+00
 ##     1   parent    93.50  90.23787  3.262e+00
 ##     1   parent    92.50  90.23787  2.262e+00
-##     3   parent    63.23  74.07320 -1.084e+01
-##     3   parent    68.99  74.07320 -5.083e+00
-##     7   parent    52.32  49.91207  2.408e+00
-##     7   parent    55.13  49.91207  5.218e+00
+##     3   parent    63.23  74.07319 -1.084e+01
+##     3   parent    68.99  74.07319 -5.083e+00
+##     7   parent    52.32  49.91206  2.408e+00
+##     7   parent    55.13  49.91206  5.218e+00
 ##    14   parent    27.27  25.01257  2.257e+00
 ##    14   parent    26.64  25.01257  1.627e+00
 ##    21   parent    11.50  12.53462 -1.035e+00
@@ -279,7 +277,7 @@
 ##    50   parent     0.69   0.71624 -2.624e-02
 ##    50   parent     0.63   0.71624 -8.624e-02
 ##    75   parent     0.05   0.06074 -1.074e-02
-##    75   parent     0.06   0.06074 -7.382e-04
+##    75   parent     0.06   0.06074 -7.381e-04
 ##     1       m1     4.84   4.80296  3.704e-02
 ##     1       m1     5.64   4.80296  8.370e-01
 ##     3       m1    12.91  13.02400 -1.140e-01
diff --git a/docs/articles/FOCUS_D_files/figure-html/plot-1.png b/docs/articles/FOCUS_D_files/figure-html/plot-1.png
index a7944b84..306244b3 100644
Binary files a/docs/articles/FOCUS_D_files/figure-html/plot-1.png and b/docs/articles/FOCUS_D_files/figure-html/plot-1.png differ
diff --git a/docs/articles/FOCUS_D_files/figure-html/plot_2-1.png b/docs/articles/FOCUS_D_files/figure-html/plot_2-1.png
index 97c61a16..158e3c50 100644
Binary files a/docs/articles/FOCUS_D_files/figure-html/plot_2-1.png and b/docs/articles/FOCUS_D_files/figure-html/plot_2-1.png differ
diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html
index 42eb6c0a..b828b7dc 100644
--- a/docs/articles/mkin.html
+++ b/docs/articles/mkin.html
@@ -6,19 +6,19 @@
 
 
 Introduction to mkin • mkin
-
-
-
-
+
+
+
+
+
 
-
-
+
 
 
-
+
     
@@ -87,12 +94,12 @@
@@ -104,34 +111,34 @@

Abstract

In the regulatory evaluation of chemical substances like plant protection products (pesticides), biocides and other chemicals, degradation data play an important role. For the evaluation of pesticide degradation experiments, detailed guidance has been developed, based on nonlinear optimisation. The R add-on package mkin implements fitting some of the models recommended in this guidance from within R and calculates some statistical measures for data series within one or more compartments, for parent and metabolites.

- +
library("mkin", quietly = TRUE)
+# Define the kinetic model
+m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
+                         M1 = mkinsub("SFO", "M2"),
+                         M2 = mkinsub("SFO"),
+                         use_of_ff = "max", quiet = TRUE)
+
+
+# Produce model predictions using some arbitrary parameters
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+d_SFO_SFO_SFO <- mkinpredict(m_SFO_SFO_SFO,
+  c(k_parent = 0.03,
+    f_parent_to_M1 = 0.5, k_M1 = log(2)/100,
+    f_M1_to_M2 = 0.9, k_M2 = log(2)/50),
+  c(parent = 100, M1 = 0, M2 = 0),
+  sampling_times)
+
+# Generate a dataset by adding normally distributed errors with
+# standard deviation 3, for two replicates at each sampling time
+d_SFO_SFO_SFO_err <- add_err(d_SFO_SFO_SFO, reps = 2,
+                             sdfunc = function(x) 3,
+                             n = 1, seed = 123456789 )
+
+# Fit the model to the dataset
+f_SFO_SFO_SFO <- mkinfit(m_SFO_SFO_SFO, d_SFO_SFO_SFO_err[[1]], quiet = TRUE)
+
+# Plot the results separately for parent and metabolites
+plot_sep(f_SFO_SFO_SFO, lpos = c("topright", "bottomright", "bottomright"))

@@ -222,29 +229,11 @@
- @@ -255,7 +244,7 @@
-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png index e21b4233..bdc067c1 100644 Binary files a/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png and b/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/web_only/benchmarks.html b/docs/articles/web_only/benchmarks.html index 4fb76fa2..ad7cf62c 100644 --- a/docs/articles/web_only/benchmarks.html +++ b/docs/articles/web_only/benchmarks.html @@ -6,19 +6,19 @@ Benchmark timings for mkin on various systems • mkin - - - - + + + + + - - + - +
@@ -87,12 +94,12 @@
@@ -103,192 +110,143 @@

Systems

Each system is characterized by its CPU type, the operating system type and the mkin version.

-
cpu_model <- benchmarkme::get_cpu()$model_name
-operating_system <- Sys.info()[["sysname"]]
-mkin_version <- as.character(packageVersion("mkin"))
-system_string <- paste0(operating_system, ", ", cpu_model, ", mkin version ", mkin_version)
-load("~/git/mkin/vignettes/web_only/mkin_benchmarks.rda")
-mkin_benchmarks[system_string, c("CPU", "OS", "mkin")] <- c(cpu_model, operating_system, mkin_version)
-
-if (mkin_version > "0.9.48.1") {
-  mmkin_bench <- function(models, datasets, error_model = "const") mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE)
-} else {
-  mmkin_bench <- function(models, datasets, error_model = NULL) mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE)
-}
-
# Parent only
-t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_2006_C, FOCUS_2006_D)))[["elapsed"]]
-t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_2006_C, FOCUS_2006_D), error_model = "tc"))[["elapsed"]]
+
cpu_model <- benchmarkme::get_cpu()$model_name
+operating_system <- Sys.info()[["sysname"]]
+mkin_version <- as.character(packageVersion("mkin"))
+system_string <- paste0(operating_system, ", ", cpu_model, ", mkin version ", mkin_version)
+load("~/git/mkin/vignettes/web_only/mkin_benchmarks.rda")
+mkin_benchmarks[system_string, c("CPU", "OS", "mkin")] <- c(cpu_model, operating_system, mkin_version)
+
+if (mkin_version > "0.9.48.1") {
+  mmkin_bench <- function(models, datasets, error_model = "const") mmkin(models, datasets, error_model = error_model, cores = 1, quiet = TRUE)
+} else {
+  mmkin_bench <- function(models, datasets, error_model = NULL) mmkin(models, datasets, reweight.method = error_model, cores = 1, quiet = TRUE)
+}
+
FOCUS_C <- FOCUS_2006_C
+FOCUS_D <- subset(FOCUS_2006_D, value != 0)
+# Parent only
+t1 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_C, FOCUS_D)))[["elapsed"]]
+t2 <- system.time(mmkin_bench(c("SFO", "FOMC", "DFOP", "HS"), list(FOCUS_C, FOCUS_D), error_model = "tc"))[["elapsed"]]
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...): Optimisation did not converge:
+## iteration limit reached without convergence (10)
+
+## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...): Optimisation did not converge:
 ## iteration limit reached without convergence (10)
- +
# One metabolite
+SFO_SFO <- mkinmod(
+  parent = mkinsub("SFO", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
- +
FOMC_SFO <- mkinmod(
+  parent = mkinsub("FOMC", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
- +
DFOP_SFO <- mkinmod(
+  parent = mkinsub("FOMC", "m1"),
+  m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
-
t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_2006_D)))[["elapsed"]]
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+
t3 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D)))[["elapsed"]]
+t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), error_model = "tc"))[["elapsed"]]
+t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_D), error_model = "obs"))[["elapsed"]]
+
+# Two metabolites, synthetic data
+m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
+                           M1 = mkinsub("SFO", "M2"),
+                           M2 = mkinsub("SFO"),
+                           use_of_ff = "max", quiet = TRUE)
+
+m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
+                           M1 = mkinsub("SFO"),
+                           M2 = mkinsub("SFO"),
+                           use_of_ff = "max", quiet = TRUE)
+
+SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
t4 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(subset(FOCUS_2006_D, value != 0)), error_model = "tc"))[["elapsed"]]
-t5 <- system.time(mmkin_bench(list(SFO_SFO, FOMC_SFO, DFOP_SFO), list(FOCUS_2006_D), error_model = "obs"))[["elapsed"]]
-
## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
+t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))["elapsed"]
+t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))["elapsed"]
 
-## Warning in mkinfit(models[[model_index]], datasets[[dataset_index]], ...):
-## Observations with value of zero were removed from the data
-
# Two metabolites, synthetic data
-m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"),
-                           M1 = mkinsub("SFO", "M2"),
-                           M2 = mkinsub("SFO"),
-                           use_of_ff = "max", quiet = TRUE)
-
-m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")),
-                           M1 = mkinsub("SFO"),
-                           M2 = mkinsub("SFO"),
-                           use_of_ff = "max", quiet = TRUE)
-
-SFO_lin_a <- synthetic_data_for_UBA_2014[[1]]$data
-
-DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data
-
-t6 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a)))["elapsed"]
-t7 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c)))["elapsed"]
-
-t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "tc"))["elapsed"]
-t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "tc"))["elapsed"]
-
-t10 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "obs"))["elapsed"]
-t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "obs"))["elapsed"]
-
-mkin_benchmarks[system_string, paste0("t", 1:11)] <- c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
-mkin_benchmarks
-
##                                                                                                       CPU
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 AMD Ryzen 7 1700 Eight-Core Processor
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 AMD Ryzen 7 1700 Eight-Core Processor
-##                                                                        OS
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 Linux
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 Linux
-##                                                                         mkin
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 0.9.48.1
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 0.9.49.1
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 0.9.49.2
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 0.9.49.3
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 0.9.49.4
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 0.9.49.6
-##                                                                        t1
+t8 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "tc"))["elapsed"]
+t9 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "tc"))["elapsed"]
+
+t10 <- system.time(mmkin_bench(list(m_synth_SFO_lin), list(SFO_lin_a), error_model = "obs"))["elapsed"]
+t11 <- system.time(mmkin_bench(list(m_synth_DFOP_par), list(DFOP_par_c), error_model = "obs"))["elapsed"]
+
+mkin_benchmarks[system_string, paste0("t", 1:11)] <- c(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11)
+mkin_benchmarks[, -c(1:3)]
+
##                                                                        t1
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 3.610
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 8.184
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 7.064
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 7.296
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 5.936
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 5.901
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.683
 ##                                                                         t2
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 11.019
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 22.889
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 12.558
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 21.239
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 20.545
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 36.164
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    3.862
 ##                                                                        t3
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 3.764
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.649
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.786
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.510
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.446
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 4.510
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.369
 ##                                                                         t4
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 14.347
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 13.789
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  8.461
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 13.805
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 15.335
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 30.849
-##                                                                         t5
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1  9.495
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  6.395
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  5.675
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.386
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  6.002
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 10.545
-##                                                                        t6
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 2.623
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 2.542
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 2.723
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 2.643
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 2.635
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 2.563
-##                                                                        t7
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 4.587
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.128
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.478
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.374
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.259
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 4.252
-##                                                                        t8
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 7.525
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.632
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.862
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.02
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.737
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 7.865
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    6.104
+##                                                                        t5    t6
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 9.495 2.623
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 6.395 2.542
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 5.675 2.723
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 7.386 2.643
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 6.002 2.635
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   2.718 0.752
+##                                                                        t7    t8
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 4.587 7.525
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 4.128 4.632
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 4.478 4.862
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 4.374  7.02
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 4.259 4.737
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   1.214 1.276
 ##                                                                         t9
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 16.621
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  8.171
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  7.618
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 11.124
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  7.763
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 16.195
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50    2.858
 ##                                                                       t10
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 8.576
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1 3.676
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2 3.579
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3 5.388
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4 3.427
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 7.729
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50   2.032
 ##                                                                        t11
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.48.1 31.267
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.1  5.636
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.2  5.574
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.3  7.365
 ## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.4  5.626
-## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.49.6 10.787
-
save(mkin_benchmarks, file = "~/git/mkin/vignettes/mkin_benchmarks.rda")
+## Linux, AMD Ryzen 7 1700 Eight-Core Processor, mkin version 0.9.50 2.973
+
save(mkin_benchmarks, file = "~/git/mkin/vignettes/mkin_benchmarks.rda")
- @@ -299,7 +257,7 @@
-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

diff --git a/docs/news/index.html b/docs/news/index.html index bc69fd2d..1e13041d 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -145,7 +145,6 @@
  • Support SFORB with formation fractions

  • ‘mkinmod’: Make ‘use_of_ff’ = “max” the default

  • -
  • Implement analytical solutions for some coupled models, e.g. SFO-SFO, DFOP-SFO, SFORB-SFO

diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 32bcaa05..b3cd3d30 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -10,7 +10,7 @@ articles: NAFTA_examples: web_only/NAFTA_examples.html benchmarks: web_only/benchmarks.html compiled_models: web_only/compiled_models.html -last_built: 2020-05-07T20:11Z +last_built: 2020-05-11T03:18Z urls: reference: https://pkgdown.jrwb.de/mkin/reference article: https://pkgdown.jrwb.de/mkin/articles diff --git a/docs/reference/create_deg_func.html b/docs/reference/create_deg_func.html index e14857cc..67016be0 100644 --- a/docs/reference/create_deg_func.html +++ b/docs/reference/create_deg_func.html @@ -167,7 +167,21 @@
SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
+ m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
FOCUS_D <- subset(FOCUS_2006_D, value != 0) # to avoid warnings +fit_1 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE) +fit_2 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE) +# \dontrun{ +if (require(rbenchmark)) + benchmark( + analytical = mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE), + deSolve = mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE), + replications = 1)
#> Lade nötiges Paket: rbenchmark
#> test replications elapsed relative user.self sys.self user.child +#> 1 analytical 1 0.198 1.000 0.198 0.000 0 +#> 2 deSolve 1 0.350 1.768 0.348 0.001 0 +#> sys.child +#> 1 0 +#> 2 0
# } +
@@ -174,7 +174,6 @@ likelihood function.

quiet = FALSE, atol = 1e-08, rtol = 1e-10, - n.outtimes = 100, error_model = c("const", "obs", "tc"), error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep", "fourstep", "IRLS", "OLS"), @@ -323,13 +322,6 @@ is 1e-8, lower than in lsoda.

rtol

Absolute error tolerance, passed to ode. Default is 1e-10, much lower than in lsoda.

- - - n.outtimes -

The length of the dataseries that is produced by the model -prediction function mkinpredict. This impacts the accuracy -of the numerical solver if that is used (see solution_type -argument. The default value is 100.

error_model @@ -422,7 +414,87 @@ estimators.

Examples

# Use shorthand notation for parent only degradation -fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
#> Error in (function (t, parent_0, alpha, beta) { parent = parent_0/(t/beta + 1)^alpha})(t = c(0, 1, 1.2020202020202, 2.4040404040404, 3, 3.60606060606061, 4.80808080808081, 6.01010101010101, 7, 7.21212121212121, 8.41414141414141, 9.61616161616162, 10.8181818181818, 12.020202020202, 13.2222222222222, 14, 14.4242424242424, 15.6262626262626, 16.8282828282828, 18.030303030303, 19.2323232323232, 20.4343434343434, 21.6363636363636, 22.8383838383838, 24.040404040404, 25.2424242424242, 26.4444444444444, 27.6464646464646, 28, 28.8484848484848, 30.050505050505, 31.2525252525253, 32.4545454545455, 33.6565656565657, 34.8585858585859, 36.0606060606061, 37.2626262626263, 38.4646464646465, 39.6666666666667, 40.8686868686869, 42.0707070707071, 43.2727272727273, 44.4747474747475, 45.6767676767677, 46.8787878787879, 48.0808080808081, 49.2828282828283, 50.4848484848485, 51.6868686868687, 52.8888888888889, 54.0909090909091, 55.2929292929293, 56.4949494949495, 57.6969696969697, 58.8989898989899, 60.1010101010101, 61.3030303030303, 62.5050505050505, 63, 63.7070707070707, 64.9090909090909, 66.1111111111111, 67.3131313131313, 68.5151515151515, 69.7171717171717, 70.9191919191919, 72.1212121212121, 73.3232323232323, 74.5252525252525, 75.7272727272727, 76.9292929292929, 78.1313131313131, 79.3333333333333, 80.5353535353535, 81.7373737373737, 82.9393939393939, 84.1414141414141, 85.3434343434343, 86.5454545454545, 87.7474747474747, 88.9494949494949, 90.1515151515152, 91, 91.3535353535353, 92.5555555555556, 93.7575757575758, 94.959595959596, 96.1616161616162, 97.3636363636364, 98.5656565656566, 99.7676767676768, 100.969696969697, 102.171717171717, 103.373737373737, 104.575757575758, 105.777777777778, 106.979797979798, 108.181818181818, 109.383838383838, 110.585858585859, 111.787878787879, 112.989898989899, 114.191919191919, 115.393939393939, 116.59595959596, 117.79797979798, 119), parent.0 = c(parent = 85.1), alpha = 1, beta = 10): unbenutztes Argument (parent.0 = 85.1)
#> Timing stopped at: 0 0 0.001
summary(fit)
#> Error in summary(fit): Objekt 'fit' nicht gefunden
+fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) +summary(fit)
#> mkin version used for fitting: 0.9.50 +#> R version used for fitting: 4.0.0 +#> Date of fit: Mon May 11 05:14:26 2020 +#> Date of summary: Mon May 11 05:14:26 2020 +#> +#> Equations: +#> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 222 model solutions performed in 0.043 s +#> +#> Error model: Constant variance +#> +#> Error model algorithm: OLS +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 85.1 state +#> alpha 1.0 deparm +#> beta 10.0 deparm +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 85.100000 -Inf Inf +#> log_alpha 0.000000 -Inf Inf +#> log_beta 2.302585 -Inf Inf +#> +#> Fixed parameter values: +#> None +#> +#> Results: +#> +#> AIC BIC logLik +#> 44.68652 45.47542 -18.34326 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 85.87000 1.8070 81.23000 90.5200 +#> log_alpha 0.05192 0.1353 -0.29580 0.3996 +#> log_beta 0.65100 0.2287 0.06315 1.2390 +#> sigma 1.85700 0.4378 0.73200 2.9830 +#> +#> Parameter correlation: +#> parent_0 log_alpha log_beta sigma +#> parent_0 1.000e+00 -1.565e-01 -3.142e-01 4.758e-08 +#> log_alpha -1.565e-01 1.000e+00 9.564e-01 1.007e-07 +#> log_beta -3.142e-01 9.564e-01 1.000e+00 8.568e-08 +#> sigma 4.758e-08 1.007e-07 8.568e-08 1.000e+00 +#> +#> Backtransformed parameters: +#> Confidence intervals for internally transformed parameters are asymmetric. +#> t-test (unrealistically) based on the assumption of normal distribution +#> for estimators of untransformed parameters. +#> Estimate t value Pr(>t) Lower Upper +#> parent_0 85.870 47.530 3.893e-08 81.2300 90.520 +#> alpha 1.053 7.393 3.562e-04 0.7439 1.491 +#> beta 1.917 4.373 3.601e-03 1.0650 3.451 +#> sigma 1.857 4.243 4.074e-03 0.7320 2.983 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 6.657 3 6 +#> parent 6.657 3 6 +#> +#> Estimated disappearance times: +#> DT50 DT90 DT50back +#> parent 1.785 15.15 4.56 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 85.1 85.875 -0.7749 +#> 1 parent 57.9 55.191 2.7091 +#> 3 parent 29.9 31.845 -1.9452 +#> 7 parent 14.6 17.012 -2.4124 +#> 14 parent 9.7 9.241 0.4590 +#> 28 parent 6.6 4.754 1.8460 +#> 63 parent 4.0 2.102 1.8977 +#> 91 parent 3.9 1.441 2.4590 +#> 119 parent 0.6 1.092 -0.4919
# One parent compound, one metabolite, both single first order. # Use mkinsub for convenience in model formulation. Pathway to sink included per default. SFO_SFO <- mkinmod( @@ -430,86 +502,105 @@ estimators.

m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults print(system.time(fit <- mkinfit(SFO_SFO, FOCUS_2006_D, solution_type = "eigen", quiet = TRUE)))
#> Warning: Observations with value of zero were removed from the data
#> User System verstrichen -#> 1.526 0.000 1.526
parms(fit)
#> parent_0 k_parent_sink k_parent_m1 k_m1_sink sigma -#> 99.598483069 0.047920122 0.050777612 0.005260651 3.125503875
#> $ff -#> parent_sink parent_m1 m1_sink -#> 0.485524 0.514476 1.000000 +#> 0.407 0.002 0.409
parms(fit)
#> parent_0 k_parent k_m1 f_parent_to_m1 sigma +#> 99.598483222 0.098697734 0.005260651 0.514475962 3.125503875
#> $ff +#> parent_m1 parent_sink +#> 0.514476 0.485524 #> #> $distimes #> DT50 DT90 #> parent 7.022929 23.32967 -#> m1 131.760712 437.69961 +#> m1 131.760715 437.69962 #>
# \dontrun{ # deSolve is slower when no C compiler (gcc) was available during model generation print(system.time(fit.deSolve <- mkinfit(SFO_SFO, FOCUS_2006_D, - solution_type = "deSolve")))
#> Warning: Observations with value of zero were removed from the data
#> Ordinary least squares optimisation
#> Sum of squared residuals at call 1: 18915.53 -#> Sum of squared residuals at call 2: 18915.53 -#> Sum of squared residuals at call 6: 11424.02 -#> Sum of squared residuals at call 10: 11424 -#> Sum of squared residuals at call 12: 4094.396 -#> Sum of squared residuals at call 16: 4094.396 -#> Sum of squared residuals at call 19: 1340.595 -#> Sum of squared residuals at call 20: 1340.593 -#> Sum of squared residuals at call 25: 1072.239 -#> Sum of squared residuals at call 28: 1072.236 -#> Sum of squared residuals at call 30: 874.2615 -#> Sum of squared residuals at call 33: 874.2611 -#> Sum of squared residuals at call 35: 616.2375 -#> Sum of squared residuals at call 37: 616.237 -#> Sum of squared residuals at call 40: 467.4386 -#> Sum of squared residuals at call 42: 467.438 -#> Sum of squared residuals at call 46: 398.2913 -#> Sum of squared residuals at call 48: 398.2913 -#> Sum of squared residuals at call 49: 398.2912 -#> Sum of squared residuals at call 51: 395.0711 -#> Sum of squared residuals at call 54: 395.071 -#> Sum of squared residuals at call 56: 378.3298 -#> Sum of squared residuals at call 59: 378.3298 -#> Sum of squared residuals at call 62: 376.9812 -#> Sum of squared residuals at call 64: 376.9811 -#> Sum of squared residuals at call 67: 375.2085 -#> Sum of squared residuals at call 69: 375.2085 -#> Sum of squared residuals at call 70: 375.2085 -#> Sum of squared residuals at call 71: 375.2085 -#> Sum of squared residuals at call 72: 374.5723 -#> Sum of squared residuals at call 74: 374.5723 -#> Sum of squared residuals at call 77: 374.0075 -#> Sum of squared residuals at call 79: 374.0075 -#> Sum of squared residuals at call 80: 374.0075 -#> Sum of squared residuals at call 82: 373.1711 -#> Sum of squared residuals at call 84: 373.1711 -#> Sum of squared residuals at call 87: 372.6445 -#> Sum of squared residuals at call 88: 372.1614 -#> Sum of squared residuals at call 90: 372.1614 -#> Sum of squared residuals at call 91: 372.1614 -#> Sum of squared residuals at call 94: 371.6464 -#> Sum of squared residuals at call 99: 371.4299 -#> Sum of squared residuals at call 101: 371.4299 -#> Sum of squared residuals at call 104: 371.4071 -#> Sum of squared residuals at call 106: 371.4071 -#> Sum of squared residuals at call 107: 371.4071 -#> Sum of squared residuals at call 109: 371.2524 -#> Sum of squared residuals at call 113: 371.2524 -#> Sum of squared residuals at call 114: 371.2136 -#> Sum of squared residuals at call 115: 371.2136 -#> Sum of squared residuals at call 116: 371.2136 -#> Sum of squared residuals at call 119: 371.2134 -#> Sum of squared residuals at call 120: 371.2134 -#> Sum of squared residuals at call 122: 371.2134 -#> Sum of squared residuals at call 123: 371.2134 -#> Sum of squared residuals at call 125: 371.2134 -#> Sum of squared residuals at call 126: 371.2134 -#> Sum of squared residuals at call 135: 371.2134 -#> Negative log-likelihood at call 145: 97.22429
#> Optimisation successfully terminated.
#> User System verstrichen -#> 1.084 0.000 1.085
parms(fit.deSolve)
#> parent_0 k_parent_sink k_parent_m1 k_m1_sink sigma -#> 99.598483072 0.047920122 0.050777612 0.005260651 3.125503874
endpoints(fit.deSolve)
#> $ff -#> parent_sink parent_m1 m1_sink -#> 0.485524 0.514476 1.000000 + solution_type = "deSolve")))
#> Warning: Observations with value of zero were removed from the data
#> Ordinary least squares optimisation
#> Sum of squared residuals at call 1: 15156.12 +#> Sum of squared residuals at call 2: 15156.12 +#> Sum of squared residuals at call 6: 8243.645 +#> Sum of squared residuals at call 12: 6290.712 +#> Sum of squared residuals at call 13: 6290.683 +#> Sum of squared residuals at call 15: 6290.452 +#> Sum of squared residuals at call 18: 1700.749 +#> Sum of squared residuals at call 20: 1700.611 +#> Sum of squared residuals at call 24: 1190.923 +#> Sum of squared residuals at call 26: 1190.922 +#> Sum of squared residuals at call 29: 1017.417 +#> Sum of squared residuals at call 31: 1017.417 +#> Sum of squared residuals at call 33: 1017.416 +#> Sum of squared residuals at call 34: 644.0471 +#> Sum of squared residuals at call 36: 644.0469 +#> Sum of squared residuals at call 38: 644.0469 +#> Sum of squared residuals at call 39: 590.5025 +#> Sum of squared residuals at call 41: 590.5022 +#> Sum of squared residuals at call 43: 590.5016 +#> Sum of squared residuals at call 44: 543.219 +#> Sum of squared residuals at call 45: 543.2187 +#> Sum of squared residuals at call 46: 543.2186 +#> Sum of squared residuals at call 50: 391.348 +#> Sum of squared residuals at call 51: 391.3479 +#> Sum of squared residuals at call 56: 386.4789 +#> Sum of squared residuals at call 58: 386.4789 +#> Sum of squared residuals at call 60: 386.4779 +#> Sum of squared residuals at call 61: 384.0686 +#> Sum of squared residuals at call 63: 384.0686 +#> Sum of squared residuals at call 66: 382.7813 +#> Sum of squared residuals at call 68: 382.7813 +#> Sum of squared residuals at call 70: 382.7813 +#> Sum of squared residuals at call 71: 378.9273 +#> Sum of squared residuals at call 73: 378.9273 +#> Sum of squared residuals at call 75: 378.9272 +#> Sum of squared residuals at call 76: 377.4847 +#> Sum of squared residuals at call 78: 377.4846 +#> Sum of squared residuals at call 81: 375.9738 +#> Sum of squared residuals at call 83: 375.9738 +#> Sum of squared residuals at call 86: 375.3387 +#> Sum of squared residuals at call 88: 375.3387 +#> Sum of squared residuals at call 91: 374.5774 +#> Sum of squared residuals at call 93: 374.5774 +#> Sum of squared residuals at call 95: 374.5774 +#> Sum of squared residuals at call 96: 373.5433 +#> Sum of squared residuals at call 100: 373.5433 +#> Sum of squared residuals at call 102: 373.2654 +#> Sum of squared residuals at call 104: 373.2654 +#> Sum of squared residuals at call 107: 372.6841 +#> Sum of squared residuals at call 111: 372.684 +#> Sum of squared residuals at call 114: 372.6374 +#> Sum of squared residuals at call 116: 372.6374 +#> Sum of squared residuals at call 119: 372.6223 +#> Sum of squared residuals at call 121: 372.6223 +#> Sum of squared residuals at call 123: 372.6223 +#> Sum of squared residuals at call 124: 372.5903 +#> Sum of squared residuals at call 126: 372.5903 +#> Sum of squared residuals at call 129: 372.5445 +#> Sum of squared residuals at call 130: 372.4921 +#> Sum of squared residuals at call 131: 372.2377 +#> Sum of squared residuals at call 132: 371.5434 +#> Sum of squared residuals at call 134: 371.5434 +#> Sum of squared residuals at call 137: 371.2857 +#> Sum of squared residuals at call 139: 371.2857 +#> Sum of squared residuals at call 143: 371.2247 +#> Sum of squared residuals at call 144: 371.2247 +#> Sum of squared residuals at call 149: 371.2189 +#> Sum of squared residuals at call 150: 371.2145 +#> Sum of squared residuals at call 153: 371.2145 +#> Sum of squared residuals at call 155: 371.2138 +#> Sum of squared residuals at call 156: 371.2138 +#> Sum of squared residuals at call 157: 371.2138 +#> Sum of squared residuals at call 161: 371.2134 +#> Sum of squared residuals at call 162: 371.2134 +#> Sum of squared residuals at call 165: 371.2134 +#> Sum of squared residuals at call 166: 371.2134 +#> Sum of squared residuals at call 168: 371.2134 +#> Negative log-likelihood at call 178: 97.22429
#> Optimisation successfully terminated.
#> User System verstrichen +#> 0.349 0.000 0.350
parms(fit.deSolve)
#> parent_0 k_parent k_m1 f_parent_to_m1 sigma +#> 99.598480759 0.098697739 0.005260651 0.514475958 3.125503874
endpoints(fit.deSolve)
#> $ff +#> parent_m1 parent_sink +#> 0.514476 0.485524 #> #> $distimes #> DT50 DT90 -#> parent 7.022929 23.32967 -#> m1 131.760712 437.69961 +#> parent 7.022929 23.32966 +#> m1 131.760731 437.69967 #>
# } # Use stepwise fitting, using optimised parameters from parent only fit, FOMC @@ -518,31 +609,33 @@ estimators.

parent = mkinsub("FOMC", "m1"), m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
# Use starting parameters from parent only FOMC fit -fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE)
#> Error in (function (t, parent_0, alpha, beta) { parent = parent_0/(t/beta + 1)^alpha})(t = c(0, 0.757575757575758, 1, 1.51515151515152, 2.27272727272727, 3, 3.03030303030303, 3.78787878787879, 4.54545454545454, 5.3030303030303, 6.06060606060606, 6.81818181818182, 7, 7.57575757575758, 8.33333333333333, 9.09090909090909, 9.84848484848485, 10.6060606060606, 11.3636363636364, 12.1212121212121, 12.8787878787879, 13.6363636363636, 14, 14.3939393939394, 15.1515151515152, 15.9090909090909, 16.6666666666667, 17.4242424242424, 18.1818181818182, 18.9393939393939, 19.6969696969697, 20.4545454545455, 21, 21.2121212121212, 21.969696969697, 22.7272727272727, 23.4848484848485, 24.2424242424242, 25, 25.7575757575758, 26.5151515151515, 27.2727272727273, 28.030303030303, 28.7878787878788, 29.5454545454545, 30.3030303030303, 31.0606060606061, 31.8181818181818, 32.5757575757576, 33.3333333333333, 34.0909090909091, 34.8484848484849, 35, 35.6060606060606, 36.3636363636364, 37.1212121212121, 37.8787878787879, 38.6363636363636, 39.3939393939394, 40.1515151515151, 40.9090909090909, 41.6666666666667, 42.4242424242424, 43.1818181818182, 43.9393939393939, 44.6969696969697, 45.4545454545455, 46.2121212121212, 46.969696969697, 47.7272727272727, 48.4848484848485, 49.2424242424242, 50, 50.7575757575758, 51.5151515151515, 52.2727272727273, 53.030303030303, 53.7878787878788, 54.5454545454545, 55.3030303030303, 56.0606060606061, 56.8181818181818, 57.5757575757576, 58.3333333333333, 59.0909090909091, 59.8484848484849, 60.6060606060606, 61.3636363636364, 62.1212121212121, 62.8787878787879, 63.6363636363636, 64.3939393939394, 65.1515151515152, 65.9090909090909, 66.6666666666667, 67.4242424242424, 68.1818181818182, 68.9393939393939, 69.6969696969697, 70.4545454545455, 71.2121212121212, 71.969696969697, 72.7272727272727, 73.4848484848485, 74.2424242424242, 75), parent.0 = c(parent = 100.75), alpha = 1, beta = 10): unbenutztes Argument (parent.0 = 100.75)
#> Timing stopped at: 0 0 0.001
fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, - parms.ini = fit.FOMC$bparms.ode)
#> Warning: Observations with value of zero were removed from the data
#> Error in mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, parms.ini = fit.FOMC$bparms.ode): Objekt 'fit.FOMC' nicht gefunden
+fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE) +fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, + parms.ini = fit.FOMC$bparms.ode)
#> Warning: Observations with value of zero were removed from the data
# Use stepwise fitting, using optimised parameters from parent only fit, SFORB SFORB_SFO <- mkinmod( parent = list(type = "SFORB", to = "m1", sink = TRUE), m1 = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit.SFORB_SFO.deSolve <- mkinfit(SFORB_SFO, FOCUS_2006_D, solution_type = "deSolve", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
# Use starting parameters from parent only SFORB fit (not really needed in this case) -fit.SFORB = mkinfit("SFORB", FOCUS_2006_D, quiet = TRUE)
#> Error in (function (t, parent_0, k_12, k_21, k_1output) { sqrt_exp = sqrt(1/4 * (k_12 + k_21 + k_1output)^2 + k_12 * k_21 - (k_12 + k_1output) * k_21) b1 = 0.5 * (k_12 + k_21 + k_1output) + sqrt_exp b2 = 0.5 * (k_12 + k_21 + k_1output) - sqrt_exp parent = parent_0 * (((k_12 + k_21 - b1)/(b2 - b1)) * exp(-b1 * t) + ((k_12 + k_21 - b2)/(b1 - b2)) * exp(-b2 * t))})(t = c(0, 0.757575757575758, 1, 1.51515151515152, 2.27272727272727, 3, 3.03030303030303, 3.78787878787879, 4.54545454545454, 5.3030303030303, 6.06060606060606, 6.81818181818182, 7, 7.57575757575758, 8.33333333333333, 9.09090909090909, 9.84848484848485, 10.6060606060606, 11.3636363636364, 12.1212121212121, 12.8787878787879, 13.6363636363636, 14, 14.3939393939394, 15.1515151515152, 15.9090909090909, 16.6666666666667, 17.4242424242424, 18.1818181818182, 18.9393939393939, 19.6969696969697, 20.4545454545455, 21, 21.2121212121212, 21.969696969697, 22.7272727272727, 23.4848484848485, 24.2424242424242, 25, 25.7575757575758, 26.5151515151515, 27.2727272727273, 28.030303030303, 28.7878787878788, 29.5454545454545, 30.3030303030303, 31.0606060606061, 31.8181818181818, 32.5757575757576, 33.3333333333333, 34.0909090909091, 34.8484848484849, 35, 35.6060606060606, 36.3636363636364, 37.1212121212121, 37.8787878787879, 38.6363636363636, 39.3939393939394, 40.1515151515151, 40.9090909090909, 41.6666666666667, 42.4242424242424, 43.1818181818182, 43.9393939393939, 44.6969696969697, 45.4545454545455, 46.2121212121212, 46.969696969697, 47.7272727272727, 48.4848484848485, 49.2424242424242, 50, 50.7575757575758, 51.5151515151515, 52.2727272727273, 53.030303030303, 53.7878787878788, 54.5454545454545, 55.3030303030303, 56.0606060606061, 56.8181818181818, 57.5757575757576, 58.3333333333333, 59.0909090909091, 59.8484848484849, 60.6060606060606, 61.3636363636364, 62.1212121212121, 62.8787878787879, 63.6363636363636, 64.3939393939394, 65.1515151515152, 65.9090909090909, 66.6666666666667, 67.4242424242424, 68.1818181818182, 68.9393939393939, 69.6969696969697, 70.4545454545455, 71.2121212121212, 71.969696969697, 72.7272727272727, 73.4848484848485, 74.2424242424242, 75), parent.0 = c(parent_free = 100.75), k_1output = 0.1, k_12 = 0.1, k_21 = 0.02): unbenutztes Argument (parent.0 = 100.75)
#> Timing stopped at: 0.001 0 0.001
fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
#> Error in mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE): Objekt 'fit.SFORB' nicht gefunden
# } +fit.SFORB = mkinfit("SFORB", FOCUS_2006_D, quiet = TRUE) +fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
#> Warning: Initial parameter(s) k_parent_free_sink not used in the model
# } # \dontrun{ # Weighted fits, including IRLS SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
f.noweight <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.noweight)
#> mkin version used for fitting: 0.9.49.11 + m1 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
f.noweight <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.noweight)
#> mkin version used for fitting: 0.9.50 #> R version used for fitting: 4.0.0 -#> Date of fit: Thu May 7 08:59:03 2020 -#> Date of summary: Thu May 7 08:59:03 2020 +#> Date of fit: Mon May 11 05:14:31 2020 +#> Date of summary: Mon May 11 05:14:31 2020 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> -#> Model predictions using solution type deSolve +#> Model predictions using solution type analytical #> -#> Fitted using 422 model solutions performed in 1.106 s +#> Fitted using 421 model solutions performed in 0.124 s #> #> Error model: Constant variance #> @@ -566,6 +659,11 @@ estimators.

#> value type #> m1_0 0 state #> +#> Results: +#> +#> AIC BIC logLik +#> 204.4486 212.6365 -97.22429 +#> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.60000 1.57000 96.40000 102.8000 @@ -576,11 +674,11 @@ estimators.

#> #> Parameter correlation: #> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 sigma -#> parent_0 1.000e+00 5.174e-01 -1.688e-01 -5.471e-01 -2.443e-07 -#> log_k_parent 5.174e-01 1.000e+00 -3.263e-01 -5.426e-01 3.181e-07 -#> log_k_m1 -1.688e-01 -3.263e-01 1.000e+00 7.478e-01 -1.369e-07 -#> f_parent_ilr_1 -5.471e-01 -5.426e-01 7.478e-01 1.000e+00 -2.287e-08 -#> sigma -2.443e-07 3.181e-07 -1.369e-07 -2.287e-08 1.000e+00 +#> parent_0 1.000e+00 5.174e-01 -1.688e-01 -5.471e-01 -3.214e-07 +#> log_k_parent 5.174e-01 1.000e+00 -3.263e-01 -5.426e-01 3.168e-07 +#> log_k_m1 -1.688e-01 -3.263e-01 1.000e+00 7.478e-01 -1.410e-07 +#> f_parent_ilr_1 -5.471e-01 -5.426e-01 7.478e-01 1.000e+00 5.093e-10 +#> sigma -3.214e-07 3.168e-07 -1.410e-07 5.093e-10 1.000e+00 #> #> Backtransformed parameters: #> Confidence intervals for internally transformed parameters are asymmetric. @@ -648,18 +746,18 @@ estimators.

#> 100 m1 31.04 31.98163 -9.416e-01 #> 100 m1 33.13 31.98163 1.148e+00 #> 120 m1 25.15 28.78984 -3.640e+00 -#> 120 m1 33.31 28.78984 4.520e+00
f.obs <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "obs", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.obs)
#> mkin version used for fitting: 0.9.49.11 +#> 120 m1 33.31 28.78984 4.520e+00
f.obs <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "obs", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.obs)
#> mkin version used for fitting: 0.9.50 #> R version used for fitting: 4.0.0 -#> Date of fit: Thu May 7 08:59:06 2020 -#> Date of summary: Thu May 7 08:59:06 2020 +#> Date of fit: Mon May 11 05:14:32 2020 +#> Date of summary: Mon May 11 05:14:32 2020 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> -#> Model predictions using solution type deSolve +#> Model predictions using solution type analytical #> -#> Fitted using 979 model solutions performed in 2.604 s +#> Fitted using 978 model solutions performed in 0.336 s #> #> Error model: Variance unique to each observed variable #> @@ -688,6 +786,11 @@ estimators.

#> value type #> m1_0 0 state #> +#> Results: +#> +#> AIC BIC logLik +#> 205.8727 215.6982 -96.93634 +#> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 99.65000 1.70200 96.19000 103.1000 @@ -780,23 +883,23 @@ estimators.

#> 100 m1 31.04 31.98773 -9.477e-01 #> 100 m1 33.13 31.98773 1.142e+00 #> 120 m1 25.15 28.80429 -3.654e+00 -#> 120 m1 33.31 28.80429 4.506e+00
f.tc <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "tc", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.tc)
#> mkin version used for fitting: 0.9.49.11 +#> 120 m1 33.31 28.80429 4.506e+00
f.tc <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "tc", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.tc)
#> mkin version used for fitting: 0.9.50 #> R version used for fitting: 4.0.0 -#> Date of fit: Thu May 7 08:59:16 2020 -#> Date of summary: Thu May 7 08:59:16 2020 +#> Date of fit: Mon May 11 05:14:32 2020 +#> Date of summary: Mon May 11 05:14:32 2020 #> #> Equations: #> d_parent/dt = - k_parent * parent #> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 #> -#> Model predictions using solution type deSolve +#> Model predictions using solution type analytical #> -#> Fitted using 2552 model solutions performed in 10.544 s +#> Fitted using 1875 model solutions performed in 0.642 s #> #> Error model: Two-component variance function #> #> Error model algorithm: d_3 -#> Three-step fitting yielded a higher likelihood than direct fitting +#> Direct fitting and three-step fitting yield approximately the same likelihood #> #> Starting values for parameters to be optimised: #> value type @@ -820,6 +923,11 @@ estimators.

#> value type #> m1_0 0 state #> +#> Results: +#> +#> AIC BIC logLik +#> 141.9656 151.7911 -64.98278 +#> #> Optimised, transformed parameters with symmetric confidence intervals: #> Estimate Std. Error Lower Upper #> parent_0 100.70000 2.621000 95.400000 106.10000 @@ -868,14 +976,14 @@ estimators.

#> #> Data: #> time variable observed predicted residual -#> 0 parent 99.46 100.73434 -1.274339 -#> 0 parent 102.04 100.73434 1.305661 +#> 0 parent 99.46 100.73434 -1.274340 +#> 0 parent 102.04 100.73434 1.305660 #> 1 parent 93.50 91.09751 2.402486 #> 1 parent 92.50 91.09751 1.402486 #> 3 parent 63.23 74.50141 -11.271410 #> 3 parent 68.99 74.50141 -5.511410 -#> 7 parent 52.32 49.82880 2.491201 -#> 7 parent 55.13 49.82880 5.301201 +#> 7 parent 52.32 49.82880 2.491200 +#> 7 parent 55.13 49.82880 5.301200 #> 14 parent 27.27 24.64809 2.621908 #> 14 parent 26.64 24.64809 1.991908 #> 21 parent 11.50 12.19232 -0.692315 @@ -902,8 +1010,8 @@ estimators.

#> 50 m1 40.01 41.34199 -1.331985 #> 75 m1 40.09 36.61471 3.475295 #> 75 m1 33.85 36.61471 -2.764705 -#> 100 m1 31.04 32.20082 -1.160824 -#> 100 m1 33.13 32.20082 0.929176 +#> 100 m1 31.04 32.20082 -1.160823 +#> 100 m1 33.13 32.20082 0.929177 #> 120 m1 25.15 29.04130 -3.891304 #> 120 m1 33.31 29.04130 4.268696
# } diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index 2f2e89d9..81b62ae1 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -237,7 +237,7 @@ in the FOCUS and NAFTA guidance documents are used.

Examples

# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) -SFO <- mkinmod(parent = list(type = "SFO")) +SFO <- mkinmod(parent = mkinsub("SFO")) # One parent compound, one metabolite, both single first order SFO_SFO <- mkinmod( @@ -252,7 +252,7 @@ in the FOCUS and NAFTA guidance documents are used.

SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), verbose = TRUE)
#> Compilation argument: -#> /usr/lib/R/bin/R CMD SHLIB fileb6a4eaab60.c 2> fileb6a4eaab60.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB file1a1abf38df.c 2> file1a1abf38df.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 21c13156..e48a0cdb 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -251,7 +251,8 @@ is 1e-10, much lower than in lsoda.

map_output

Boolean to specify if the output should list values for the observed variables (default) or for all state variables (if set to -FALSE).

+FALSE). Setting this to FALSE has no effect for analytical solutions, +as these always return mapped output.

... @@ -262,7 +263,7 @@ solver is used.

Value

-

A matrix in the same format as the output of ode.

+

A matrix with the numeric solution in wide format

Examples

@@ -270,149 +271,147 @@ solver is used.

# Compare solution types mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical")
#> time degradinol -#> 1 0 100.0000000 -#> 2 1 74.0818221 -#> 3 2 54.8811636 -#> 4 3 40.6569660 -#> 5 4 30.1194212 -#> 6 5 22.3130160 -#> 7 6 16.5298888 -#> 8 7 12.2456428 -#> 9 8 9.0717953 -#> 10 9 6.7205513 -#> 11 10 4.9787068 -#> 12 11 3.6883167 -#> 13 12 2.7323722 -#> 14 13 2.0241911 -#> 15 14 1.4995577 -#> 16 15 1.1108997 -#> 17 16 0.8229747 -#> 18 17 0.6096747 -#> 19 18 0.4516581 -#> 20 19 0.3345965 -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108997 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve")
#> time degradinol -#> 1 0 100.0000000 -#> 2 1 74.0818221 -#> 3 2 54.8811636 -#> 4 3 40.6569660 -#> 5 4 30.1194212 -#> 6 5 22.3130160 -#> 7 6 16.5298888 -#> 8 7 12.2456428 -#> 9 8 9.0717953 -#> 10 9 6.7205513 -#> 11 10 4.9787068 -#> 12 11 3.6883167 -#> 13 12 2.7323722 -#> 14 13 2.0241911 -#> 15 14 1.4995577 -#> 16 15 1.1108996 -#> 17 16 0.8229747 -#> 18 17 0.6096747 -#> 19 18 0.4516581 -#> 20 19 0.3345965 -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108996 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE)
#> time degradinol -#> 1 0 100.0000000 -#> 2 1 74.0818221 -#> 3 2 54.8811636 -#> 4 3 40.6569660 -#> 5 4 30.1194212 -#> 6 5 22.3130160 -#> 7 6 16.5298888 -#> 8 7 12.2456428 -#> 9 8 9.0717953 -#> 10 9 6.7205513 -#> 11 10 4.9787068 -#> 12 11 3.6883167 -#> 13 12 2.7323722 -#> 14 13 2.0241911 -#> 15 14 1.4995577 -#> 16 15 1.1108996 -#> 17 16 0.8229747 -#> 18 17 0.6096747 -#> 19 18 0.4516581 -#> 20 19 0.3345965 -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108996 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, solution_type = "eigen")
#> time degradinol -#> 1 0 100.0000000 -#> 2 1 74.0818221 -#> 3 2 54.8811636 -#> 4 3 40.6569660 -#> 5 4 30.1194212 -#> 6 5 22.3130160 -#> 7 6 16.5298888 -#> 8 7 12.2456428 -#> 9 8 9.0717953 -#> 10 9 6.7205513 -#> 11 10 4.9787068 -#> 12 11 3.6883167 -#> 13 12 2.7323722 -#> 14 13 2.0241911 -#> 15 14 1.4995577 -#> 16 15 1.1108997 -#> 17 16 0.8229747 -#> 18 17 0.6096747 -#> 19 18 0.4516581 -#> 20 19 0.3345965 -#> 21 20 0.2478752
+#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108997 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
# Compare integration methods to analytical solution mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, - solution_type = "analytical")[21,]
#> time degradinol -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, - method = "lsoda")[21,]
#> time degradinol -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, - method = "ode45")[21,]
#> time degradinol -#> 21 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, - method = "rk4")[21,]
#> time degradinol -#> 21 20 0.2480043
# rk4 is not as precise here + solution_type = "analytical")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "lsoda")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "ode45")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "rk4")[21,]
#> time degradinol +#> 20.0000000 0.2480043
# rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), - seq(0, 20, by = 0.1))[201,]
#> time degradinol -#> 201 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), - seq(0, 20, by = 0.01))[2001,]
#> time degradinol -#> 2001 20 0.2478752
-# Check compiled model versions - they are faster than the eigenvalue based solutions! + seq(0, 20, by = 0.1))[201,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), + seq(0, 20, by = 0.01))[2001,]
#> time degradinol +#> 20.0000000 0.2478752
+# Comparison of the performance of solution types SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"), use_of_ff = "min")
#> Successfully compiled differential equation model from auto-generated C code.
if(require(rbenchmark)) { - benchmark( - eigen = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), + m1 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
if(require(rbenchmark)) { + benchmark(replications = 10, order = "relative", columns = c("test", "relative", "elapsed"), + eigen = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "eigen")[201,], deSolve_compiled = mkinpredict(SFO_SFO, - c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve")[201,], - deSolve = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), - c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), - solution_type = "deSolve", use_compiled = FALSE)[201,], - replications = 10) -}
#> Lade nötiges Paket: rbenchmark
#> test replications elapsed relative user.self sys.self user.child -#> 3 deSolve 10 0.229 28.625 0.229 0 0 -#> 2 deSolve_compiled 10 0.008 1.000 0.008 0 0 -#> 1 eigen 10 0.026 3.250 0.025 0 0 -#> sys.child -#> 3 0 -#> 2 0 -#> 1 0
-# Since mkin 0.9.49.11 we also have analytical solutions for some models, including SFO-SFO -# deSolve = mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), -# c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), -# solution_type = "analytical", use_compiled = FALSE)[201,], - + deSolve = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "deSolve", use_compiled = FALSE)[201,], + analytical = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "analytical", use_compiled = FALSE)[201,]) +}
#> test relative elapsed +#> 4 analytical 1.00 0.004 +#> 2 deSolve_compiled 1.25 0.005 +#> 1 eigen 5.00 0.020 +#> 3 deSolve 54.25 0.217
# \dontrun{ # Predict from a fitted model f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE) - head(mkinpredict(f))
#> time parent m1 -#> 1 0.0 82.49216 0.000000 -#> 2 0.1 80.00563 1.179963 -#> 3 0.2 77.59404 2.312596 -#> 4 0.3 75.25515 3.399443 -#> 5 0.4 72.98675 4.442000 -#> 6 0.5 70.78673 5.441717
# } + f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE, solution_type = "deSolve") + head(mkinpredict(f))
#> time parent m1 +#> 0 0.0 82.49216 0.000000 +#> 0.1 0.1 80.00562 1.236198 +#> 0.2 0.2 77.59404 2.422818 +#> 0.3 0.3 75.25514 3.561476 +#> 0.4 0.4 72.98675 4.653740 +#> 0.5 0.5 70.78673 5.701130
# }
diff --git a/docs/reference/plot.mkinfit-1.png b/docs/reference/plot.mkinfit-1.png index 0fe3c263..c6a415d7 100644 Binary files a/docs/reference/plot.mkinfit-1.png and b/docs/reference/plot.mkinfit-1.png differ diff --git a/docs/reference/plot.mkinfit-2.png b/docs/reference/plot.mkinfit-2.png index 72bc331e..5dd3731e 100644 Binary files a/docs/reference/plot.mkinfit-2.png and b/docs/reference/plot.mkinfit-2.png differ diff --git a/docs/reference/plot.mkinfit-3.png b/docs/reference/plot.mkinfit-3.png index 6910ae47..59cf8f8d 100644 Binary files a/docs/reference/plot.mkinfit-3.png and b/docs/reference/plot.mkinfit-3.png differ diff --git a/docs/reference/plot.mkinfit-4.png b/docs/reference/plot.mkinfit-4.png index 8d399598..d9867952 100644 Binary files a/docs/reference/plot.mkinfit-4.png and b/docs/reference/plot.mkinfit-4.png differ diff --git a/docs/reference/plot.mkinfit-5.png b/docs/reference/plot.mkinfit-5.png index 20f30221..1109c8df 100644 Binary files a/docs/reference/plot.mkinfit-5.png and b/docs/reference/plot.mkinfit-5.png differ diff --git a/docs/reference/plot.mkinfit-6.png b/docs/reference/plot.mkinfit-6.png index 0b3769ce..230c90e9 100644 Binary files a/docs/reference/plot.mkinfit-6.png and b/docs/reference/plot.mkinfit-6.png differ diff --git a/docs/reference/plot.mkinfit-7.png b/docs/reference/plot.mkinfit-7.png index ad2ffa8c..b23427b5 100644 Binary files a/docs/reference/plot.mkinfit-7.png and b/docs/reference/plot.mkinfit-7.png differ diff --git a/docs/reference/plot.mkinfit.html b/docs/reference/plot.mkinfit.html index 33dc52b7..2ede2dec 100644 --- a/docs/reference/plot.mkinfit.html +++ b/docs/reference/plot.mkinfit.html @@ -10,23 +10,27 @@ - + - + - + + + + + - - + + - + - - + + @@ -39,7 +43,6 @@ - @@ -57,7 +60,7 @@ observed data together with the solution of the fitted model." /> - +
@@ -115,7 +118,12 @@ observed data together with the solution of the fitted model." />
@@ -130,7 +138,7 @@ observed data together with the solution of the fitted model." />
@@ -141,7 +149,7 @@ observed data together with the solution of the fitted model.

# S3 method for mkinfit
-plot(
+plot(
   x,
   fit = x,
   obs_vars = names(fit$mkinmod$map),
@@ -303,7 +311,7 @@ chi2 error percentage.

... -

Further arguments passed to plot.

+

Further arguments passed to plot.

standardized @@ -327,29 +335,22 @@ latex is being used for the formatting of the chi2 error level, if # parent to sink included # \dontrun{ SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"), - m1 = mkinsub("SFO", full = "Metabolite M1" ))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
#> Warning: Observations with value of zero were removed from the data
plot(fit)
plot_res(fit)
plot_res(fit, standardized = FALSE)
plot_err(fit)
+ m1 = mkinsub("SFO", full = "Metabolite M1" ))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
#> Warning: Observations with value of zero were removed from the data
plot(fit)
plot_res(fit)
plot_res(fit, standardized = FALSE)
plot_err(fit)
# Show the observed variables separately, with residuals -plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"), +plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"), show_errmin = TRUE)
# The same can be obtained with less typing, using the convenience function plot_sep plot_sep(fit, lpos = c("topright", "bottomright"))
# Show the observed variables separately, with the error model -plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"), +plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"), show_errmin = TRUE)
# }
- @@ -360,7 +361,7 @@ latex is being used for the formatting of the chi2 error level, if
-

Site built with pkgdown 1.4.1.

+

Site built with pkgdown 1.5.1.

-- cgit v1.2.1