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. --- vignettes/FOCUS_D.html | 114 ++++++++++++++++++------------------- vignettes/mkin.html | 112 +++++++++++++++++++----------------- vignettes/mkin_benchmarks.rda | Bin 871 -> 882 bytes vignettes/web_only/benchmarks.html | 22 +++---- 4 files changed, 128 insertions(+), 120 deletions(-) (limited to 'vignettes') diff --git a/vignettes/FOCUS_D.html b/vignettes/FOCUS_D.html index ff9d4596..38c597b0 100644 --- a/vignettes/FOCUS_D.html +++ b/vignettes/FOCUS_D.html @@ -11,7 +11,7 @@ - + Example evaluation of FOCUS Example Dataset D @@ -365,7 +365,7 @@ summary {

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

2020-05-06

+

2020-05-11

@@ -423,101 +423,99 @@ print(FOCUS_2006_D)
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
 ## of zero were removed from the data

A plot of the fit including a residual plot for both observed variables is obtained using the plot_sep method for mkinfit objects, which shows separate graphs for all compounds and their residuals.

plot_sep(fit, lpos = c("topright", "bottomright"))
-

+

Confidence intervals for the parameter estimates are obtained using the mkinparplot function.

mkinparplot(fit)
-

+

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:     Wed May  6 19:54:54 2020 
-## Date of summary: Wed May  6 19:54:54 2020 
+## Date of fit:     Mon May 11 04:41:12 2020 
+## Date of summary: Mon May 11 04:41:12 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.041 s
+## Fitted using 421 model solutions performed in 0.149 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
@@ -530,10 +528,10 @@ print(FOCUS_2006_D)
## 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 @@ -543,7 +541,7 @@ print(FOCUS_2006_D)
## 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/vignettes/mkin.html b/vignettes/mkin.html index 8786aa05..2ba360f4 100644 --- a/vignettes/mkin.html +++ b/vignettes/mkin.html @@ -1,17 +1,17 @@ - + - + - + Introduction to mkin @@ -1288,7 +1288,7 @@ window.initializeCodeFolding = function(show) { // create a collapsable div to wrap the code in var div = $('
'); - if (show) + if (show || $(this)[0].classList.contains('fold-show')) div.addClass('in'); var id = 'rcode-643E0F36' + currentIndex++; div.attr('id', id); @@ -1404,7 +1404,6 @@ code { } img { max-width:100%; - height: auto; } .tabbed-pane { padding-top: 12px; @@ -1466,6 +1465,7 @@ summary { border: none; display: inline-block; border-radius: 4px; + background-color: transparent; } .tabset-dropdown > .nav-tabs.nav-tabs-open > li { @@ -1478,56 +1478,12 @@ summary { } - - - - - - -