From 3f6ce570824616f5be0d6289ed65910d455dd266 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Thu, 17 Nov 2016 22:56:30 +0100 Subject: Rebuild --- README.html | 8 +++--- build.log | 1 - test.log | 23 ++++++++------- vignettes/FOCUS_L.html | 64 ++++++++++++++++++++--------------------- vignettes/FOCUS_Z.pdf | Bin 239558 -> 239558 bytes vignettes/compiled_models.html | 51 ++++++++++++++++---------------- vignettes/mkin.html | 10 +++---- 7 files changed, 80 insertions(+), 77 deletions(-) diff --git a/README.html b/README.html index ef650bdc..7afc8e5a 100644 --- a/README.html +++ b/README.html @@ -121,11 +121,11 @@ $(document).ready(function () {

mkin

-

+

The R package mkin provides calculation routines for the analysis of chemical degradation data, including multicompartment kinetics as needed for modelling the formation and decline of transformation products, or if several compartments are involved.

Installation

-

You can install the latest released version from CRAN from within R:

+

You can install the latest released version from CRAN from within R:

install.packages("mkin")
@@ -170,10 +170,10 @@ $(document).ready(function () {

mkin would not be possible without the underlying software stack consisting of R and the packages deSolve and FME, to say the least.

It could not have been written without me being introduced to regulatory fate modelling of pesticides by Adrian Gurney during my time at Harlan Laboratories Ltd (formerly RCC Ltd). mkin greatly profits from and largely follows the work done by the FOCUS Degradation Kinetics Workgroup, as detailed in their guidance document from 2006, slightly updated in 2011 and in 2014.

Also, it was inspired by the first version of KinGUI developed by BayerCropScience, which is based on the MatLab runtime environment.

-

The companion package kinfit (now deprecated) was started in 2008 and first published on CRAN on 01 May 2010.

+

The companion package kinfit (now deprecated) was started in 2008 and first published on CRAN on 01 May 2010.

The first mkin code was published on 11 May 2010 and the first CRAN version on 18 May 2010.

In 2011, Bayer Crop Science started to distribute an R based successor to KinGUI named KinGUII whose R code is based on mkin, but which added, amongst other refinements, a closed source graphical user interface (GUI), iteratively reweighted least squares (IRLS) optimisation of the variance for each of the observed variables, and Markov Chain Monte Carlo (MCMC) simulation functionality, similar to what is available e.g. in the FME package.

-

Somewhat in parallel, Syngenta has sponsored the development of an mkin and KinGUII based GUI application called CAKE, which also adds IRLS and MCMC, is more limited in the model formulation, but puts more weight on usability. CAKE is available for download from the CAKE website, where you can also find a zip archive of the R scripts derived from mkin, published under the GPL license.

+

Somewhat in parallel, Syngenta has sponsored the development of an mkin and KinGUII based GUI application called CAKE, which also adds IRLS and MCMC, is more limited in the model formulation, but puts more weight on usability. CAKE is available for download from the CAKE website, where you can also find a zip archive of the R scripts derived from mkin, published under the GPL license.

Finally, there is KineticEval, which contains a further development of the scripts used for KinGUII, so the different tools will hopefully be able to learn from each other in the future as well.

diff --git a/build.log b/build.log index fcbd6702..9798dc00 100644 --- a/build.log +++ b/build.log @@ -5,7 +5,6 @@ * creating vignettes ... OK * checking for LF line-endings in source and make files * checking for empty or unneeded directories -Removed empty directory ‘mkin/docs/icons’ * looking to see if a ‘data/datalist’ file should be added * building ‘mkin_0.9.44.9000.tar.gz’ diff --git a/test.log b/test.log index 6276c633..436b9663 100644 --- a/test.log +++ b/test.log @@ -1,18 +1,21 @@ Loading mkin Loading required package: testthat -Loading required package: methods Loading required package: minpack.lm Loading required package: rootSolve Loading required package: inline +Loading required package: methods Loading required package: parallel Testing mkin -Calculation of FOCUS chi2 error levels : .. -Results for FOCUS D established in expertise for UBA (Ranke 2014) : ...... -The t-test for significant difference from zero : .. -Fitting the FOMC model with large parameter correlation : S -Model predictions with mkinpredict : ... -Fitting of parent only models : ..................... -Complex test case from Schaefer et al. (2007) Piacenza paper : .. -Results for synthetic data established in expertise for UBA (Ranke 2014) : .... +Calculation of FOCUS chi2 error levels: .. +Results for FOCUS D established in expertise for UBA (Ranke 2014): ...... +The t-test for significant difference from zero: .. +Fitting the FOMC model with large parameter correlation: S +Model predictions with mkinpredict: ... +Fitting of parent only models: ..................... +Complex test case from Schaefer et al. (2007) Piacenza paper: .. +Results for synthetic data established in expertise for UBA (Ranke 2014): .... + +Skipped ------------------------------------------------------------------------ +1. Fitting with large parameter correlation gives warnings (@test_FOMC_ill-defined.R#30) - Skip test for warnings triggered by large parameter correlation as it failed on r-forge -DONE +DONE =========================================================================== diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html index bcdee8df..0d96fd5f 100644 --- a/vignettes/FOCUS_L.html +++ b/vignettes/FOCUS_L.html @@ -244,15 +244,15 @@ FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1) summary(m.L1.SFO)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:04 2016 
-## Date of summary: Thu Nov 17 17:46:04 2016 
+## Date of fit:     Thu Nov 17 18:44:25 2016 
+## Date of summary: Thu Nov 17 18:44:25 2016 
 ## 
 ## Equations:
-## d_parent = - k_parent_sink * parent
+## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.093 s
+## Fitted with method Port using 37 model solutions performed in 0.088 s
 ## 
 ## Weighting: none
 ## 
@@ -337,8 +337,8 @@ summary(m.L1.SFO)
summary(m.L1.FOMC, data = FALSE)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:05 2016 
-## Date of summary: Thu Nov 17 17:46:05 2016 
+## Date of fit:     Thu Nov 17 18:44:26 2016 
+## Date of summary: Thu Nov 17 18:44:26 2016 
 ## 
 ## 
 ## Warning: Optimisation by method Port did not converge.
@@ -346,11 +346,11 @@ summary(m.L1.SFO)
## ## ## Equations: -## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent +## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent ## ## Model predictions using solution type analytical ## -## Fitted with method Port using 188 model solutions performed in 0.456 s +## Fitted with method Port using 188 model solutions performed in 0.431 s ## ## Weighting: none ## @@ -434,15 +434,15 @@ plot(m.L2.FOMC, show_residuals = TRUE,
summary(m.L2.FOMC, data = FALSE)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:06 2016 
-## Date of summary: Thu Nov 17 17:46:06 2016 
+## Date of fit:     Thu Nov 17 18:44:26 2016 
+## Date of summary: Thu Nov 17 18:44:26 2016 
 ## 
 ## Equations:
-## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
+## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.227 s
+## Fitted with method Port using 81 model solutions performed in 0.18 s
 ## 
 ## Weighting: none
 ## 
@@ -504,17 +504,17 @@ plot(m.L2.DFOP, show_residuals = TRUE, show_errmin = TRUE,
 
summary(m.L2.DFOP, data = FALSE)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:07 2016 
-## Date of summary: Thu Nov 17 17:46:07 2016 
+## Date of fit:     Thu Nov 17 18:44:27 2016 
+## Date of summary: Thu Nov 17 18:44:27 2016 
 ## 
 ## Equations:
-## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
-##            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 *
-##            time))) * parent
+## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
+##            exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+##            exp(-k2 * time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 336 model solutions performed in 0.935 s
+## Fitted with method Port using 336 model solutions performed in 0.768 s
 ## 
 ## Weighting: none
 ## 
@@ -593,17 +593,17 @@ plot(mm.L3)
summary(mm.L3[["DFOP", 1]])
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:08 2016 
-## Date of summary: Thu Nov 17 17:46:08 2016 
+## Date of fit:     Thu Nov 17 18:44:28 2016 
+## Date of summary: Thu Nov 17 18:44:28 2016 
 ## 
 ## Equations:
-## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
-##            time)) / (g * exp(-k1 * time) + (1 - g) * exp(-k2 *
-##            time))) * parent
+## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
+##            exp(-k2 * time)) / (g * exp(-k1 * time) + (1 - g) *
+##            exp(-k2 * time))) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 137 model solutions performed in 0.332 s
+## Fitted with method Port using 137 model solutions performed in 0.313 s
 ## 
 ## Weighting: none
 ## 
@@ -693,15 +693,15 @@ plot(mm.L4)
summary(mm.L4[["SFO", 1]], data = FALSE)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:08 2016 
-## Date of summary: Thu Nov 17 17:46:08 2016 
+## Date of fit:     Thu Nov 17 18:44:28 2016 
+## Date of summary: Thu Nov 17 18:44:29 2016 
 ## 
 ## Equations:
-## d_parent = - k_parent_sink * parent
+## d_parent/dt = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.131 s
+## Fitted with method Port using 46 model solutions performed in 0.1 s
 ## 
 ## Weighting: none
 ## 
@@ -753,15 +753,15 @@ plot(mm.L4)
summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version:    0.9.44.9000 
 ## R version:       3.3.2 
-## Date of fit:     Thu Nov 17 17:46:08 2016 
-## Date of summary: Thu Nov 17 17:46:08 2016 
+## Date of fit:     Thu Nov 17 18:44:28 2016 
+## Date of summary: Thu Nov 17 18:44:29 2016 
 ## 
 ## Equations:
-## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
+## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.167 s
+## Fitted with method Port using 66 model solutions performed in 0.152 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf
index 6f71d018..6f8929ea 100644
Binary files a/vignettes/FOCUS_Z.pdf and b/vignettes/FOCUS_Z.pdf differ
diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html
index dc2b2ca7..2cb73ac7 100644
--- a/vignettes/compiled_models.html
+++ b/vignettes/compiled_models.html
@@ -11,7 +11,7 @@
 
 
 
-
+
 
 Performance benefit by using compiled model definitions in mkin
 
@@ -216,7 +216,7 @@ div.tocify {
 
 

Performance benefit by using compiled model definitions in mkin

Johannes Ranke

-

2016-11-04

+

2016-11-17

@@ -232,6 +232,7 @@ div.tocify {
## Loading required package: minpack.lm
## Loading required package: rootSolve
## Loading required package: inline
+
## Loading required package: methods
## Loading required package: parallel
SFO_SFO <- mkinmod(
   parent = mkinsub("SFO", "m1"),
@@ -241,12 +242,12 @@ div.tocify {
 
library("microbenchmark")
 library("ggplot2")
 mb.1 <- microbenchmark(
-  "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, 
-                                    solution_type = "deSolve", 
+  "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
+                                    solution_type = "deSolve",
                                     use_compiled = FALSE, quiet = TRUE),
-  "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_2006_D, 
+  "Eigenvalue based" = mkinfit(SFO_SFO, FOCUS_2006_D,
                                solution_type = "eigen", quiet = TRUE),
-  "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, 
+  "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
                                 solution_type = "deSolve", quiet = TRUE),
   times = 3, control = list(warmup = 0))
## Warning in microbenchmark(`deSolve, not compiled` = mkinfit(SFO_SFO,
@@ -256,21 +257,21 @@ mb.1 <- microbenchmark(
 print(mb.1)
## Unit: milliseconds
 ##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 4969.1274 5005.4703 5026.1990 5041.8132 5054.7348
-##       Eigenvalue based  841.6273  843.3144  855.0880  845.0015  861.8183
-##      deSolve, compiled  689.6154  698.2345  710.3162  706.8537  720.6666
+##  deSolve, not compiled 4925.0009 4957.6694 4974.0652 4990.3379 4998.5974
+##       Eigenvalue based  838.9741  839.6651  857.4679  840.3561  866.7149
+##      deSolve, compiled  695.5858  709.3905  717.8062  723.1951  728.9163
 ##        max neval cld
-##  5067.6564     3   c
-##   878.6352     3  b 
-##   734.4795     3 a
+## 5006.8569 3 c +## 893.0736 3 b +## 734.6375 3 a
autoplot(mb.1)
-

-

We see that using the compiled model is by a factor of 7.1 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:

+

+

We see that using the compiled model is by a factor of 6.9 faster than using the R version with the default ode solver, and it is even faster than the Eigenvalue based solution implemented in R which does not need iterative solution of the ODEs:

rownames(smb.1) <- smb.1$expr
 smb.1["median"]/smb.1["deSolve, compiled", "median"]
##                         median
-## deSolve, not compiled 7.132754
-## Eigenvalue based      1.195441
+## deSolve, not compiled 6.900403
+## Eigenvalue based      1.162005
 ## deSolve, compiled     1.000000
@@ -281,7 +282,7 @@ smb.1["median"]/smb.1["deSolve, compiled", "median" m1 = mkinsub( "SFO"))
## Successfully compiled differential equation model from auto-generated C code.
mb.2 <- microbenchmark(
-  "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, 
+  "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D,
                                     use_compiled = FALSE, quiet = TRUE),
   "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
   times = 3, control = list(warmup = 0))
@@ -291,19 +292,19 @@ smb.1["median"]/smb.1["deSolve, compiled", "median"
smb.2 <- summary(mb.2)
 print(mb.2)
## Unit: seconds
-##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 10.998190 11.039105 11.133751 11.080019 11.201531
-##      deSolve, compiled  1.286159  1.286381  1.288394  1.286602  1.289511
-##       max neval cld
-##  11.32304     3   b
-##   1.29242     3  a
+## expr min lq mean median uq +## deSolve, not compiled 10.905262 11.007527 11.335389 11.109791 11.55045 +## deSolve, compiled 1.297428 1.304999 1.327356 1.312569 1.34232 +## max neval cld +## 11.991114 3 b +## 1.372071 3 a
smb.2["median"]/smb.2["deSolve, compiled", "median"]
##   median
 ## 1     NA
 ## 2     NA
autoplot(mb.2)
-

-

Here we get a performance benefit of a factor of 8.6 using the version of the differential equation model compiled from C code!

+

+

Here we get a performance benefit of a factor of 8.5 using the version of the differential equation model compiled from C code!

This vignette was built with mkin 0.9.44.9000 on

## R version 3.3.2 (2016-10-31)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
diff --git a/vignettes/mkin.html b/vignettes/mkin.html
index 172712f5..a8f7f2ba 100644
--- a/vignettes/mkin.html
+++ b/vignettes/mkin.html
@@ -246,23 +246,23 @@ div.tocify {
 # Define the kinetic model
 m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
                          M1 = mkinsub("SFO", "M2"),
-                         M2 = mkinsub("SFO"), 
+                         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, 
+  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 
+# 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, 
+                             sdfunc = function(x) 3,
                              n = 1, seed = 123456789 )
 
 # Fit the model to the dataset
-- 
cgit v1.2.1