From 70d158c4dd919f4f77bc12f8ace333d29d249b79 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 14 Sep 2018 16:57:17 +0200 Subject: Remove two vignettes from the package but not from docs - Rebuild static documentation - Adapt test to new approach to two component error model where the model is inadequate --- DESCRIPTION | 2 +- GNUmakefile | 8 +- _pkgdown.yml | 4 +- check.log | 6 +- docs/articles/FOCUS_D.html | 14 +- docs/articles/FOCUS_L.html | 62 +- docs/articles/index.html | 10 +- docs/articles/mkin.html | 6 +- docs/articles/twa.html | 6 +- docs/articles/web_only/FOCUS_Z.html | 332 ++++ .../figure-html/FOCUS_2006_Z_fits_1-1.png | Bin 0 -> 86312 bytes .../figure-html/FOCUS_2006_Z_fits_10-1.png | Bin 0 -> 129920 bytes .../figure-html/FOCUS_2006_Z_fits_11-1.png | Bin 0 -> 129452 bytes .../figure-html/FOCUS_2006_Z_fits_11a-1.png | Bin 0 -> 97933 bytes .../figure-html/FOCUS_2006_Z_fits_11b-1.png | Bin 0 -> 22321 bytes .../figure-html/FOCUS_2006_Z_fits_2-1.png | Bin 0 -> 86923 bytes .../figure-html/FOCUS_2006_Z_fits_3-1.png | Bin 0 -> 86529 bytes .../figure-html/FOCUS_2006_Z_fits_5-1.png | Bin 0 -> 102872 bytes .../figure-html/FOCUS_2006_Z_fits_6-1.png | Bin 0 -> 130096 bytes .../figure-html/FOCUS_2006_Z_fits_7-1.png | Bin 0 -> 130164 bytes .../figure-html/FOCUS_2006_Z_fits_9-1.png | Bin 0 -> 109280 bytes docs/articles/web_only/compiled_models.html | 201 +++ docs/authors.html | 6 +- docs/index.html | 6 +- docs/news/index.html | 6 +- docs/pkgdown.yml | 4 +- docs/reference/DFOP.solution.html | 6 +- docs/reference/Extract.mmkin.html | 20 +- docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html | 6 +- docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html | 6 +- docs/reference/FOCUS_2006_HS_ref_A_to_F.html | 6 +- docs/reference/FOCUS_2006_SFO_ref_A_to_F.html | 6 +- docs/reference/FOCUS_2006_datasets.html | 6 +- docs/reference/FOMC.solution.html | 6 +- docs/reference/HS.solution.html | 6 +- docs/reference/IORE.solution.html | 6 +- docs/reference/SFO.solution.html | 6 +- docs/reference/SFORB.solution.html | 6 +- docs/reference/add_err.html | 6 +- docs/reference/endpoints.html | 6 +- docs/reference/geometric_mean.html | 6 +- docs/reference/ilr.html | 6 +- docs/reference/index.html | 6 +- docs/reference/max_twa_parent.html | 6 +- docs/reference/mccall81_245T.html | 22 +- docs/reference/mkin_long_to_wide.html | 6 +- docs/reference/mkin_wide_to_long.html | 6 +- docs/reference/mkinds.html | 6 +- docs/reference/mkinerrmin.html | 6 +- docs/reference/mkinfit.html | 66 +- docs/reference/mkinmod.html | 8 +- docs/reference/mkinparplot.html | 6 +- docs/reference/mkinplot.html | 6 +- docs/reference/mkinpredict.html | 8 +- docs/reference/mkinresplot.html | 6 +- docs/reference/mkinsub.html | 6 +- docs/reference/mmkin.html | 10 +- docs/reference/plot.mkinfit.html | 6 +- docs/reference/plot.mmkin.html | 6 +- docs/reference/print.mkinds.html | 6 +- docs/reference/print.mkinmod.html | 6 +- docs/reference/schaefer07_complex_case.html | 6 +- docs/reference/sigma_twocomp.html | 6 +- docs/reference/summary.mkinfit.html | 14 +- docs/reference/synthetic_data_for_UBA.html | 6 +- docs/reference/test_data_from_UBA_2014.html | 6 +- docs/reference/transform_odeparms.html | 38 +- test.log | 18 +- tests/testthat/test_irls.R | 8 +- vignettes/FOCUS_Z.Rmd | 256 --- vignettes/FOCUS_Z.html | 474 ------ vignettes/FOCUS_Z.pdf | Bin 384032 -> 0 bytes vignettes/compiled_models.Rmd | 102 -- vignettes/compiled_models.html | 164 -- vignettes/web_only/FOCUS_Z.Rmd | 255 +++ vignettes/web_only/FOCUS_Z.html | 1786 ++++++++++++++++++++ vignettes/web_only/compiled_models.Rmd | 106 ++ vignettes/web_only/compiled_models.html | 1661 ++++++++++++++++++ 78 files changed, 4619 insertions(+), 1268 deletions(-) create mode 100644 docs/articles/web_only/FOCUS_Z.html create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png create mode 100644 docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png create mode 100644 docs/articles/web_only/compiled_models.html delete mode 100644 vignettes/FOCUS_Z.Rmd delete mode 100644 vignettes/FOCUS_Z.html delete mode 100644 vignettes/FOCUS_Z.pdf delete mode 100644 vignettes/compiled_models.Rmd delete mode 100644 vignettes/compiled_models.html create mode 100644 vignettes/web_only/FOCUS_Z.Rmd create mode 100644 vignettes/web_only/FOCUS_Z.html create mode 100644 vignettes/web_only/compiled_models.Rmd create mode 100644 vignettes/web_only/compiled_models.html diff --git a/DESCRIPTION b/DESCRIPTION index 11fb4a9d..17b873f1 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data -Version: 0.9.47.4 +Version: 0.9.47.5 Date: 2018-09-14 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", diff --git a/GNUmakefile b/GNUmakefile index be2e6675..a6f0d8c6 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -60,6 +60,7 @@ clean: $(RM) -r vignettes/*_cache $(RM) -r vignettes/*_files $(RM) -r vignettes/*.R + $(RM) -r vignettes/web_only/*.R $(RM) Rplots.pdf test: quickinstall @@ -71,7 +72,12 @@ README.html: README.md vignettes/%.html: vignettes/mkin_vignettes.css vignettes/references.bib vignettes/%.Rmd "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/$*.Rmd', dir = 'vignettes')" -vignettes: vignettes/mkin.html vignettes/FOCUS_D.html vignettes/FOCUS_L.html vignettes/FOCUS_Z.html vignettes/compiled_models.html +vignettes: vignettes/mkin.html vignettes/FOCUS_D.html vignettes/FOCUS_L.html + +vignettes/web_only/%.html: vignettes/references.bib vignettes/web_only/%.Rmd + "$(RBIN)/Rscript" -e "tools::buildVignette(file = 'vignettes/web_only/$*.Rmd', dir = 'vignettes/web_only')" + +articles: vignettes/web_only/FOCUS_Z.html vignettes/web_only/compiled_models.html pd: "$(RBIN)/Rscript" -e "pkgdown::build_site(run_dont_run = TRUE)" diff --git a/_pkgdown.yml b/_pkgdown.yml index 9cb51f5c..004e1139 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -81,9 +81,9 @@ navbar: - text: Example evaluation of FOCUS Laboratory Data L1 to L3 href: articles/FOCUS_L.html - text: Example evaluation of FOCUS Example Dataset Z - href: articles/FOCUS_Z.html + href: articles/web_only/FOCUS_Z.html - text: Performance benefit by using compiled model definitions in mkin - href: articles/compiled_models.html + href: articles/web_only/compiled_models.html - text: Calculation of time weighted average concentrations with mkin href: articles/twa.html - text: News diff --git a/check.log b/check.log index 4732c4a3..d275321e 100644 --- a/check.log +++ b/check.log @@ -1,11 +1,11 @@ * using log directory ‘/home/jranke/git/mkin/mkin.Rcheck’ -* using R Under development (unstable) (2018-09-13 r75299) +* using R version 3.5.1 (2018-07-02) * using platform: x86_64-pc-linux-gnu (64-bit) * using session charset: UTF-8 * using options ‘--no-tests --as-cran’ * checking for file ‘mkin/DESCRIPTION’ ... OK * checking extension type ... Package -* this is package ‘mkin’ version ‘0.9.47.3’ +* this is package ‘mkin’ version ‘0.9.47.4’ * package encoding: UTF-8 * checking CRAN incoming feasibility ... Note_to_CRAN_maintainers Maintainer: ‘Johannes Ranke ’ @@ -21,7 +21,6 @@ Maintainer: ‘Johannes Ranke ’ * checking whether package ‘mkin’ can be installed ... OK * checking installed package size ... OK * checking package directory ... OK -* checking for future file timestanps ... OK * checking ‘build’ directory ... OK * checking DESCRIPTION meta-information ... OK * checking top-level files ... OK @@ -54,7 +53,6 @@ Maintainer: ‘Johannes Ranke ’ * checking contents of ‘data’ directory ... OK * checking data for non-ASCII characters ... OK * checking data for ASCII and uncompressed saves ... OK -* checking sizes of PDF files under ‘inst/doc’ ... OK * checking installed files from ‘inst/doc’ ... OK * checking files in ‘vignettes’ ... OK * checking examples ... OK diff --git a/docs/articles/FOCUS_D.html b/docs/articles/FOCUS_D.html index 3ed8004e..6dde02d4 100644 --- a/docs/articles/FOCUS_D.html +++ b/docs/articles/FOCUS_D.html @@ -29,7 +29,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -55,10 +55,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -160,10 +160,10 @@

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

    -
    ## mkin version used for fitting:    0.9.47.1 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Wed Jul 18 14:52:30 2018 
    -## Date of summary: Wed Jul 18 14:52:31 2018 
    +## Date of fit:     Fri Sep 14 16:50:31 2018 
    +## Date of summary: Fri Sep 14 16:50:31 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent
    @@ -171,7 +171,7 @@
     ## 
     ## Model predictions using solution type deSolve 
     ## 
    -## Fitted with method Port using 153 model solutions performed in 0.604 s
    +## Fitted with method Port using 153 model solutions performed in 0.728 s
     ## 
     ## Weighting: none
     ## 
    diff --git a/docs/articles/FOCUS_L.html b/docs/articles/FOCUS_L.html
    index cc069d1a..1087c0ed 100644
    --- a/docs/articles/FOCUS_L.html
    +++ b/docs/articles/FOCUS_L.html
    @@ -29,7 +29,7 @@
           
           
             mkin
    -        0.9.47.4
    +        0.9.47.5
           
         
     
    @@ -55,10 +55,10 @@
           Example evaluation of FOCUS Laboratory Data L1 to L3
         
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -108,17 +108,17 @@

    Since mkin version 0.9-32 (July 2014), we can use shorthand notation like "SFO" for parent only degradation models. The following two lines fit the model and produce the summary report of the model fit. This covers the numerical analysis given in the FOCUS report.

    m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet = TRUE)
     summary(m.L1.SFO)
    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:13 2018 
    -## Date of summary: Fri Sep 14 11:36:13 2018 
    +## Date of fit:     Fri Sep 14 16:54:49 2018 
    +## Date of summary: Fri Sep 14 16:54:49 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - k_parent_sink * parent
     ## 
     ## Model predictions using solution type analytical 
     ## 
    -## Fitted with method Port using 37 model solutions performed in 0.085 s
    +## Fitted with method Port using 37 model solutions performed in 0.088 s
     ## 
     ## Weighting: none
     ## 
    @@ -199,17 +199,17 @@
     plot(m.L1.FOMC, show_errmin = TRUE, main = "FOCUS L1 - FOMC")

    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:14 2018 
    -## Date of summary: Fri Sep 14 11:36:14 2018 
    +## Date of fit:     Fri Sep 14 16:54:51 2018 
    +## Date of summary: Fri Sep 14 16:54:51 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
     ## 
     ## Model predictions using solution type analytical 
     ## 
    -## Fitted with method Port using 611 model solutions performed in 1.405 s
    +## Fitted with method Port using 611 model solutions performed in 1.349 s
     ## 
     ## Weighting: none
     ## 
    @@ -294,17 +294,17 @@
          main = "FOCUS L2 - FOMC")

    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:15 2018 
    -## Date of summary: Fri Sep 14 11:36:15 2018 
    +## Date of fit:     Fri Sep 14 16:54:51 2018 
    +## Date of summary: Fri Sep 14 16:54:51 2018 
     ## 
     ## Equations:
     ## 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.188 s
    +## Fitted with method Port using 81 model solutions performed in 0.18 s
     ## 
     ## Weighting: none
     ## 
    @@ -365,10 +365,10 @@
          main = "FOCUS L2 - DFOP")

    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:16 2018 
    -## Date of summary: Fri Sep 14 11:36:16 2018 
    +## Date of fit:     Fri Sep 14 16:54:52 2018 
    +## Date of summary: Fri Sep 14 16:54:52 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
    @@ -377,7 +377,7 @@
     ## 
     ## Model predictions using solution type analytical 
     ## 
    -## Fitted with method Port using 336 model solutions performed in 0.833 s
    +## Fitted with method Port using 336 model solutions performed in 0.754 s
     ## 
     ## Weighting: none
     ## 
    @@ -457,10 +457,10 @@
     

    The objects returned by mmkin are arranged like a matrix, with models as a row index and datasets as a column index.

    We can extract the summary and plot for e.g. the DFOP fit, using square brackets for indexing which will result in the use of the summary and plot functions working on mkinfit objects.

    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:17 2018 
    -## Date of summary: Fri Sep 14 11:36:17 2018 
    +## Date of fit:     Fri Sep 14 16:54:53 2018 
    +## Date of summary: Fri Sep 14 16:54:53 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
    @@ -469,7 +469,7 @@
     ## 
     ## Model predictions using solution type analytical 
     ## 
    -## Fitted with method Port using 137 model solutions performed in 0.335 s
    +## Fitted with method Port using 137 model solutions performed in 0.312 s
     ## 
     ## Weighting: none
     ## 
    @@ -558,17 +558,17 @@
     

    The \(\chi^2\) error level of 3.3% as well as the plot suggest that the SFO model fits very well. The error level at which the \(\chi^2\) test passes is slightly lower for the FOMC model. However, the difference appears negligible.

    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:18 2018 
    -## Date of summary: Fri Sep 14 11:36:18 2018 
    +## Date of fit:     Fri Sep 14 16:54:54 2018 
    +## Date of summary: Fri Sep 14 16:54:54 2018 
     ## 
     ## Equations:
     ## d_parent/dt = - k_parent_sink * parent
     ## 
     ## Model predictions using solution type analytical 
     ## 
    -## Fitted with method Port using 46 model solutions performed in 0.099 s
    +## Fitted with method Port using 46 model solutions performed in 0.098 s
     ## 
     ## Weighting: none
     ## 
    @@ -618,17 +618,17 @@
     ##        DT50 DT90
     ## parent  106  352
    -
    ## mkin version used for fitting:    0.9.47.3 
    +
    ## mkin version used for fitting:    0.9.47.5 
     ## R version used for fitting:       3.5.1 
    -## Date of fit:     Fri Sep 14 11:36:18 2018 
    -## Date of summary: Fri Sep 14 11:36:18 2018 
    +## Date of fit:     Fri Sep 14 16:54:54 2018 
    +## Date of summary: Fri Sep 14 16:54:54 2018 
     ## 
     ## Equations:
     ## 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.152 s
    +## Fitted with method Port using 66 model solutions performed in 0.153 s
     ## 
     ## Weighting: none
     ## 
    diff --git a/docs/articles/index.html b/docs/articles/index.html
    index e20ad2d4..ad0ab46e 100644
    --- a/docs/articles/index.html
    +++ b/docs/articles/index.html
    @@ -58,7 +58,7 @@
           
           
             mkin
    -        0.9.47.4
    +        0.9.47.5
           
         
     
    @@ -84,10 +84,10 @@
           Example evaluation of FOCUS Laboratory Data L1 to L3
         
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -123,10 +123,10 @@ diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html index bc76c2cf..3ae09165 100644 --- a/docs/articles/mkin.html +++ b/docs/articles/mkin.html @@ -29,7 +29,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -55,10 +55,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/articles/twa.html b/docs/articles/twa.html index a2f7f72a..4d516ff1 100644 --- a/docs/articles/twa.html +++ b/docs/articles/twa.html @@ -29,7 +29,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -55,10 +55,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/articles/web_only/FOCUS_Z.html b/docs/articles/web_only/FOCUS_Z.html new file mode 100644 index 00000000..381c9e4f --- /dev/null +++ b/docs/articles/web_only/FOCUS_Z.html @@ -0,0 +1,332 @@ + + + + + + + +Example evaluation of FOCUS dataset Z • mkin + + + + + + + + + +
    +
    + + + +
    +
    + + + + +

    Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
    Privatdozent at the University of Bremen

    + +
    +

    +Parent and one metabolite

    +

    The next step is to set up the models used for the kinetic analysis. As the simultaneous fit of parent and the first metabolite is usually straightforward, Step 1 (SFO for parent only) is skipped here. We start with the model 2a, with formation and decline of metabolite Z1 and the pathway from parent directly to sink included (default in mkin).

    +
    Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
    +                Z1 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.2a)
    +

    + +
    ##             Estimate se_notrans    t value     Pr(>t) Lower Upper
    +## Z0_0      9.7015e+01   3.553140 2.7304e+01 1.6793e-21    NA    NA
    +## k_Z0_sink 1.2790e-11   0.226895 5.6368e-11 5.0000e-01    NA    NA
    +## k_Z0_Z1   2.2360e+00   0.165073 1.3546e+01 7.3938e-14    NA    NA
    +## k_Z1_sink 4.8212e-01   0.065854 7.3212e+00 3.5520e-08    NA    NA
    +

    As obvious from the parameter summary (the component of the summary), the kinetic rate constant from parent compound Z to sink is very small and the t-test for this parameter suggests that it is not significantly different from zero. This suggests, in agreement with the analysis in the FOCUS kinetics report, to simplify the model by removing the pathway to sink.

    +

    A similar result can be obtained when formation fractions are used in the model formulation:

    + +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.2a.ff)
    +

    + +
    ##            Estimate se_notrans t value     Pr(>t) Lower Upper
    +## Z0_0       97.01488   3.553145 27.3039 1.6793e-21    NA    NA
    +## k_Z0        2.23601   0.216849 10.3114 3.6623e-11    NA    NA
    +## k_Z1        0.48212   0.065854  7.3211 3.5520e-08    NA    NA
    +## f_Z0_to_Z1  1.00000   0.101473  9.8548 9.7068e-11    NA    NA
    +

    Here, the ilr transformed formation fraction fitted in the model takes a very large value, and the backtransformed formation fraction from parent Z to Z1 is practically unity. Here, the covariance matrix used for the calculation of confidence intervals is not returned as the model is overparameterised.

    +

    A simplified model is obtained by removing the pathway to the sink.

    +

    In the following, we use the parameterisation with formation fractions in order to be able to compare with the results in the FOCUS guidance, and as it makes it easier to use parameters obtained in a previous fit when adding a further metabolite.

    +
    Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +               Z1 = mkinsub("SFO"), use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.3)
    +

    + +
    ##      Estimate se_notrans t value     Pr(>t)    Lower   Upper
    +## Z0_0 97.01488   2.681772  36.176 2.3636e-25 91.52152 102.508
    +## k_Z0  2.23601   0.146861  15.225 2.2464e-15  1.95453   2.558
    +## k_Z1  0.48212   0.042687  11.294 3.0686e-12  0.40216   0.578
    +

    As there is only one transformation product for Z0 and no pathway to sink, the formation fraction is internally fixed to unity.

    +
    +
    +

    +Metabolites Z2 and Z3

    +

    As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as well in the next step. While this step appears questionable on the basis of the above results, it is followed here for the purpose of comparison. Also, in the FOCUS report, it is assumed that there is additional empirical evidence that Z1 quickly and exclusively hydrolyses to Z2.

    +
    Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +               Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +               Z2 = mkinsub("SFO"), use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.5)
    +

    +

    Finally, metabolite Z3 is added to the model. We use the optimised differential equation parameter values from the previous fit in order to accelerate the optimization.

    +
    Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +                   Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                   Z2 = mkinsub("SFO", "Z3"),
    +                   Z3 = mkinsub("SFO"),
    +                   use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    + +
    ## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, : Optimisation by method Port did not converge:
    +## false convergence (8)
    +
    plot_sep(m.Z.FOCUS)
    +

    + +
    ##             Estimate se_notrans t value     Pr(>t)     Lower      Upper
    +## Z0_0       96.837112   2.058861 47.0343 5.5877e-44 92.703779 100.970445
    +## k_Z0        2.215368   0.118098 18.7587 7.6563e-25  1.990525   2.465609
    +## k_Z1        0.478302   0.029289 16.3302 3.3408e-22  0.422977   0.540864
    +## k_Z2        0.451617   0.044214 10.2144 3.1133e-14  0.371034   0.549702
    +## k_Z3        0.058693   0.014296  4.1056 7.2924e-05  0.035994   0.095705
    +## f_Z2_to_Z3  0.471516   0.057057  8.2639 2.8156e-11  0.360381   0.585548
    +
    endpoints(m.Z.FOCUS)
    +
    ## $ff
    +##   Z2_Z3 Z2_sink 
    +## 0.47152 0.52848 
    +## 
    +## $SFORB
    +## logical(0)
    +## 
    +## $distimes
    +##        DT50    DT90
    +## Z0  0.31288  1.0394
    +## Z1  1.44918  4.8141
    +## Z2  1.53481  5.0985
    +## Z3 11.80973 39.2311
    +

    This fit corresponds to the final result chosen in Appendix 7 of the FOCUS report. Confidence intervals returned by mkin are based on internally transformed parameters, however.

    +
    +
    +

    +Using the SFORB model

    +

    As the FOCUS report states, there is a certain tailing of the time course of metabolite Z3. Also, the time course of the parent compound is not fitted very well using the SFO model, as residues at a certain low level remain.

    +

    Therefore, an additional model is offered here, using the single first-order reversible binding (SFORB) model for metabolite Z3. As expected, the \(\chi^2\) error level is lower for metabolite Z3 using this model and the graphical fit for Z3 is improved. However, the covariance matrix is not returned.

    +
    Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFORB"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.mkin.1)
    +

    + +
    ## NULL
    +

    Therefore, a further stepwise model building is performed starting from the stage of parent and two metabolites, starting from the assumption that the model fit for the parent compound can be improved by using the SFORB model.

    +
    Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.mkin.3)
    +

    +

    This results in a much better representation of the behaviour of the parent compound Z0.

    +

    Finally, Z3 is added as well. These models appear overparameterised (no covariance matrix returned) if the sink for Z1 is left in the models.

    +
    Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    + +

    +

    The error level of the fit, but especially of metabolite Z3, can be improved if the SFORB model is chosen for this metabolite, as this model is capable of representing the tailing of the metabolite decline phase.

    +
    Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFORB"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    + +

    +

    The summary view of the backtransformed parameters shows that we get no confidence intervals due to overparameterisation. As the optimized is excessively small, it seems reasonable to fix it to zero.

    + +

    +

    As expected, the residual plots for Z0 and Z3 are more random than in the case of the all SFO model for which they were shown above. In conclusion, the model is proposed as the best-fit model for the dataset from Appendix 7 of the FOCUS report.

    +

    A graphical representation of the confidence intervals can finally be obtained.

    +
    mkinparplot(m.Z.mkin.5a)
    +

    +

    The endpoints obtained with this model are

    +
    endpoints(m.Z.mkin.5a)
    +
    ## $ff
    +##   Z0_free_Z1        Z1_Z2      Z2_sink   Z2_Z3_free Z3_free_sink 
    +##      1.00000      1.00000      0.46344      0.53656      1.00000 
    +## 
    +## $SFORB
    +##     Z0_b1     Z0_b2     Z3_b1     Z3_b2 
    +## 2.4471382 0.0075127 0.0800075 0.0000000 
    +## 
    +## $distimes
    +##      DT50   DT90 DT50_Z0_b1 DT50_Z0_b2 DT50_Z3_b1 DT50_Z3_b2
    +## Z0 0.3043 1.1848    0.28325     92.264         NA         NA
    +## Z1 1.5148 5.0320         NA         NA         NA         NA
    +## Z2 1.6414 5.4526         NA         NA         NA         NA
    +## Z3     NA     NA         NA         NA     8.6635        Inf
    +

    It is clear the degradation rate of Z3 towards the end of the experiment is very low as DT50_Z3_b2 (the second Eigenvalue of the system of two differential equations representing the SFORB system for Z3, corresponding to the slower rate constant of the DFOP model) is reported to be infinity. However, this appears to be a feature of the data.

    +
    +
    +

    +References

    + +
    +
    +

    FOCUS Work Group on Degradation Kinetics. 2014. Generic Guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in Eu Registration. 1.1 ed. http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics.

    +
    +
    +
    +
    + + + +
    + + +
    + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png new file mode 100644 index 00000000..53f2ce85 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_1-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png new file mode 100644 index 00000000..90eab945 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png new file mode 100644 index 00000000..f44737ad Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png new file mode 100644 index 00000000..98562168 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png new file mode 100644 index 00000000..27e7eb52 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png new file mode 100644 index 00000000..236cdbfe Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_2-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png new file mode 100644 index 00000000..693c9c2c Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_3-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png new file mode 100644 index 00000000..180f44f9 Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png new file mode 100644 index 00000000..a67e9c1d Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png new file mode 100644 index 00000000..80452f9f Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_7-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png new file mode 100644 index 00000000..e6ce97cd Binary files /dev/null and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png differ diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html new file mode 100644 index 00000000..e941bea3 --- /dev/null +++ b/docs/articles/web_only/compiled_models.html @@ -0,0 +1,201 @@ + + + + + + + +Performance benefit by using compiled model definitions in mkin • mkin + + + + + + + + + +
    +
    + + + +
    +
    + + + + +
    +

    +Model that can also be solved with Eigenvalues

    +

    This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The mkinmod() function checks for presence of the gcc compiler using

    + +
    ##            gcc 
    +## "/usr/bin/gcc"
    +

    First, we build a simple degradation model for a parent compound with one metabolite.

    + +
    ## Successfully compiled differential equation model from auto-generated C code.
    +

    We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package.

    + +
    ## Lade nötiges Paket: rbenchmark
    +
    ##                    test replications elapsed relative user.self sys.self
    +## 3     deSolve, compiled            3   2.120    1.000     2.118    0.000
    +## 1 deSolve, not compiled            3  17.195    8.111    17.187    0.000
    +## 2      Eigenvalue based            3   2.589    1.221     2.582    0.004
    +##   user.child sys.child
    +## 3          0         0
    +## 1          0         0
    +## 2          0         0
    +

    We see that using the compiled model is by a factor of around 8 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.

    +
    +
    +

    +Model that can not be solved with Eigenvalues

    +

    This evaluation is also taken from the example section of mkinfit.

    + +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    ##                    test replications elapsed relative user.self sys.self
    +## 2     deSolve, compiled            3   3.761    1.000     3.758    0.000
    +## 1 deSolve, not compiled            3  36.462    9.695    36.441    0.004
    +##   user.child sys.child
    +## 2          0         0
    +## 1          0         0
    +

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

    +

    This vignette was built with mkin 0.9.47.5 on

    +
    ## R version 3.5.1 (2018-07-02)
    +## Platform: x86_64-pc-linux-gnu (64-bit)
    +## Running under: Debian GNU/Linux 9 (stretch)
    +
    ## CPU model: AMD Ryzen 7 1700 Eight-Core Processor
    +
    +
    + + + +
    + + +
    + +
    +

    Site built with pkgdown.

    +
    + +
    +
    + + + + + diff --git a/docs/authors.html b/docs/authors.html index 61cf4fbc..fddc66c9 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -58,7 +58,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -84,10 +84,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/index.html b/docs/index.html index 5a3864bf..60787c81 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -62,10 +62,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/news/index.html b/docs/news/index.html index 6cc7351d..4bd93964 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -58,7 +58,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -84,10 +84,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/pkgdown.yml b/docs/pkgdown.yml index 8da0943f..bbd8704e 100644 --- a/docs/pkgdown.yml +++ b/docs/pkgdown.yml @@ -4,8 +4,8 @@ pkgdown_sha: ~ articles: FOCUS_D: FOCUS_D.html FOCUS_L: FOCUS_L.html - FOCUS_Z: FOCUS_Z.html - compiled_models: compiled_models.html mkin: mkin.html twa: twa.html + FOCUS_Z: web_only/FOCUS_Z.html + compiled_models: web_only/compiled_models.html diff --git a/docs/reference/DFOP.solution.html b/docs/reference/DFOP.solution.html index 2f714f2c..f3ee0099 100644 --- a/docs/reference/DFOP.solution.html +++ b/docs/reference/DFOP.solution.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/Extract.mmkin.html b/docs/reference/Extract.mmkin.html index 922479a1..9d49313c 100644 --- a/docs/reference/Extract.mmkin.html +++ b/docs/reference/Extract.mmkin.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -278,7 +278,7 @@ #> #> $time #> User System verstrichen -#> 0.164 0.000 0.164 +#> 0.169 0.000 0.169 #> #> $mkinmod #> <mkinmod> model generated with @@ -467,8 +467,8 @@ #> } #> return(mC) #> } -#> <bytecode: 0x55555bd535f0> -#> <environment: 0x55555bd1c770> +#> <bytecode: 0x55555bd4a710> +#> <environment: 0x55555bd3c748> #> #> $cost_notrans #> function (P) @@ -490,8 +490,8 @@ #> scaleVar = scaleVar) #> return(mC) #> } -#> <bytecode: 0x55555c9c70f8> -#> <environment: 0x55555bd1c770> +#> <bytecode: 0x55555c9b4488> +#> <environment: 0x55555bd3c748> #> #> $hessian_notrans #> parent_0 k_parent_sink @@ -558,10 +558,10 @@ #> 99.17407 #> #> $date -#> [1] "Fri Sep 14 11:34:38 2018" +#> [1] "Fri Sep 14 16:53:13 2018" #> #> $version -#> [1] "0.9.47.4" +#> [1] "0.9.47.5" #> #> $Rversion #> [1] "3.5.1" diff --git a/docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html b/docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html index bea35e09..d5354c28 100644 --- a/docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html +++ b/docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html @@ -65,7 +65,7 @@ in this fit." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ in this fit." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html b/docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html index 9122a546..f5c36792 100644 --- a/docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html +++ b/docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html @@ -65,7 +65,7 @@ in this fit." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ in this fit." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/FOCUS_2006_HS_ref_A_to_F.html b/docs/reference/FOCUS_2006_HS_ref_A_to_F.html index 3d5677e8..fb2cd7de 100644 --- a/docs/reference/FOCUS_2006_HS_ref_A_to_F.html +++ b/docs/reference/FOCUS_2006_HS_ref_A_to_F.html @@ -65,7 +65,7 @@ in this fit." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ in this fit." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/FOCUS_2006_SFO_ref_A_to_F.html b/docs/reference/FOCUS_2006_SFO_ref_A_to_F.html index 524fbd79..dfccea5c 100644 --- a/docs/reference/FOCUS_2006_SFO_ref_A_to_F.html +++ b/docs/reference/FOCUS_2006_SFO_ref_A_to_F.html @@ -65,7 +65,7 @@ in this fit." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ in this fit." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/FOCUS_2006_datasets.html b/docs/reference/FOCUS_2006_datasets.html index a0bcc65d..7f89e33e 100644 --- a/docs/reference/FOCUS_2006_datasets.html +++ b/docs/reference/FOCUS_2006_datasets.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/FOMC.solution.html b/docs/reference/FOMC.solution.html index 10f33260..abda4d81 100644 --- a/docs/reference/FOMC.solution.html +++ b/docs/reference/FOMC.solution.html @@ -65,7 +65,7 @@ The form given here differs slightly from the original reference by Gustafson mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ The form given here differs slightly from the original reference by Gustafson Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/HS.solution.html b/docs/reference/HS.solution.html index cb9eb353..bb3768ba 100644 --- a/docs/reference/HS.solution.html +++ b/docs/reference/HS.solution.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/IORE.solution.html b/docs/reference/IORE.solution.html index 23f82d13..d86ee0c3 100644 --- a/docs/reference/IORE.solution.html +++ b/docs/reference/IORE.solution.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/SFO.solution.html b/docs/reference/SFO.solution.html index 087ff46f..17f1920c 100644 --- a/docs/reference/SFO.solution.html +++ b/docs/reference/SFO.solution.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/SFORB.solution.html b/docs/reference/SFORB.solution.html index 61989c40..050d19cf 100644 --- a/docs/reference/SFORB.solution.html +++ b/docs/reference/SFORB.solution.html @@ -65,7 +65,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/add_err.html b/docs/reference/add_err.html index b3324064..cea1e03c 100644 --- a/docs/reference/add_err.html +++ b/docs/reference/add_err.html @@ -63,7 +63,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -89,10 +89,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/endpoints.html b/docs/reference/endpoints.html index fdf465a5..a54fb71e 100644 --- a/docs/reference/endpoints.html +++ b/docs/reference/endpoints.html @@ -64,7 +64,7 @@ with the advantage that the SFORB model can also be used for metabolites." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -90,10 +90,10 @@ with the advantage that the SFORB model can also be used for metabolites." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/geometric_mean.html b/docs/reference/geometric_mean.html index bddbab1a..41ccbbfd 100644 --- a/docs/reference/geometric_mean.html +++ b/docs/reference/geometric_mean.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/ilr.html b/docs/reference/ilr.html index e780d26b..601ab1a2 100644 --- a/docs/reference/ilr.html +++ b/docs/reference/ilr.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/index.html b/docs/reference/index.html index 185991d6..615f6777 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -58,7 +58,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -84,10 +84,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/max_twa_parent.html b/docs/reference/max_twa_parent.html index ef7209bf..3a19c754 100644 --- a/docs/reference/max_twa_parent.html +++ b/docs/reference/max_twa_parent.html @@ -65,7 +65,7 @@ guidance." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ guidance." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mccall81_245T.html b/docs/reference/mccall81_245T.html index ac2adf1e..86f3c07e 100644 --- a/docs/reference/mccall81_245T.html +++ b/docs/reference/mccall81_245T.html @@ -63,7 +63,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -89,10 +89,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -156,10 +156,10 @@
    SFO_SFO_SFO <- mkinmod(T245 = list(type = "SFO", to = "phenol"), phenol = list(type = "SFO", to = "anisole"), anisole = list(type = "SFO"))
    #> Successfully compiled differential equation model from auto-generated C code.
    fit.1 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE) - summary(fit.1, data = FALSE)
    #> mkin version used for fitting: 0.9.47.4 + summary(fit.1, data = FALSE)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:34:50 2018 -#> Date of summary: Fri Sep 14 11:34:50 2018 +#> Date of fit: Fri Sep 14 16:53:25 2018 +#> Date of summary: Fri Sep 14 16:53:25 2018 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -169,7 +169,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 574 model solutions performed in 3.33 s +#> Fitted with method Port using 574 model solutions performed in 3.403 s #> #> Weighting: none #> @@ -245,10 +245,10 @@ fit.2 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), parms.ini = c(k_phenol_sink = 0), fixed_parms = "k_phenol_sink", quiet = TRUE) - summary(fit.2, data = FALSE)
    #> mkin version used for fitting: 0.9.47.4 + summary(fit.2, data = FALSE)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:34:51 2018 -#> Date of summary: Fri Sep 14 11:34:51 2018 +#> Date of fit: Fri Sep 14 16:53:27 2018 +#> Date of summary: Fri Sep 14 16:53:27 2018 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -258,7 +258,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 246 model solutions performed in 1.417 s +#> Fitted with method Port using 246 model solutions performed in 1.46 s #> #> Weighting: none #> diff --git a/docs/reference/mkin_long_to_wide.html b/docs/reference/mkin_long_to_wide.html index b83287ff..ea74ff47 100644 --- a/docs/reference/mkin_long_to_wide.html +++ b/docs/reference/mkin_long_to_wide.html @@ -63,7 +63,7 @@ mkin - 0.9.47.4 + 0.9.47.5
    @@ -89,10 +89,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkin_wide_to_long.html b/docs/reference/mkin_wide_to_long.html index e2b4ef61..369649e3 100644 --- a/docs/reference/mkin_wide_to_long.html +++ b/docs/reference/mkin_wide_to_long.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinds.html b/docs/reference/mkinds.html index c77945b9..d356fdab 100644 --- a/docs/reference/mkinds.html +++ b/docs/reference/mkinds.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinerrmin.html b/docs/reference/mkinerrmin.html index a18b226e..4f70a274 100644 --- a/docs/reference/mkinerrmin.html +++ b/docs/reference/mkinerrmin.html @@ -62,7 +62,7 @@ chi-squared test as defined in the FOCUS kinetics report from 2006." /> mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ chi-squared test as defined in the FOCUS kinetics report from 2006." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinfit.html b/docs/reference/mkinfit.html index 13029e91..0f2bb875 100644 --- a/docs/reference/mkinfit.html +++ b/docs/reference/mkinfit.html @@ -71,7 +71,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -97,10 +97,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -432,17 +432,17 @@

    Examples

    # Use shorthand notation for parent only degradation fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) -summary(fit)
    #> mkin version used for fitting: 0.9.47.4 +summary(fit)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:34:54 2018 -#> Date of summary: Fri Sep 14 11:34:54 2018 +#> Date of fit: Fri Sep 14 16:53:29 2018 +#> Date of summary: Fri Sep 14 16:53:29 2018 #> #> Equations: #> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent #> #> Model predictions using solution type analytical #> -#> Fitted with method Port using 64 model solutions performed in 0.141 s +#> Fitted with method Port using 64 model solutions performed in 0.158 s #> #> Weighting: none #> @@ -511,7 +511,7 @@ 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)))
    #> User System verstrichen -#> 0.906 0.000 0.907
    coef(fit)
    #> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.909 0.000 0.910
    coef(fit)
    #> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750
    #> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 @@ -586,7 +586,7 @@ #> Model cost at call 146 : 371.2134 #> Optimisation by method Port successfully terminated. #> User System verstrichen -#> 0.714 0.000 0.715
    coef(fit.deSolve)
    #> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.749 0.000 0.749
    coef(fit.deSolve)
    #> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink #> 99.59848 -3.03822 -2.98030 -5.24750
    endpoints(fit.deSolve)
    #> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 @@ -622,10 +622,10 @@
    # 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) -summary(f.noweight)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.noweight)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:05 2018 -#> Date of summary: Fri Sep 14 11:35:05 2018 +#> Date of fit: Fri Sep 14 16:53:40 2018 +#> Date of summary: Fri Sep 14 16:53:40 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -633,7 +633,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 186 model solutions performed in 0.763 s +#> Fitted with method Port using 186 model solutions performed in 0.79 s #> #> Weighting: none #> @@ -739,10 +739,10 @@ #> 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.irls <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, reweight.method = "obs", quiet = TRUE) -summary(f.irls)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.irls)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:07 2018 -#> Date of summary: Fri Sep 14 11:35:07 2018 +#> Date of fit: Fri Sep 14 16:53:43 2018 +#> Date of summary: Fri Sep 14 16:53:43 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -750,7 +750,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 551 model solutions performed in 2.297 s +#> Fitted with method Port using 551 model solutions performed in 2.278 s #> #> Weighting: none #> @@ -861,10 +861,10 @@ #> 100 m1 33.13 31.98971 1.140e+00 2.722 #> 120 m1 25.15 28.80898 -3.659e+00 2.722 #> 120 m1 33.31 28.80898 4.501e+00 2.722
    f.w.mean <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, weight = "mean", quiet = TRUE) -summary(f.w.mean)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.w.mean)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:08 2018 -#> Date of summary: Fri Sep 14 11:35:08 2018 +#> Date of fit: Fri Sep 14 16:53:43 2018 +#> Date of summary: Fri Sep 14 16:53:43 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -872,7 +872,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 155 model solutions performed in 0.618 s +#> Fitted with method Port using 155 model solutions performed in 0.643 s #> #> Weighting: mean #> @@ -979,10 +979,10 @@ #> 120 m1 25.15 28.82413 -3.674128 #> 120 m1 33.31 28.82413 4.485872
    f.w.value <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), err = "value", quiet = TRUE) -summary(f.w.value)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.w.value)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:09 2018 -#> Date of summary: Fri Sep 14 11:35:09 2018 +#> Date of fit: Fri Sep 14 16:53:44 2018 +#> Date of summary: Fri Sep 14 16:53:44 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -990,7 +990,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 174 model solutions performed in 0.704 s +#> Fitted with method Port using 174 model solutions performed in 0.722 s #> #> Weighting: manual #> @@ -1099,10 +1099,10 @@ errors <- c(parent = 2, m1 = 1) dw$err.man <- errors[FOCUS_2006_D$name] f.w.man <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE) -summary(f.w.man)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.w.man)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:10 2018 -#> Date of summary: Fri Sep 14 11:35:10 2018 +#> Date of fit: Fri Sep 14 16:53:45 2018 +#> Date of summary: Fri Sep 14 16:53:45 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1110,7 +1110,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 270 model solutions performed in 1.109 s +#> Fitted with method Port using 270 model solutions performed in 1.11 s #> #> Weighting: manual #> @@ -1217,10 +1217,10 @@ #> 120 m1 25.15 28.76062 -3.610621 2 #> 120 m1 33.31 28.76062 4.549379 2
    f.w.man.irls <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE, reweight.method = "obs") -summary(f.w.man.irls)
    #> mkin version used for fitting: 0.9.47.4 +summary(f.w.man.irls)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:13 2018 -#> Date of summary: Fri Sep 14 11:35:13 2018 +#> Date of fit: Fri Sep 14 16:53:49 2018 +#> Date of summary: Fri Sep 14 16:53:49 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1228,7 +1228,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 692 model solutions performed in 2.903 s +#> Fitted with method Port using 692 model solutions performed in 2.945 s #> #> Weighting: manual #> diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index 857e0c74..3633686e 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -66,7 +66,7 @@ For the definition of model types and their parameters, the equations given mkin - 0.9.47.4 + 0.9.47.5
    @@ -92,10 +92,10 @@ For the definition of model types and their parameters, the equations given Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -229,7 +229,7 @@ For the definition of model types and their parameters, the equations given SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), verbose = TRUE)
    #> Compilation argument: -#> /usr/lib/R/bin/R CMD SHLIB file3c104e6e45e4.c 2> file3c104e6e45e4.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB file7b505448f8a5.c 2> file7b505448f8a5.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: diff --git a/docs/reference/mkinparplot.html b/docs/reference/mkinparplot.html index adcd2a3b..6ed32315 100644 --- a/docs/reference/mkinparplot.html +++ b/docs/reference/mkinparplot.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5
    @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinplot.html b/docs/reference/mkinplot.html index 2d878175..72ff93f6 100644 --- a/docs/reference/mkinplot.html +++ b/docs/reference/mkinplot.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index ffd6e89f..6c30d7a8 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -63,7 +63,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -89,10 +89,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -326,7 +326,7 @@ c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve")[201,]))
    #> time parent m1 #> 201 20 4.978707 27.46227
    #> User System verstrichen -#> 0.002 0.000 0.001
    system.time( +#> 0.002 0.000 0.002
    system.time( print(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,]))
    #> time parent m1 diff --git a/docs/reference/mkinresplot.html b/docs/reference/mkinresplot.html index b4e1e747..306b7400 100644 --- a/docs/reference/mkinresplot.html +++ b/docs/reference/mkinresplot.html @@ -64,7 +64,7 @@ mkin - 0.9.47.4 + 0.9.47.5
    @@ -90,10 +90,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mkinsub.html b/docs/reference/mkinsub.html index a34f1dae..0a2bf41a 100644 --- a/docs/reference/mkinsub.html +++ b/docs/reference/mkinsub.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/mmkin.html b/docs/reference/mmkin.html index 621571c1..a656ef65 100644 --- a/docs/reference/mmkin.html +++ b/docs/reference/mmkin.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -189,8 +189,8 @@ time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE)) time_default
    #> User System verstrichen -#> 0.046 0.033 6.654
    time_1
    #> User System verstrichen -#> 20.150 0.000 20.163
    +#> 0.054 0.029 6.762
    time_1
    #> User System verstrichen +#> 20.495 0.004 20.512
    endpoints(fits.0[["SFO_lin", 2]])
    #> $ff #> parent_M1 parent_sink M1_M2 M1_sink #> 0.7340480 0.2659520 0.7505686 0.2494314 diff --git a/docs/reference/plot.mkinfit.html b/docs/reference/plot.mkinfit.html index 4fec74c9..e88c2025 100644 --- a/docs/reference/plot.mkinfit.html +++ b/docs/reference/plot.mkinfit.html @@ -66,7 +66,7 @@ If the current plot device is a tikz device, mkin - 0.9.47.4 + 0.9.47.5
    @@ -92,10 +92,10 @@ If the current plot device is a tikz device, Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/plot.mmkin.html b/docs/reference/plot.mmkin.html index 478a5682..d67d87d9 100644 --- a/docs/reference/plot.mmkin.html +++ b/docs/reference/plot.mmkin.html @@ -65,7 +65,7 @@ If the current plot device is a tikz device, mkin - 0.9.47.4 + 0.9.47.5 @@ -91,10 +91,10 @@ If the current plot device is a tikz device, Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/print.mkinds.html b/docs/reference/print.mkinds.html index f59325f9..2489269c 100644 --- a/docs/reference/print.mkinds.html +++ b/docs/reference/print.mkinds.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/print.mkinmod.html b/docs/reference/print.mkinmod.html index 299fdfbb..b6cbad61 100644 --- a/docs/reference/print.mkinmod.html +++ b/docs/reference/print.mkinmod.html @@ -61,7 +61,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -87,10 +87,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/schaefer07_complex_case.html b/docs/reference/schaefer07_complex_case.html index 9fd60805..4ceba867 100644 --- a/docs/reference/schaefer07_complex_case.html +++ b/docs/reference/schaefer07_complex_case.html @@ -63,7 +63,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -89,10 +89,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/sigma_twocomp.html b/docs/reference/sigma_twocomp.html index 6db7d74c..e74707ff 100644 --- a/docs/reference/sigma_twocomp.html +++ b/docs/reference/sigma_twocomp.html @@ -66,7 +66,7 @@ This is the error model used for example by Werner et al. (1978). The model mkin - 0.9.47.4 + 0.9.47.5 @@ -92,10 +92,10 @@ This is the error model used for example by Werner et al. (1978). The model Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/summary.mkinfit.html b/docs/reference/summary.mkinfit.html index 1d0a7c52..bb701470 100644 --- a/docs/reference/summary.mkinfit.html +++ b/docs/reference/summary.mkinfit.html @@ -64,7 +64,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -90,10 +90,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -204,17 +204,17 @@

    Examples

    -
    summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
    #> mkin version used for fitting: 0.9.47.4 +
    summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:35:59 2018 -#> Date of summary: Fri Sep 14 11:35:59 2018 +#> Date of fit: Fri Sep 14 16:54:36 2018 +#> Date of summary: Fri Sep 14 16:54:36 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent #> #> Model predictions using solution type analytical #> -#> Fitted with method Port using 35 model solutions performed in 0.076 s +#> Fitted with method Port using 35 model solutions performed in 0.077 s #> #> Weighting: none #> diff --git a/docs/reference/synthetic_data_for_UBA.html b/docs/reference/synthetic_data_for_UBA.html index 25cfc012..384d628d 100644 --- a/docs/reference/synthetic_data_for_UBA.html +++ b/docs/reference/synthetic_data_for_UBA.html @@ -76,7 +76,7 @@ Compare also the code in the example section to see the degradation models." /> mkin - 0.9.47.4 + 0.9.47.5
    @@ -102,10 +102,10 @@ Compare also the code in the example section to see the degradation models." /> Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/test_data_from_UBA_2014.html b/docs/reference/test_data_from_UBA_2014.html index a30161a2..094e003d 100644 --- a/docs/reference/test_data_from_UBA_2014.html +++ b/docs/reference/test_data_from_UBA_2014.html @@ -62,7 +62,7 @@ mkin - 0.9.47.4 + 0.9.47.5 @@ -88,10 +88,10 @@ Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index c0ca534c..38c3fe9d 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -69,7 +69,7 @@ The transformation of sets of formation fractions is fragile, as it supposes mkin - 0.9.47.4 + 0.9.47.5 @@ -95,10 +95,10 @@ The transformation of sets of formation fractions is fragile, as it supposes Example evaluation of FOCUS Laboratory Data L1 to L3
  • - Example evaluation of FOCUS Example Dataset Z + Example evaluation of FOCUS Example Dataset Z
  • - Performance benefit by using compiled model definitions in mkin + Performance benefit by using compiled model definitions in mkin
  • Calculation of time weighted average concentrations with mkin @@ -198,10 +198,10 @@ The transformation of sets of formation fractions is fragile, as it supposes parent = list(type = "SFO", 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 <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) -summary(fit, data=FALSE) # See transformed and backtransformed parameters
    #> mkin version used for fitting: 0.9.47.4 +summary(fit, data=FALSE) # See transformed and backtransformed parameters
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:36:07 2018 -#> Date of summary: Fri Sep 14 11:36:07 2018 +#> Date of fit: Fri Sep 14 16:54:43 2018 +#> Date of summary: Fri Sep 14 16:54:43 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -209,7 +209,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 153 model solutions performed in 0.627 s +#> Fitted with method Port using 153 model solutions performed in 0.629 s #> #> Weighting: none #> @@ -274,10 +274,10 @@ The transformation of sets of formation fractions is fragile, as it supposes #> parent 7.023 23.33 #> m1 131.761 437.70
    fit.2 <- mkinfit(SFO_SFO, FOCUS_2006_D, transform_rates = FALSE, quiet = TRUE) -summary(fit.2, data=FALSE)
    #> mkin version used for fitting: 0.9.47.4 +summary(fit.2, data=FALSE)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:36:08 2018 -#> Date of summary: Fri Sep 14 11:36:08 2018 +#> Date of fit: Fri Sep 14 16:54:45 2018 +#> Date of summary: Fri Sep 14 16:54:45 2018 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -285,7 +285,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 350 model solutions performed in 1.437 s +#> Fitted with method Port using 350 model solutions performed in 1.426 s #> #> Weighting: none #> @@ -362,10 +362,10 @@ The transformation of sets of formation fractions is fragile, as it supposes m1 = list(type = "SFO"), use_of_ff = "max")
    #> Successfully compiled differential equation model from auto-generated C code.
    fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) -summary(fit.ff, data = FALSE)
    #> mkin version used for fitting: 0.9.47.4 +summary(fit.ff, data = FALSE)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:36:09 2018 -#> Date of summary: Fri Sep 14 11:36:09 2018 +#> Date of fit: Fri Sep 14 16:54:46 2018 +#> Date of summary: Fri Sep 14 16:54:46 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -373,7 +373,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 186 model solutions performed in 0.773 s +#> Fitted with method Port using 186 model solutions performed in 0.766 s #> #> Weighting: none #> @@ -446,10 +446,10 @@ The transformation of sets of formation fractions is fragile, as it supposes use_of_ff = "max")
    #> Successfully compiled differential equation model from auto-generated C code.
    fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_2006_D, quiet = TRUE) -summary(fit.ff.2, data = FALSE)
    #> mkin version used for fitting: 0.9.47.4 +summary(fit.ff.2, data = FALSE)
    #> mkin version used for fitting: 0.9.47.5 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 11:36:10 2018 -#> Date of summary: Fri Sep 14 11:36:10 2018 +#> Date of fit: Fri Sep 14 16:54:46 2018 +#> Date of summary: Fri Sep 14 16:54:46 2018 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -457,7 +457,7 @@ The transformation of sets of formation fractions is fragile, as it supposes #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 104 model solutions performed in 0.424 s +#> Fitted with method Port using 104 model solutions performed in 0.42 s #> #> Weighting: none #> diff --git a/test.log b/test.log index 25afc5a1..884b67c1 100644 --- a/test.log +++ b/test.log @@ -2,20 +2,22 @@ Loading mkin Loading required package: testthat Testing mkin ✔ | OK F W S | Context - ⠏ | 0 | Calculation of FOCUS chi2 error levels ⠋ | 1 | Calculation of FOCUS chi2 error levels ⠙ | 2 | Calculation of FOCUS chi2 error levels ✔ | 2 | Calculation of FOCUS chi2 error levels [2.4 s] + ⠏ | 0 | Calculation of FOCUS chi2 error levels ⠋ | 1 | Calculation of FOCUS chi2 error levels ⠙ | 2 | Calculation of FOCUS chi2 error levels ✔ | 2 | Calculation of FOCUS chi2 error levels [2.3 s] ⠏ | 0 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠼ | 5 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠴ | 6 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 6 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [2.3 s] - ⠏ | 0 | The t-test for significant difference from zero ⠋ | 1 | The t-test for significant difference from zero ⠙ | 2 | The t-test for significant difference from zero ✔ | 2 | The t-test for significant difference from zero [4.2 s] - ⠏ | 0 | Iteratively reweighed least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighed least squares (IRLS) fitting ⠙ | 2 | Iteratively reweighed least squares (IRLS) fitting ⠹ | 3 | Iteratively reweighed least squares (IRLS) fitting ✔ | 3 | Iteratively reweighed least squares (IRLS) fitting [36.3 s] + ⠏ | 0 | The t-test for significant difference from zero ⠋ | 1 | The t-test for significant difference from zero ⠙ | 2 | The t-test for significant difference from zero ✔ | 2 | The t-test for significant difference from zero [4.6 s] + ⠏ | 0 | Iteratively reweighted least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighted least squares (IRLS) fitting ⠙ | 2 | Iteratively reweighted least squares (IRLS) fitting ⠹ | 3 | Iteratively reweighted least squares (IRLS) fitting ✔ | 3 | Iteratively reweighted least squares (IRLS) fitting [37.5 s] ⠏ | 0 | Model predictions with mkinpredict ⠋ | 1 | Model predictions with mkinpredict ⠙ | 2 | Model predictions with mkinpredict ⠹ | 3 | Model predictions with mkinpredict ✔ | 3 | Model predictions with mkinpredict [0.3 s] - ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [21.6 s] - ⠏ | 0 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠋ | 1 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠙ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.3 s] - ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [6.7 s] - ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 3 | Calculation of maximum time weighted average concentrations (TWAs) [4.6 s] + ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [22.2 s] + ⠏ | 0 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠋ | 1 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠙ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.4 s] + ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [6.9 s] + ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 3 | Calculation of maximum time weighted average concentrations (TWAs) [4.9 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 83.9 s +Duration: 86.5 s OK: 46 Failed: 0 Warnings: 0 Skipped: 0 + +Nice code. diff --git a/tests/testthat/test_irls.R b/tests/testthat/test_irls.R index 93d538de..6c8ad849 100644 --- a/tests/testthat/test_irls.R +++ b/tests/testthat/test_irls.R @@ -16,7 +16,7 @@ # You should have received a copy of the GNU General Public License along with # this program. If not, see -context("Iteratively reweighed least squares (IRLS) fitting") +context("Iteratively reweighted least squares (IRLS) fitting") m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), @@ -46,7 +46,7 @@ test_that("Reweighting method 'tc' works", { parms_2 <- signif(fit_irls_2$bparms.optim, 3) expect_equivalent(parms_2, c(99.3, 0.041, 0.00962, 0.597, 0.393, 0.298, 0.0203, 0.707)) - fit_irls_3 <- mkinfit("DFOP", FOCUS_2006_C, reweight.method = "tc", quiet = TRUE) - parms_3 <- signif(fit_irls_3$bparms.optim, 3) - expect_equivalent(parms_3, c(85.0, 0.46, 0.0178, 0.854)) + # In the dataset FOCUS_2006_C, no correlation between absolute residuals and observed + # values is found + expect_error(mkinfit("DFOP", FOCUS_2006_C, reweight.method = "tc", quiet = TRUE), "No correlation") }) diff --git a/vignettes/FOCUS_Z.Rmd b/vignettes/FOCUS_Z.Rmd deleted file mode 100644 index 951d5eee..00000000 --- a/vignettes/FOCUS_Z.Rmd +++ /dev/null @@ -1,256 +0,0 @@ ---- -title: Example evaluation of FOCUS dataset Z -author: Johannes Ranke -date: "`r Sys.Date()`" -output: - html_document: - toc: true - toc_float: true - code_folding: show - fig_retina: null -bibliography: references.bib -vignette: > - %\VignetteEngine{knitr::rmarkdown} - %\VignetteIndexEntry{Example evaluation of FOCUS dataset Z} - %\VignetteEncoding{UTF-8} ---- - -[Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany](http://www.jrwb.de)
    -[Privatdozent at the University of Bremen](http://chem.uft.uni-bremen.de/ranke) - -```{r, include = FALSE} -require(knitr) -options(digits = 5) -opts_chunk$set(engine='R', tidy = FALSE) -``` - -# The data - -The following code defines the example dataset from Appendix 7 to the FOCUS kinetics -report [@FOCUSkinetics2014, p. 354]. - -```{r, echo = TRUE, fig = TRUE, fig.width = 8, fig.height = 7} -library(mkin, quietly = TRUE) -LOD = 0.5 -FOCUS_2006_Z = data.frame( - t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21, - 42, 61, 96, 124), - Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8, - 2.9, 3.5, 5.3, 4.4, 1.2, 0.7), - Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1, - 1.6, 0.6, 0.5 * LOD, NA, NA, NA), - Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5, - 0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA), - Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5, - 25.2, 17.2, 4.8, 4.5, 2.8, 4.4)) - -FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z) -``` - -# Parent and one metabolite - -The next step is to set up the models used for the kinetic analysis. As the -simultaneous fit of parent and the first metabolite is usually straightforward, -Step 1 (SFO for parent only) is skipped here. We start with the model 2a, -with formation and decline of metabolite Z1 and the pathway from parent -directly to sink included (default in mkin). - -```{r FOCUS_2006_Z_fits_1, echo=TRUE, fig.height=6} -Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"), - Z1 = mkinsub("SFO")) -m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.2a) -summary(m.Z.2a, data = FALSE)$bpar -``` - -As obvious from the parameter summary (the \texttt{bpar} component of the -summary), the kinetic rate constant from parent compound Z to sink -is very small and the t-test for this parameter suggests that it is -not significantly different from zero. This suggests, in agreement with the -analysis in the FOCUS kinetics report, to simplify the model by removing the -pathway to sink. - -A similar result can be obtained when formation fractions are used in the model -formulation: - -```{r FOCUS_2006_Z_fits_2, echo=TRUE, fig.height=6} -Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"), - Z1 = mkinsub("SFO"), - use_of_ff = "max") - -m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.2a.ff) -summary(m.Z.2a.ff, data = FALSE)$bpar -``` - -Here, the ilr transformed formation fraction fitted in the model takes a very -large value, and the backtransformed formation fraction from parent Z to Z1 is -practically unity. Here, the covariance matrix used for the calculation -of confidence intervals is not returned as the model is -overparameterised. - -A simplified model is obtained by removing the pathway to the sink. -\footnote{If the model formulation without formation fractions -is used, the same effect can be obtained by fixing the parameter \texttt{k\_Z\_sink} -to a value of zero.} - -In the following, we use the parameterisation with formation fractions in order -to be able to compare with the results in the FOCUS guidance, and as it -makes it easier to use parameters obtained in a previous fit when adding a further -metabolite. - -```{r FOCUS_2006_Z_fits_3, echo=TRUE, fig.height=6} -Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), - Z1 = mkinsub("SFO"), use_of_ff = "max") -m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.3) -summary(m.Z.3, data = FALSE)$bpar -``` - -As there is only one transformation product for Z0 and no pathway -to sink, the formation fraction is internally fixed to unity. - -# Metabolites Z2 and Z3 - -As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as -well in the next step. While this step appears questionable on the basis of the above results, it -is followed here for the purpose of comparison. Also, in the FOCUS report, it is -assumed that there is additional empirical evidence that Z1 quickly and exclusively -hydrolyses to Z2. - -```{r FOCUS_2006_Z_fits_5, echo=TRUE, fig.height=7} -Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO"), use_of_ff = "max") -m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.5) -``` - -Finally, metabolite Z3 is added to the model. We use the optimised -differential equation parameter values from the previous fit in order to -accelerate the optimization. - -```{r FOCUS_2006_Z_fits_6, echo=TRUE, fig.height=8} -Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO", "Z3"), - Z3 = mkinsub("SFO"), - use_of_ff = "max") -m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, - parms.ini = m.Z.5$bparms.ode, - quiet = TRUE) -plot_sep(m.Z.FOCUS) -summary(m.Z.FOCUS, data = FALSE)$bpar -endpoints(m.Z.FOCUS) -``` - -This fit corresponds to the final result chosen in Appendix 7 of the FOCUS -report. Confidence intervals returned by mkin are based on internally -transformed parameters, however. - -# Using the SFORB model - -As the FOCUS report states, there is a certain tailing of the time course of metabolite -Z3. Also, the time course of the parent compound is not fitted very well using the -SFO model, as residues at a certain low level remain. - -Therefore, an additional model is offered here, using the single first-order -reversible binding (SFORB) model for metabolite Z3. As expected, the $\chi^2$ -error level is lower for metabolite Z3 using this model and the graphical -fit for Z3 is improved. However, the covariance matrix is not returned. - -```{r FOCUS_2006_Z_fits_7, echo=TRUE, fig.height=8} -Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO", "Z3"), - Z3 = mkinsub("SFORB")) -m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.mkin.1) -summary(m.Z.mkin.1, data = FALSE)$cov.unscaled -``` - -Therefore, a further stepwise model building is performed starting from the -stage of parent and two metabolites, starting from the assumption that the model -fit for the parent compound can be improved by using the SFORB model. - -```{r FOCUS_2006_Z_fits_9, echo=TRUE, fig.height=8} -Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO")) -m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE) -plot_sep(m.Z.mkin.3) -``` - -This results in a much better representation of the behaviour of the parent -compound Z0. - -Finally, Z3 is added as well. These models appear overparameterised (no -covariance matrix returned) if the sink for Z1 is left in the models. - -```{r FOCUS_2006_Z_fits_10, echo=TRUE, fig.height=8} -Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO", "Z3"), - Z3 = mkinsub("SFO")) -m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin, - parms.ini = m.Z.mkin.3$bparms.ode, - quiet = TRUE) -plot_sep(m.Z.mkin.4) -``` - -The error level of the fit, but especially of metabolite Z3, can be improved if -the SFORB model is chosen for this metabolite, as this model is capable of -representing the tailing of the metabolite decline phase. - -```{r FOCUS_2006_Z_fits_11, echo=TRUE, fig.height=8} -Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), - Z1 = mkinsub("SFO", "Z2", sink = FALSE), - Z2 = mkinsub("SFO", "Z3"), - Z3 = mkinsub("SFORB")) -m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, - parms.ini = m.Z.mkin.4$bparms.ode[1:4], - quiet = TRUE) -plot_sep(m.Z.mkin.5) -``` - -The summary view of the backtransformed parameters shows that we get no -confidence intervals due to overparameterisation. As the optimized -\texttt{k\_Z3\_bound\_free} is excessively small, it seems reasonable to fix it to -zero. - -```{r FOCUS_2006_Z_fits_11a, echo=TRUE} -m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, - parms.ini = c(m.Z.mkin.5$bparms.ode[1:7], - k_Z3_bound_free = 0), - fixed_parms = "k_Z3_bound_free", - quiet = TRUE) -plot_sep(m.Z.mkin.5a) -``` - -As expected, the residual plots for Z0 and Z3 are more random than in the case of the -all SFO model for which they were shown above. In conclusion, the model -\texttt{Z.mkin.5a} is proposed as the best-fit model for the dataset from -Appendix 7 of the FOCUS report. - -A graphical representation of the confidence intervals can finally be obtained. - -```{r FOCUS_2006_Z_fits_11b, echo=TRUE} -mkinparplot(m.Z.mkin.5a) -``` - -The endpoints obtained with this model are - -```{r FOCUS_2006_Z_fits_11b_endpoints, echo=TRUE} -endpoints(m.Z.mkin.5a) -``` - -It is clear the degradation rate of Z3 towards the end of the experiment -is very low as DT50\_Z3\_b2 (the second Eigenvalue of the system of two differential -equations representing the SFORB system for Z3, corresponding to the slower rate -constant of the DFOP model) is reported to be infinity. However, this appears -to be a feature of the data. - - -# References - - diff --git a/vignettes/FOCUS_Z.html b/vignettes/FOCUS_Z.html deleted file mode 100644 index ab32e936..00000000 --- a/vignettes/FOCUS_Z.html +++ /dev/null @@ -1,474 +0,0 @@ - - - - - - - - - - - - - - - -Example evaluation of FOCUS dataset Z - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - -
    -
    -
    -
    -
    - -
    - - - - - - - -

    Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
    Privatdozent at the University of Bremen

    -
    -

    The data

    -

    The following code defines the example dataset from Appendix 7 to the FOCUS kinetics report (FOCUS Work Group on Degradation Kinetics 2014, 354).

    -
    library(mkin, quietly = TRUE)
    -LOD = 0.5
    -FOCUS_2006_Z = data.frame(
    -  t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21,
    -        42, 61, 96, 124),
    -  Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8,
    -         2.9, 3.5, 5.3, 4.4, 1.2, 0.7),
    -  Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1,
    -         1.6, 0.6, 0.5 * LOD, NA, NA, NA),
    -  Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5,
    -         0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA),
    -  Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5,
    -         25.2, 17.2, 4.8, 4.5, 2.8, 4.4))
    -
    -FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z)
    -
    -
    -

    Parent and one metabolite

    -

    The next step is to set up the models used for the kinetic analysis. As the simultaneous fit of parent and the first metabolite is usually straightforward, Step 1 (SFO for parent only) is skipped here. We start with the model 2a, with formation and decline of metabolite Z1 and the pathway from parent directly to sink included (default in mkin).

    -
    Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
    -                Z1 = mkinsub("SFO"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.2a)
    -

    -
    summary(m.Z.2a, data = FALSE)$bpar
    -
    ##             Estimate se_notrans    t value     Pr(>t) Lower Upper
    -## Z0_0      9.7015e+01   3.553140 2.7304e+01 1.6793e-21    NA    NA
    -## k_Z0_sink 1.2790e-11   0.226895 5.6368e-11 5.0000e-01    NA    NA
    -## k_Z0_Z1   2.2360e+00   0.165073 1.3546e+01 7.3938e-14    NA    NA
    -## k_Z1_sink 4.8212e-01   0.065854 7.3212e+00 3.5520e-08    NA    NA
    -

    As obvious from the parameter summary (the component of the summary), the kinetic rate constant from parent compound Z to sink is very small and the t-test for this parameter suggests that it is not significantly different from zero. This suggests, in agreement with the analysis in the FOCUS kinetics report, to simplify the model by removing the pathway to sink.

    -

    A similar result can be obtained when formation fractions are used in the model formulation:

    -
    Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
    -                   Z1 = mkinsub("SFO"),
    -                   use_of_ff = "max")
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.2a.ff)
    -

    -
    summary(m.Z.2a.ff, data = FALSE)$bpar
    -
    ##            Estimate se_notrans t value     Pr(>t) Lower Upper
    -## Z0_0       97.01488   3.553145 27.3039 1.6793e-21    NA    NA
    -## k_Z0        2.23601   0.216849 10.3114 3.6623e-11    NA    NA
    -## k_Z1        0.48212   0.065854  7.3211 3.5520e-08    NA    NA
    -## f_Z0_to_Z1  1.00000   0.101473  9.8548 9.7068e-11    NA    NA
    -

    Here, the ilr transformed formation fraction fitted in the model takes a very large value, and the backtransformed formation fraction from parent Z to Z1 is practically unity. Here, the covariance matrix used for the calculation of confidence intervals is not returned as the model is overparameterised.

    -

    A simplified model is obtained by removing the pathway to the sink.

    -

    In the following, we use the parameterisation with formation fractions in order to be able to compare with the results in the FOCUS guidance, and as it makes it easier to use parameters obtained in a previous fit when adding a further metabolite.

    -
    Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    -               Z1 = mkinsub("SFO"), use_of_ff = "max")
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.3)
    -

    -
    summary(m.Z.3, data = FALSE)$bpar
    -
    ##      Estimate se_notrans t value     Pr(>t)    Lower   Upper
    -## Z0_0 97.01488   2.681772  36.176 2.3636e-25 91.52152 102.508
    -## k_Z0  2.23601   0.146861  15.225 2.2464e-15  1.95453   2.558
    -## k_Z1  0.48212   0.042687  11.294 3.0686e-12  0.40216   0.578
    -

    As there is only one transformation product for Z0 and no pathway to sink, the formation fraction is internally fixed to unity.

    -
    -
    -

    Metabolites Z2 and Z3

    -

    As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as well in the next step. While this step appears questionable on the basis of the above results, it is followed here for the purpose of comparison. Also, in the FOCUS report, it is assumed that there is additional empirical evidence that Z1 quickly and exclusively hydrolyses to Z2.

    -
    Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    -               Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -               Z2 = mkinsub("SFO"), use_of_ff = "max")
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.5)
    -

    -

    Finally, metabolite Z3 is added to the model. We use the optimised differential equation parameter values from the previous fit in order to accelerate the optimization.

    -
    Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    -                   Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -                   Z2 = mkinsub("SFO", "Z3"),
    -                   Z3 = mkinsub("SFO"),
    -                   use_of_ff = "max")
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin,
    -                     parms.ini = m.Z.5$bparms.ode,
    -                     quiet = TRUE)
    -
    ## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, : Optimisation by method Port did not converge:
    -## false convergence (8)
    -
    plot_sep(m.Z.FOCUS)
    -

    -
    summary(m.Z.FOCUS, data = FALSE)$bpar
    -
    ##             Estimate se_notrans t value     Pr(>t)     Lower      Upper
    -## Z0_0       96.837112   2.058861 47.0343 5.5877e-44 92.703779 100.970445
    -## k_Z0        2.215368   0.118098 18.7587 7.6563e-25  1.990525   2.465609
    -## k_Z1        0.478302   0.029289 16.3302 3.3408e-22  0.422977   0.540864
    -## k_Z2        0.451617   0.044214 10.2144 3.1133e-14  0.371034   0.549702
    -## k_Z3        0.058693   0.014296  4.1056 7.2924e-05  0.035994   0.095705
    -## f_Z2_to_Z3  0.471516   0.057057  8.2639 2.8156e-11  0.360381   0.585548
    -
    endpoints(m.Z.FOCUS)
    -
    ## $ff
    -##   Z2_Z3 Z2_sink 
    -## 0.47152 0.52848 
    -## 
    -## $SFORB
    -## logical(0)
    -## 
    -## $distimes
    -##        DT50    DT90
    -## Z0  0.31288  1.0394
    -## Z1  1.44918  4.8141
    -## Z2  1.53481  5.0985
    -## Z3 11.80973 39.2311
    -

    This fit corresponds to the final result chosen in Appendix 7 of the FOCUS report. Confidence intervals returned by mkin are based on internally transformed parameters, however.

    -
    -
    -

    Using the SFORB model

    -

    As the FOCUS report states, there is a certain tailing of the time course of metabolite Z3. Also, the time course of the parent compound is not fitted very well using the SFO model, as residues at a certain low level remain.

    -

    Therefore, an additional model is offered here, using the single first-order reversible binding (SFORB) model for metabolite Z3. As expected, the \(\chi^2\) error level is lower for metabolite Z3 using this model and the graphical fit for Z3 is improved. However, the covariance matrix is not returned.

    -
    Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    -                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -                    Z2 = mkinsub("SFO", "Z3"),
    -                    Z3 = mkinsub("SFORB"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.mkin.1)
    -

    -
    summary(m.Z.mkin.1, data = FALSE)$cov.unscaled
    -
    ## NULL
    -

    Therefore, a further stepwise model building is performed starting from the stage of parent and two metabolites, starting from the assumption that the model fit for the parent compound can be improved by using the SFORB model.

    -
    Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    -                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -                    Z2 = mkinsub("SFO"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    -plot_sep(m.Z.mkin.3)
    -

    -

    This results in a much better representation of the behaviour of the parent compound Z0.

    -

    Finally, Z3 is added as well. These models appear overparameterised (no covariance matrix returned) if the sink for Z1 is left in the models.

    -
    Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    -                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -                    Z2 = mkinsub("SFO", "Z3"),
    -                    Z3 = mkinsub("SFO"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin,
    -                      parms.ini = m.Z.mkin.3$bparms.ode,
    -                      quiet = TRUE)
    -plot_sep(m.Z.mkin.4)
    -

    -

    The error level of the fit, but especially of metabolite Z3, can be improved if the SFORB model is chosen for this metabolite, as this model is capable of representing the tailing of the metabolite decline phase.

    -
    Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    -                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    -                    Z2 = mkinsub("SFO", "Z3"),
    -                    Z3 = mkinsub("SFORB"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
    -                      parms.ini = m.Z.mkin.4$bparms.ode[1:4],
    -                      quiet = TRUE)
    -plot_sep(m.Z.mkin.5)
    -

    -

    The summary view of the backtransformed parameters shows that we get no confidence intervals due to overparameterisation. As the optimized is excessively small, it seems reasonable to fix it to zero.

    -
    m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
    -                       parms.ini = c(m.Z.mkin.5$bparms.ode[1:7],
    -                                     k_Z3_bound_free = 0),
    -                       fixed_parms = "k_Z3_bound_free",
    -                       quiet = TRUE)
    -plot_sep(m.Z.mkin.5a)
    -

    -

    As expected, the residual plots for Z0 and Z3 are more random than in the case of the all SFO model for which they were shown above. In conclusion, the model is proposed as the best-fit model for the dataset from Appendix 7 of the FOCUS report.

    -

    A graphical representation of the confidence intervals can finally be obtained.

    -
    mkinparplot(m.Z.mkin.5a)
    -

    -

    The endpoints obtained with this model are

    -
    endpoints(m.Z.mkin.5a)
    -
    ## $ff
    -##   Z0_free_Z1        Z1_Z2      Z2_sink   Z2_Z3_free Z3_free_sink 
    -##      1.00000      1.00000      0.46344      0.53656      1.00000 
    -## 
    -## $SFORB
    -##     Z0_b1     Z0_b2     Z3_b1     Z3_b2 
    -## 2.4471382 0.0075127 0.0800075 0.0000000 
    -## 
    -## $distimes
    -##      DT50   DT90 DT50_Z0_b1 DT50_Z0_b2 DT50_Z3_b1 DT50_Z3_b2
    -## Z0 0.3043 1.1848    0.28325     92.264         NA         NA
    -## Z1 1.5148 5.0320         NA         NA         NA         NA
    -## Z2 1.6414 5.4526         NA         NA         NA         NA
    -## Z3     NA     NA         NA         NA     8.6635        Inf
    -

    It is clear the degradation rate of Z3 towards the end of the experiment is very low as DT50_Z3_b2 (the second Eigenvalue of the system of two differential equations representing the SFORB system for Z3, corresponding to the slower rate constant of the DFOP model) is reported to be infinity. However, this appears to be a feature of the data.

    -
    -
    -

    References

    - -
    -
    -

    FOCUS Work Group on Degradation Kinetics. 2014. Generic Guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in Eu Registration. 1.1 ed. http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics.

    -
    -
    -
    - - - -
    -
    - -
    - - - - - - - - diff --git a/vignettes/FOCUS_Z.pdf b/vignettes/FOCUS_Z.pdf deleted file mode 100644 index 975ad17f..00000000 Binary files a/vignettes/FOCUS_Z.pdf and /dev/null differ diff --git a/vignettes/compiled_models.Rmd b/vignettes/compiled_models.Rmd deleted file mode 100644 index b16dfea6..00000000 --- a/vignettes/compiled_models.Rmd +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: "Performance benefit by using compiled model definitions in mkin" -author: "Johannes Ranke" -output: rmarkdown::html_vignette -date: "`r Sys.Date()`" -vignette: > - %\VignetteIndexEntry{Performance benefit by using compiled model definitions in mkin} - %\VignetteEngine{knitr::rmarkdown} - %\VignetteEncoding{UTF-8} ---- - -```{r, include = FALSE} -library(knitr) -opts_chunk$set(tidy = FALSE, cache = FALSE) -``` - -## Model that can also be solved with Eigenvalues - -This evaluation is taken from the example section of mkinfit. When using an mkin version -equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see -a message that the model is being compiled from autogenerated C code when -defining a model using mkinmod. The `mkinmod()` function checks for presence of -the gcc compiler using - -```{r check_gcc} -Sys.which("gcc") -``` -First, we build a simple degradation model for a parent compound with one metabolite. - -```{r create_SFO_SFO} -library("mkin", quietly = TRUE) -SFO_SFO <- mkinmod( - parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO")) -``` - -We can compare the performance of the Eigenvalue based solution against the -compiled version and the R implementation of the differential equations using -the benchmark package. - - -```{r benchmark_SFO_SFO, fig.height = 3} -if (require(rbenchmark)) { - b.1 <- benchmark( - "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, - solution_type = "eigen", quiet = TRUE), - "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, - solution_type = "deSolve", quiet = TRUE), - replications = 3) - print(b.1) - factor_SFO_SFO <- round(b.1["1", "relative"]) -} else { - factor_SFO_SFO <- NA - print("R package benchmark is not available") -} -``` - -We see that using the compiled model is by a factor of around -`r factor_SFO_SFO` -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. - - -## Model that can not be solved with Eigenvalues - -This evaluation is also taken from the example section of mkinfit. - -```{r benchmark_FOMC_SFO, fig.height = 3} -if (require(rbenchmark)) { - FOMC_SFO <- mkinmod( - parent = mkinsub("FOMC", "m1"), - m1 = mkinsub( "SFO")) - - b.2 <- benchmark( - "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, - use_compiled = FALSE, quiet = TRUE), - "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE), - replications = 3) - print(b.2) - factor_FOMC_SFO <- round(b.2["1", "relative"]) -} else { - factor_FOMC_SFO <- NA - print("R package benchmark is not available") -} -``` - -Here we get a performance benefit of a factor of -`r factor_FOMC_SFO` -using the version of the differential equation model compiled from C code! - -This vignette was built with mkin `r utils::packageVersion("mkin")` on - -```{r sessionInfo, echo = FALSE} -cat(utils::capture.output(utils::sessionInfo())[1:3], sep = "\n") -if(!inherits(try(cpuinfo <- readLines("/proc/cpuinfo")), "try-error")) { - cat(gsub("model name\t: ", "CPU model: ", cpuinfo[grep("model name", cpuinfo)[1]])) -} -``` diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html deleted file mode 100644 index 81bff548..00000000 --- a/vignettes/compiled_models.html +++ /dev/null @@ -1,164 +0,0 @@ - - - - - - - - - - - - - - - - -Performance benefit by using compiled model definitions in mkin - - - - - - - - - - - - - - - - - -

    Performance benefit by using compiled model definitions in mkin

    -

    Johannes Ranke

    -

    2018-07-17

    - - - -
    -

    Model that can also be solved with Eigenvalues

    -

    This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The mkinmod() function checks for presence of the gcc compiler using

    -
    Sys.which("gcc")
    -
    ##            gcc 
    -## "/usr/bin/gcc"
    -

    First, we build a simple degradation model for a parent compound with one metabolite.

    -
    library("mkin", quietly = TRUE)
    -SFO_SFO <- mkinmod(
    -  parent = mkinsub("SFO", "m1"),
    -  m1 = mkinsub("SFO"))
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -

    We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package.

    -
    if (require(rbenchmark)) {
    -  b.1 <- benchmark(
    -    "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,
    -                                 solution_type = "eigen", quiet = TRUE),
    -    "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
    -                                  solution_type = "deSolve", quiet = TRUE),
    -    replications = 3)
    -  print(b.1)
    -  factor_SFO_SFO <- round(b.1["1", "relative"])
    -} else {
    -  factor_SFO_SFO <- NA
    -  print("R package benchmark is not available")
    -}
    -
    ## Loading required package: rbenchmark
    -
    ##                    test replications elapsed relative user.self sys.self
    -## 3     deSolve, compiled            3   2.116    1.000     2.115        0
    -## 1 deSolve, not compiled            3  16.563    7.828    16.555        0
    -## 2      Eigenvalue based            3   2.599    1.228     2.597        0
    -##   user.child sys.child
    -## 3          0         0
    -## 1          0         0
    -## 2          0         0
    -

    We see that using the compiled model is by a factor of around 8 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.

    -
    -
    -

    Model that can not be solved with Eigenvalues

    -

    This evaluation is also taken from the example section of mkinfit.

    -
    if (require(rbenchmark)) {
    -  FOMC_SFO <- mkinmod(
    -    parent = mkinsub("FOMC", "m1"),
    -    m1 = mkinsub( "SFO"))
    -
    -  b.2 <- benchmark(
    -    "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D,
    -                                      use_compiled = FALSE, quiet = TRUE),
    -    "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
    -    replications = 3)
    -  print(b.2)
    -  factor_FOMC_SFO <- round(b.2["1", "relative"])
    -} else {
    -  factor_FOMC_SFO <- NA
    -  print("R package benchmark is not available")
    -}
    -
    ## Successfully compiled differential equation model from auto-generated C code.
    -
    ##                    test replications elapsed relative user.self sys.self
    -## 2     deSolve, compiled            3   3.809    1.000     3.806        0
    -## 1 deSolve, not compiled            3  35.885    9.421    35.866        0
    -##   user.child sys.child
    -## 2          0         0
    -## 1          0         0
    -

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

    -

    This vignette was built with mkin 0.9.47.1 on

    -
    ## R version 3.5.1 (2018-07-02)
    -## Platform: x86_64-pc-linux-gnu (64-bit)
    -## Running under: Debian GNU/Linux 9 (stretch)
    -
    ## CPU model: AMD Ryzen 7 1700 Eight-Core Processor
    -
    - - - - - - - - diff --git a/vignettes/web_only/FOCUS_Z.Rmd b/vignettes/web_only/FOCUS_Z.Rmd new file mode 100644 index 00000000..2da7fde7 --- /dev/null +++ b/vignettes/web_only/FOCUS_Z.Rmd @@ -0,0 +1,255 @@ +--- +title: Example evaluation of FOCUS dataset Z +author: Johannes Ranke +date: "`r Sys.Date()`" +output: + html_document: + toc: true + toc_float: true + code_folding: show + fig_retina: null +bibliography: ../references.bib +vignette: > + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +[Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany](http://www.jrwb.de)
    +[Privatdozent at the University of Bremen](http://chem.uft.uni-bremen.de/ranke) + +```{r, include = FALSE} +require(knitr) +options(digits = 5) +opts_chunk$set(engine='R', tidy = FALSE) +``` + +# The data + +The following code defines the example dataset from Appendix 7 to the FOCUS kinetics +report [@FOCUSkinetics2014, p. 354]. + +```{r, echo = TRUE, fig = TRUE, fig.width = 8, fig.height = 7} +library(mkin, quietly = TRUE) +LOD = 0.5 +FOCUS_2006_Z = data.frame( + t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21, + 42, 61, 96, 124), + Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8, + 2.9, 3.5, 5.3, 4.4, 1.2, 0.7), + Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1, + 1.6, 0.6, 0.5 * LOD, NA, NA, NA), + Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5, + 0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA), + Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5, + 25.2, 17.2, 4.8, 4.5, 2.8, 4.4)) + +FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z) +``` + +# Parent and one metabolite + +The next step is to set up the models used for the kinetic analysis. As the +simultaneous fit of parent and the first metabolite is usually straightforward, +Step 1 (SFO for parent only) is skipped here. We start with the model 2a, +with formation and decline of metabolite Z1 and the pathway from parent +directly to sink included (default in mkin). + +```{r FOCUS_2006_Z_fits_1, echo=TRUE, fig.height=6} +Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"), + Z1 = mkinsub("SFO")) +m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.2a) +summary(m.Z.2a, data = FALSE)$bpar +``` + +As obvious from the parameter summary (the \texttt{bpar} component of the +summary), the kinetic rate constant from parent compound Z to sink +is very small and the t-test for this parameter suggests that it is +not significantly different from zero. This suggests, in agreement with the +analysis in the FOCUS kinetics report, to simplify the model by removing the +pathway to sink. + +A similar result can be obtained when formation fractions are used in the model +formulation: + +```{r FOCUS_2006_Z_fits_2, echo=TRUE, fig.height=6} +Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"), + Z1 = mkinsub("SFO"), + use_of_ff = "max") + +m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.2a.ff) +summary(m.Z.2a.ff, data = FALSE)$bpar +``` + +Here, the ilr transformed formation fraction fitted in the model takes a very +large value, and the backtransformed formation fraction from parent Z to Z1 is +practically unity. Here, the covariance matrix used for the calculation +of confidence intervals is not returned as the model is +overparameterised. + +A simplified model is obtained by removing the pathway to the sink. +\footnote{If the model formulation without formation fractions +is used, the same effect can be obtained by fixing the parameter \texttt{k\_Z\_sink} +to a value of zero.} + +In the following, we use the parameterisation with formation fractions in order +to be able to compare with the results in the FOCUS guidance, and as it +makes it easier to use parameters obtained in a previous fit when adding a further +metabolite. + +```{r FOCUS_2006_Z_fits_3, echo=TRUE, fig.height=6} +Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO"), use_of_ff = "max") +m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.3) +summary(m.Z.3, data = FALSE)$bpar +``` + +As there is only one transformation product for Z0 and no pathway +to sink, the formation fraction is internally fixed to unity. + +# Metabolites Z2 and Z3 + +As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as +well in the next step. While this step appears questionable on the basis of the above results, it +is followed here for the purpose of comparison. Also, in the FOCUS report, it is +assumed that there is additional empirical evidence that Z1 quickly and exclusively +hydrolyses to Z2. + +```{r FOCUS_2006_Z_fits_5, echo=TRUE, fig.height=7} +Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO"), use_of_ff = "max") +m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.5) +``` + +Finally, metabolite Z3 is added to the model. We use the optimised +differential equation parameter values from the previous fit in order to +accelerate the optimization. + +```{r FOCUS_2006_Z_fits_6, echo=TRUE, fig.height=8} +Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFO"), + use_of_ff = "max") +m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, + parms.ini = m.Z.5$bparms.ode, + quiet = TRUE) +plot_sep(m.Z.FOCUS) +summary(m.Z.FOCUS, data = FALSE)$bpar +endpoints(m.Z.FOCUS) +``` + +This fit corresponds to the final result chosen in Appendix 7 of the FOCUS +report. Confidence intervals returned by mkin are based on internally +transformed parameters, however. + +# Using the SFORB model + +As the FOCUS report states, there is a certain tailing of the time course of metabolite +Z3. Also, the time course of the parent compound is not fitted very well using the +SFO model, as residues at a certain low level remain. + +Therefore, an additional model is offered here, using the single first-order +reversible binding (SFORB) model for metabolite Z3. As expected, the $\chi^2$ +error level is lower for metabolite Z3 using this model and the graphical +fit for Z3 is improved. However, the covariance matrix is not returned. + +```{r FOCUS_2006_Z_fits_7, echo=TRUE, fig.height=8} +Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFORB")) +m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.mkin.1) +summary(m.Z.mkin.1, data = FALSE)$cov.unscaled +``` + +Therefore, a further stepwise model building is performed starting from the +stage of parent and two metabolites, starting from the assumption that the model +fit for the parent compound can be improved by using the SFORB model. + +```{r FOCUS_2006_Z_fits_9, echo=TRUE, fig.height=8} +Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO")) +m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE) +plot_sep(m.Z.mkin.3) +``` + +This results in a much better representation of the behaviour of the parent +compound Z0. + +Finally, Z3 is added as well. These models appear overparameterised (no +covariance matrix returned) if the sink for Z1 is left in the models. + +```{r FOCUS_2006_Z_fits_10, echo=TRUE, fig.height=8} +Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFO")) +m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin, + parms.ini = m.Z.mkin.3$bparms.ode, + quiet = TRUE) +plot_sep(m.Z.mkin.4) +``` + +The error level of the fit, but especially of metabolite Z3, can be improved if +the SFORB model is chosen for this metabolite, as this model is capable of +representing the tailing of the metabolite decline phase. + +```{r FOCUS_2006_Z_fits_11, echo=TRUE, fig.height=8} +Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE), + Z1 = mkinsub("SFO", "Z2", sink = FALSE), + Z2 = mkinsub("SFO", "Z3"), + Z3 = mkinsub("SFORB")) +m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, + parms.ini = m.Z.mkin.4$bparms.ode[1:4], + quiet = TRUE) +plot_sep(m.Z.mkin.5) +``` + +The summary view of the backtransformed parameters shows that we get no +confidence intervals due to overparameterisation. As the optimized +\texttt{k\_Z3\_bound\_free} is excessively small, it seems reasonable to fix it to +zero. + +```{r FOCUS_2006_Z_fits_11a, echo=TRUE} +m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin, + parms.ini = c(m.Z.mkin.5$bparms.ode[1:7], + k_Z3_bound_free = 0), + fixed_parms = "k_Z3_bound_free", + quiet = TRUE) +plot_sep(m.Z.mkin.5a) +``` + +As expected, the residual plots for Z0 and Z3 are more random than in the case of the +all SFO model for which they were shown above. In conclusion, the model +\texttt{Z.mkin.5a} is proposed as the best-fit model for the dataset from +Appendix 7 of the FOCUS report. + +A graphical representation of the confidence intervals can finally be obtained. + +```{r FOCUS_2006_Z_fits_11b, echo=TRUE} +mkinparplot(m.Z.mkin.5a) +``` + +The endpoints obtained with this model are + +```{r FOCUS_2006_Z_fits_11b_endpoints, echo=TRUE} +endpoints(m.Z.mkin.5a) +``` + +It is clear the degradation rate of Z3 towards the end of the experiment +is very low as DT50\_Z3\_b2 (the second Eigenvalue of the system of two differential +equations representing the SFORB system for Z3, corresponding to the slower rate +constant of the DFOP model) is reported to be infinity. However, this appears +to be a feature of the data. + + +# References + + diff --git a/vignettes/web_only/FOCUS_Z.html b/vignettes/web_only/FOCUS_Z.html new file mode 100644 index 00000000..d7f0f88c --- /dev/null +++ b/vignettes/web_only/FOCUS_Z.html @@ -0,0 +1,1786 @@ + + + + + + + + + + + + + + + +Example evaluation of FOCUS dataset Z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + +
    + + + + + + + +

    Wissenschaftlicher Berater, Kronacher Str. 12, 79639 Grenzach-Wyhlen, Germany
    Privatdozent at the University of Bremen

    +
    +

    The data

    +

    The following code defines the example dataset from Appendix 7 to the FOCUS kinetics report (FOCUS Work Group on Degradation Kinetics 2014, 354).

    +
    library(mkin, quietly = TRUE)
    +LOD = 0.5
    +FOCUS_2006_Z = data.frame(
    +  t = c(0, 0.04, 0.125, 0.29, 0.54, 1, 2, 3, 4, 7, 10, 14, 21,
    +        42, 61, 96, 124),
    +  Z0 = c(100, 81.7, 70.4, 51.1, 41.2, 6.6, 4.6, 3.9, 4.6, 4.3, 6.8,
    +         2.9, 3.5, 5.3, 4.4, 1.2, 0.7),
    +  Z1 = c(0, 18.3, 29.6, 46.3, 55.1, 65.7, 39.1, 36, 15.3, 5.6, 1.1,
    +         1.6, 0.6, 0.5 * LOD, NA, NA, NA),
    +  Z2 = c(0, NA, 0.5 * LOD, 2.6, 3.8, 15.3, 37.2, 31.7, 35.6, 14.5,
    +         0.8, 2.1, 1.9, 0.5 * LOD, NA, NA, NA),
    +  Z3 = c(0, NA, NA, NA, NA, 0.5 * LOD, 9.2, 13.1, 22.3, 28.4, 32.5,
    +         25.2, 17.2, 4.8, 4.5, 2.8, 4.4))
    +
    +FOCUS_2006_Z_mkin <- mkin_wide_to_long(FOCUS_2006_Z)
    +
    +
    +

    Parent and one metabolite

    +

    The next step is to set up the models used for the kinetic analysis. As the simultaneous fit of parent and the first metabolite is usually straightforward, Step 1 (SFO for parent only) is skipped here. We start with the model 2a, with formation and decline of metabolite Z1 and the pathway from parent directly to sink included (default in mkin).

    +
    Z.2a <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
    +                Z1 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.2a <- mkinfit(Z.2a, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.2a)
    +

    +
    summary(m.Z.2a, data = FALSE)$bpar
    +
    ##             Estimate se_notrans    t value     Pr(>t) Lower Upper
    +## Z0_0      9.7015e+01   3.553140 2.7304e+01 1.6793e-21    NA    NA
    +## k_Z0_sink 1.2790e-11   0.226895 5.6368e-11 5.0000e-01    NA    NA
    +## k_Z0_Z1   2.2360e+00   0.165073 1.3546e+01 7.3938e-14    NA    NA
    +## k_Z1_sink 4.8212e-01   0.065854 7.3212e+00 3.5520e-08    NA    NA
    +

    As obvious from the parameter summary (the component of the summary), the kinetic rate constant from parent compound Z to sink is very small and the t-test for this parameter suggests that it is not significantly different from zero. This suggests, in agreement with the analysis in the FOCUS kinetics report, to simplify the model by removing the pathway to sink.

    +

    A similar result can be obtained when formation fractions are used in the model formulation:

    +
    Z.2a.ff <- mkinmod(Z0 = mkinsub("SFO", "Z1"),
    +                   Z1 = mkinsub("SFO"),
    +                   use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.2a.ff <- mkinfit(Z.2a.ff, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.2a.ff)
    +

    +
    summary(m.Z.2a.ff, data = FALSE)$bpar
    +
    ##            Estimate se_notrans t value     Pr(>t) Lower Upper
    +## Z0_0       97.01488   3.553145 27.3039 1.6793e-21    NA    NA
    +## k_Z0        2.23601   0.216849 10.3114 3.6623e-11    NA    NA
    +## k_Z1        0.48212   0.065854  7.3211 3.5520e-08    NA    NA
    +## f_Z0_to_Z1  1.00000   0.101473  9.8548 9.7068e-11    NA    NA
    +

    Here, the ilr transformed formation fraction fitted in the model takes a very large value, and the backtransformed formation fraction from parent Z to Z1 is practically unity. Here, the covariance matrix used for the calculation of confidence intervals is not returned as the model is overparameterised.

    +

    A simplified model is obtained by removing the pathway to the sink.

    +

    In the following, we use the parameterisation with formation fractions in order to be able to compare with the results in the FOCUS guidance, and as it makes it easier to use parameters obtained in a previous fit when adding a further metabolite.

    +
    Z.3 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +               Z1 = mkinsub("SFO"), use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.3 <- mkinfit(Z.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.3)
    +

    +
    summary(m.Z.3, data = FALSE)$bpar
    +
    ##      Estimate se_notrans t value     Pr(>t)    Lower   Upper
    +## Z0_0 97.01488   2.681772  36.176 2.3636e-25 91.52152 102.508
    +## k_Z0  2.23601   0.146861  15.225 2.2464e-15  1.95453   2.558
    +## k_Z1  0.48212   0.042687  11.294 3.0686e-12  0.40216   0.578
    +

    As there is only one transformation product for Z0 and no pathway to sink, the formation fraction is internally fixed to unity.

    +
    +
    +

    Metabolites Z2 and Z3

    +

    As suggested in the FOCUS report, the pathway to sink was removed for metabolite Z1 as well in the next step. While this step appears questionable on the basis of the above results, it is followed here for the purpose of comparison. Also, in the FOCUS report, it is assumed that there is additional empirical evidence that Z1 quickly and exclusively hydrolyses to Z2.

    +
    Z.5 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +               Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +               Z2 = mkinsub("SFO"), use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.5 <- mkinfit(Z.5, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.5)
    +

    +

    Finally, metabolite Z3 is added to the model. We use the optimised differential equation parameter values from the previous fit in order to accelerate the optimization.

    +
    Z.FOCUS <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +                   Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                   Z2 = mkinsub("SFO", "Z3"),
    +                   Z3 = mkinsub("SFO"),
    +                   use_of_ff = "max")
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.FOCUS <- mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin,
    +                     parms.ini = m.Z.5$bparms.ode,
    +                     quiet = TRUE)
    +
    ## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, : Optimisation by method Port did not converge:
    +## false convergence (8)
    +
    plot_sep(m.Z.FOCUS)
    +

    +
    summary(m.Z.FOCUS, data = FALSE)$bpar
    +
    ##             Estimate se_notrans t value     Pr(>t)     Lower      Upper
    +## Z0_0       96.837112   2.058861 47.0343 5.5877e-44 92.703779 100.970445
    +## k_Z0        2.215368   0.118098 18.7587 7.6563e-25  1.990525   2.465609
    +## k_Z1        0.478302   0.029289 16.3302 3.3408e-22  0.422977   0.540864
    +## k_Z2        0.451617   0.044214 10.2144 3.1133e-14  0.371034   0.549702
    +## k_Z3        0.058693   0.014296  4.1056 7.2924e-05  0.035994   0.095705
    +## f_Z2_to_Z3  0.471516   0.057057  8.2639 2.8156e-11  0.360381   0.585548
    +
    endpoints(m.Z.FOCUS)
    +
    ## $ff
    +##   Z2_Z3 Z2_sink 
    +## 0.47152 0.52848 
    +## 
    +## $SFORB
    +## logical(0)
    +## 
    +## $distimes
    +##        DT50    DT90
    +## Z0  0.31288  1.0394
    +## Z1  1.44918  4.8141
    +## Z2  1.53481  5.0985
    +## Z3 11.80973 39.2311
    +

    This fit corresponds to the final result chosen in Appendix 7 of the FOCUS report. Confidence intervals returned by mkin are based on internally transformed parameters, however.

    +
    +
    +

    Using the SFORB model

    +

    As the FOCUS report states, there is a certain tailing of the time course of metabolite Z3. Also, the time course of the parent compound is not fitted very well using the SFO model, as residues at a certain low level remain.

    +

    Therefore, an additional model is offered here, using the single first-order reversible binding (SFORB) model for metabolite Z3. As expected, the \(\chi^2\) error level is lower for metabolite Z3 using this model and the graphical fit for Z3 is improved. However, the covariance matrix is not returned.

    +
    Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFORB"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.mkin.1)
    +

    +
    summary(m.Z.mkin.1, data = FALSE)$cov.unscaled
    +
    ## NULL
    +

    Therefore, a further stepwise model building is performed starting from the stage of parent and two metabolites, starting from the assumption that the model fit for the parent compound can be improved by using the SFORB model.

    +
    Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
    +plot_sep(m.Z.mkin.3)
    +

    +

    This results in a much better representation of the behaviour of the parent compound Z0.

    +

    Finally, Z3 is added as well. These models appear overparameterised (no covariance matrix returned) if the sink for Z1 is left in the models.

    +
    Z.mkin.4 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.4 <- mkinfit(Z.mkin.4, FOCUS_2006_Z_mkin,
    +                      parms.ini = m.Z.mkin.3$bparms.ode,
    +                      quiet = TRUE)
    +plot_sep(m.Z.mkin.4)
    +

    +

    The error level of the fit, but especially of metabolite Z3, can be improved if the SFORB model is chosen for this metabolite, as this model is capable of representing the tailing of the metabolite decline phase.

    +
    Z.mkin.5 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
    +                    Z1 = mkinsub("SFO", "Z2", sink = FALSE),
    +                    Z2 = mkinsub("SFO", "Z3"),
    +                    Z3 = mkinsub("SFORB"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    m.Z.mkin.5 <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
    +                      parms.ini = m.Z.mkin.4$bparms.ode[1:4],
    +                      quiet = TRUE)
    +plot_sep(m.Z.mkin.5)
    +

    +

    The summary view of the backtransformed parameters shows that we get no confidence intervals due to overparameterisation. As the optimized is excessively small, it seems reasonable to fix it to zero.

    +
    m.Z.mkin.5a <- mkinfit(Z.mkin.5, FOCUS_2006_Z_mkin,
    +                       parms.ini = c(m.Z.mkin.5$bparms.ode[1:7],
    +                                     k_Z3_bound_free = 0),
    +                       fixed_parms = "k_Z3_bound_free",
    +                       quiet = TRUE)
    +plot_sep(m.Z.mkin.5a)
    +

    +

    As expected, the residual plots for Z0 and Z3 are more random than in the case of the all SFO model for which they were shown above. In conclusion, the model is proposed as the best-fit model for the dataset from Appendix 7 of the FOCUS report.

    +

    A graphical representation of the confidence intervals can finally be obtained.

    +
    mkinparplot(m.Z.mkin.5a)
    +

    +

    The endpoints obtained with this model are

    +
    endpoints(m.Z.mkin.5a)
    +
    ## $ff
    +##   Z0_free_Z1        Z1_Z2      Z2_sink   Z2_Z3_free Z3_free_sink 
    +##      1.00000      1.00000      0.46344      0.53656      1.00000 
    +## 
    +## $SFORB
    +##     Z0_b1     Z0_b2     Z3_b1     Z3_b2 
    +## 2.4471382 0.0075127 0.0800075 0.0000000 
    +## 
    +## $distimes
    +##      DT50   DT90 DT50_Z0_b1 DT50_Z0_b2 DT50_Z3_b1 DT50_Z3_b2
    +## Z0 0.3043 1.1848    0.28325     92.264         NA         NA
    +## Z1 1.5148 5.0320         NA         NA         NA         NA
    +## Z2 1.6414 5.4526         NA         NA         NA         NA
    +## Z3     NA     NA         NA         NA     8.6635        Inf
    +

    It is clear the degradation rate of Z3 towards the end of the experiment is very low as DT50_Z3_b2 (the second Eigenvalue of the system of two differential equations representing the SFORB system for Z3, corresponding to the slower rate constant of the DFOP model) is reported to be infinity. However, this appears to be a feature of the data.

    +
    +
    +

    References

    + +
    +
    +

    FOCUS Work Group on Degradation Kinetics. 2014. Generic Guidance for Estimating Persistence and Degradation Kinetics from Environmental Fate Studies on Pesticides in Eu Registration. 1.1 ed. http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics.

    +
    +
    +
    + + + +
    +
    + +
    + + + + + + + + diff --git a/vignettes/web_only/compiled_models.Rmd b/vignettes/web_only/compiled_models.Rmd new file mode 100644 index 00000000..ae283238 --- /dev/null +++ b/vignettes/web_only/compiled_models.Rmd @@ -0,0 +1,106 @@ +--- +title: "Performance benefit by using compiled model definitions in mkin" +author: "Johannes Ranke" +output: + html_document: + toc: true + toc_float: true + code_folding: show + fig_retina: null +date: "`r Sys.Date()`" +vignette: > + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} +--- + +```{r, include = FALSE} +library(knitr) +opts_chunk$set(tidy = FALSE, cache = FALSE) +``` + +## Model that can also be solved with Eigenvalues + +This evaluation is taken from the example section of mkinfit. When using an mkin version +equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see +a message that the model is being compiled from autogenerated C code when +defining a model using mkinmod. The `mkinmod()` function checks for presence of +the gcc compiler using + +```{r check_gcc} +Sys.which("gcc") +``` +First, we build a simple degradation model for a parent compound with one metabolite. + +```{r create_SFO_SFO} +library("mkin", quietly = TRUE) +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO")) +``` + +We can compare the performance of the Eigenvalue based solution against the +compiled version and the R implementation of the differential equations using +the benchmark package. + + +```{r benchmark_SFO_SFO, fig.height = 3} +if (require(rbenchmark)) { + b.1 <- benchmark( + "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, + solution_type = "eigen", quiet = TRUE), + "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D, + solution_type = "deSolve", quiet = TRUE), + replications = 3) + print(b.1) + factor_SFO_SFO <- round(b.1["1", "relative"]) +} else { + factor_SFO_SFO <- NA + print("R package benchmark is not available") +} +``` + +We see that using the compiled model is by a factor of around +`r factor_SFO_SFO` +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. + + +## Model that can not be solved with Eigenvalues + +This evaluation is also taken from the example section of mkinfit. + +```{r benchmark_FOMC_SFO, fig.height = 3} +if (require(rbenchmark)) { + FOMC_SFO <- mkinmod( + parent = mkinsub("FOMC", "m1"), + m1 = mkinsub( "SFO")) + + b.2 <- benchmark( + "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, + use_compiled = FALSE, quiet = TRUE), + "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE), + replications = 3) + print(b.2) + factor_FOMC_SFO <- round(b.2["1", "relative"]) +} else { + factor_FOMC_SFO <- NA + print("R package benchmark is not available") +} +``` + +Here we get a performance benefit of a factor of +`r factor_FOMC_SFO` +using the version of the differential equation model compiled from C code! + +This vignette was built with mkin `r utils::packageVersion("mkin")` on + +```{r sessionInfo, echo = FALSE} +cat(utils::capture.output(utils::sessionInfo())[1:3], sep = "\n") +if(!inherits(try(cpuinfo <- readLines("/proc/cpuinfo")), "try-error")) { + cat(gsub("model name\t: ", "CPU model: ", cpuinfo[grep("model name", cpuinfo)[1]])) +} +``` diff --git a/vignettes/web_only/compiled_models.html b/vignettes/web_only/compiled_models.html new file mode 100644 index 00000000..8b4f3955 --- /dev/null +++ b/vignettes/web_only/compiled_models.html @@ -0,0 +1,1661 @@ + + + + + + + + + + + + + + + +Performance benefit by using compiled model definitions in mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + +
    + + + + + + + +
    +

    Model that can also be solved with Eigenvalues

    +

    This evaluation is taken from the example section of mkinfit. When using an mkin version equal to or greater than 0.9-36 and a C compiler (gcc) is available, you will see a message that the model is being compiled from autogenerated C code when defining a model using mkinmod. The mkinmod() function checks for presence of the gcc compiler using

    +
    Sys.which("gcc")
    +
    ##            gcc 
    +## "/usr/bin/gcc"
    +

    First, we build a simple degradation model for a parent compound with one metabolite.

    +
    library("mkin", quietly = TRUE)
    +SFO_SFO <- mkinmod(
    +  parent = mkinsub("SFO", "m1"),
    +  m1 = mkinsub("SFO"))
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +

    We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package.

    +
    if (require(rbenchmark)) {
    +  b.1 <- benchmark(
    +    "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,
    +                                 solution_type = "eigen", quiet = TRUE),
    +    "deSolve, compiled" = mkinfit(SFO_SFO, FOCUS_2006_D,
    +                                  solution_type = "deSolve", quiet = TRUE),
    +    replications = 3)
    +  print(b.1)
    +  factor_SFO_SFO <- round(b.1["1", "relative"])
    +} else {
    +  factor_SFO_SFO <- NA
    +  print("R package benchmark is not available")
    +}
    +
    ## Loading required package: rbenchmark
    +
    ##                    test replications elapsed relative user.self sys.self
    +## 3     deSolve, compiled            3   2.180    1.000     2.179        0
    +## 1 deSolve, not compiled            3  16.710    7.665    16.702        0
    +## 2      Eigenvalue based            3   2.721    1.248     2.719        0
    +##   user.child sys.child
    +## 3          0         0
    +## 1          0         0
    +## 2          0         0
    +

    We see that using the compiled model is by a factor of around 8 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.

    +
    +
    +

    Model that can not be solved with Eigenvalues

    +

    This evaluation is also taken from the example section of mkinfit.

    +
    if (require(rbenchmark)) {
    +  FOMC_SFO <- mkinmod(
    +    parent = mkinsub("FOMC", "m1"),
    +    m1 = mkinsub( "SFO"))
    +
    +  b.2 <- benchmark(
    +    "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D,
    +                                      use_compiled = FALSE, quiet = TRUE),
    +    "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE),
    +    replications = 3)
    +  print(b.2)
    +  factor_FOMC_SFO <- round(b.2["1", "relative"])
    +} else {
    +  factor_FOMC_SFO <- NA
    +  print("R package benchmark is not available")
    +}
    +
    ## Successfully compiled differential equation model from auto-generated C code.
    +
    ##                    test replications elapsed relative user.self sys.self
    +## 2     deSolve, compiled            3   3.703    1.000     3.700        0
    +## 1 deSolve, not compiled            3  34.789    9.395    34.772        0
    +##   user.child sys.child
    +## 2          0         0
    +## 1          0         0
    +

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

    +

    This vignette was built with mkin 0.9.47.5 on

    +
    ## R version 3.5.1 (2018-07-02)
    +## Platform: x86_64-pc-linux-gnu (64-bit)
    +## Running under: Debian GNU/Linux 9 (stretch)
    +
    ## CPU model: AMD Ryzen 7 1700 Eight-Core Processor
    +
    + + + +
    +
    + +
    + + + + + + + + -- cgit v1.2.1