From 39b6d8b8569801c2957b22d0973b5ad0c9405e7d Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 18 Sep 2018 10:14:40 +0200 Subject: Support maximum twa for HS, test, docs --- DESCRIPTION | 2 +- NEWS.md | 4 +- R/max_twa_parent.R | 18 +++++++- build.log | 2 +- docs/articles/FOCUS_D.html | 4 +- docs/articles/FOCUS_L.html | 46 +++++++++---------- docs/articles/index.html | 2 +- docs/articles/mkin.html | 4 +- docs/articles/twa.html | 4 +- docs/articles/web_only/FOCUS_Z.html | 4 +- docs/articles/web_only/compiled_models.html | 14 +++--- docs/authors.html | 2 +- docs/index.html | 3 +- docs/news/index.html | 14 +++++- docs/reference/DFOP.solution.html | 2 +- docs/reference/Extract.mmkin.html | 16 +++---- docs/reference/FOCUS_2006_DFOP_ref_A_to_B.html | 2 +- docs/reference/FOCUS_2006_FOMC_ref_A_to_F.html | 2 +- docs/reference/FOCUS_2006_HS_ref_A_to_F.html | 2 +- docs/reference/FOCUS_2006_SFO_ref_A_to_F.html | 2 +- docs/reference/FOCUS_2006_datasets.html | 2 +- docs/reference/FOMC.solution.html | 2 +- docs/reference/HS.solution.html | 2 +- docs/reference/IORE.solution.html | 2 +- docs/reference/SFO.solution.html | 2 +- docs/reference/SFORB.solution.html | 2 +- docs/reference/add_err.html | 2 +- docs/reference/endpoints.html | 2 +- docs/reference/geometric_mean.html | 2 +- docs/reference/ilr.html | 2 +- docs/reference/index.html | 2 +- docs/reference/max_twa_parent.html | 6 +-- docs/reference/mccall81_245T.html | 18 ++++---- docs/reference/mkin_long_to_wide.html | 2 +- docs/reference/mkin_wide_to_long.html | 2 +- docs/reference/mkinds.html | 2 +- docs/reference/mkinerrmin.html | 2 +- docs/reference/mkinfit.html | 62 +++++++++++++------------- docs/reference/mkinmod.html | 4 +- docs/reference/mkinparplot.html | 2 +- docs/reference/mkinplot.html | 2 +- docs/reference/mkinpredict.html | 8 ++-- docs/reference/mkinresplot.html | 2 +- docs/reference/mkinsub.html | 2 +- docs/reference/mmkin.html | 6 +-- docs/reference/plot.mkinfit.html | 2 +- docs/reference/plot.mmkin.html | 2 +- docs/reference/print.mkinds.html | 2 +- docs/reference/print.mkinmod.html | 2 +- docs/reference/schaefer07_complex_case.html | 2 +- docs/reference/sigma_twocomp.html | 2 +- docs/reference/summary.mkinfit.html | 10 ++--- docs/reference/synthetic_data_for_UBA.html | 2 +- docs/reference/test_data_from_UBA_2014.html | 2 +- docs/reference/transform_odeparms.html | 34 +++++++------- man/max_twa_parent.Rd | 2 +- test.log | 20 +++++---- tests/testthat/test_twa.R | 42 +++++++++-------- 58 files changed, 225 insertions(+), 190 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1b5b399d..53285036 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 0.9.47.6 -Date: 2018-09-14 +Date: 2018-09-18 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", comment = c(ORCID = "0000-0003-4371-6538")), diff --git a/NEWS.md b/NEWS.md index 43146df9..780ee5ac 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,9 @@ -# mkin 0.9.47.6 (2018-09-15) +# mkin 0.9.47.6 (2018-09-18) - 'add_err': Respect the argument giving the number of replicates in the synthetic dataset +- 'max_twa_parent': Support maximum time weighted average concentration calculations for the hockey stick (HS) model + # mkin 0.9.47.5 (2018-09-14) - Make the two-component error model stop in cases where it is inadequate to avoid nls crashes on windows diff --git a/R/max_twa_parent.R b/R/max_twa_parent.R index 8d8b77f8..946a9b3d 100644 --- a/R/max_twa_parent.R +++ b/R/max_twa_parent.R @@ -1,4 +1,4 @@ -# Copyright (C) 2016,2017 Johannes Ranke +# Copyright (C) 2016,2017,2018 Johannes Ranke # Contact: jranke@uni-bremen.de # This file is part of the R package mkin @@ -55,7 +55,21 @@ max_twa_parent <- function(fit, windows) { M0/t * ((g/k1) * (1 - exp(- k1 * t)) + ((1 - g)/k2) * (1 - exp(- k2 * t))) } } - if (type %in% c("HS", "IORE", "SFORB")) { + if (type == "HS") { + k1 <- parms.all["k1"] + k2 <- parms.all["k2"] + tb <- parms.all["tb"] + twafunc <- function(t) { + ifelse(t <= tb, + M0 * (1 - exp(- k1 * t)) / (k1 * t), + (M0 / t) * ( + (1/k1) * (1 - exp(- k1 * tb)) + + (exp(- k1 * tb) / k2) * (1 - exp(- k2 * (t - tb))) + ) + ) + } + } + if (type %in% c("IORE", "SFORB")) { stop("Calculation of maximum time weighted average concentrations is currently ", "not implemented for the ", type, " model.") } diff --git a/build.log b/build.log index ca1c6f50..79c00855 100644 --- a/build.log +++ b/build.log @@ -6,5 +6,5 @@ * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories * looking to see if a ‘data/datalist’ file should be added -* building ‘mkin_0.9.47.5.tar.gz’ +* building ‘mkin_0.9.47.6.tar.gz’ diff --git a/docs/articles/FOCUS_D.html b/docs/articles/FOCUS_D.html index a90cb7fb..b44462aa 100644 --- a/docs/articles/FOCUS_D.html +++ b/docs/articles/FOCUS_D.html @@ -29,7 +29,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -84,7 +84,7 @@

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

2018-09-14

+

2018-09-18

diff --git a/docs/articles/FOCUS_L.html b/docs/articles/FOCUS_L.html index 2a99a609..8ef55b81 100644 --- a/docs/articles/FOCUS_L.html +++ b/docs/articles/FOCUS_L.html @@ -29,7 +29,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -84,7 +84,7 @@

Example evaluation of FOCUS Laboratory Data L1 to L3

Johannes Ranke

-

2018-09-14

+

2018-09-18

@@ -110,15 +110,15 @@ summary(m.L1.SFO)
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:22 2018 
-## Date of summary: Fri Sep 14 21:00:22 2018 
+## Date of fit:     Tue Sep 18 09:50:45 2018 
+## Date of summary: Tue Sep 18 09:50:45 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.087 s
+## Fitted with method Port using 37 model solutions performed in 0.081 s
 ## 
 ## Weighting: none
 ## 
@@ -201,15 +201,15 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:23 2018 
-## Date of summary: Fri Sep 14 21:00:23 2018 
+## Date of fit:     Tue Sep 18 09:50:47 2018 
+## Date of summary: Tue Sep 18 09:50:47 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.352 s
+## Fitted with method Port using 611 model solutions performed in 1.294 s
 ## 
 ## Weighting: none
 ## 
@@ -296,15 +296,15 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:24 2018 
-## Date of summary: Fri Sep 14 21:00:24 2018 
+## Date of fit:     Tue Sep 18 09:50:47 2018 
+## Date of summary: Tue Sep 18 09:50:47 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.175 s
+## Fitted with method Port using 81 model solutions performed in 0.166 s
 ## 
 ## Weighting: none
 ## 
@@ -367,8 +367,8 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:25 2018 
-## Date of summary: Fri Sep 14 21:00:25 2018 
+## Date of fit:     Tue Sep 18 09:50:48 2018 
+## Date of summary: Tue Sep 18 09:50:48 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.758 s
+## Fitted with method Port using 336 model solutions performed in 0.714 s
 ## 
 ## Weighting: none
 ## 
@@ -459,8 +459,8 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:26 2018 
-## Date of summary: Fri Sep 14 21:00:26 2018 
+## Date of fit:     Tue Sep 18 09:50:49 2018 
+## Date of summary: Tue Sep 18 09:50:49 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.31 s
+## Fitted with method Port using 137 model solutions performed in 0.299 s
 ## 
 ## Weighting: none
 ## 
@@ -560,15 +560,15 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:26 2018 
-## Date of summary: Fri Sep 14 21:00:27 2018 
+## Date of fit:     Tue Sep 18 09:50:50 2018 
+## Date of summary: Tue Sep 18 09:50:50 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.102 s
+## Fitted with method Port using 46 model solutions performed in 0.093 s
 ## 
 ## Weighting: none
 ## 
@@ -620,15 +620,15 @@
 
 
## mkin version used for fitting:    0.9.47.5 
 ## R version used for fitting:       3.5.1 
-## Date of fit:     Fri Sep 14 21:00:26 2018 
-## Date of summary: Fri Sep 14 21:00:27 2018 
+## Date of fit:     Tue Sep 18 09:50:50 2018 
+## Date of summary: Tue Sep 18 09:50:50 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.151 s
+## Fitted with method Port using 66 model solutions performed in 0.138 s
 ## 
 ## Weighting: none
 ## 
diff --git a/docs/articles/index.html b/docs/articles/index.html
index ad0ab46e..c48dfec7 100644
--- a/docs/articles/index.html
+++ b/docs/articles/index.html
@@ -58,7 +58,7 @@
       
       
         mkin
-        0.9.47.5
+        0.9.47.6
       
     
 
diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html
index 3ae09165..e483043b 100644
--- a/docs/articles/mkin.html
+++ b/docs/articles/mkin.html
@@ -29,7 +29,7 @@
       
       
         mkin
-        0.9.47.5
+        0.9.47.6
       
     
 
@@ -84,7 +84,7 @@
       

Introduction to mkin

Johannes Ranke

-

2018-09-14

+

2018-09-18

diff --git a/docs/articles/twa.html b/docs/articles/twa.html index 4d516ff1..d9249f9d 100644 --- a/docs/articles/twa.html +++ b/docs/articles/twa.html @@ -29,7 +29,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -84,7 +84,7 @@

Calculation of time weighted average concentrations with mkin

Johannes Ranke

-

2018-09-14

+

2018-09-18

diff --git a/docs/articles/web_only/FOCUS_Z.html b/docs/articles/web_only/FOCUS_Z.html index 381c9e4f..a3e743d1 100644 --- a/docs/articles/web_only/FOCUS_Z.html +++ b/docs/articles/web_only/FOCUS_Z.html @@ -29,7 +29,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -84,7 +84,7 @@

Example evaluation of FOCUS dataset Z

Johannes Ranke

-

2018-09-14

+

2018-09-18

diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html index 9aac1ab2..3b3e9150 100644 --- a/docs/articles/web_only/compiled_models.html +++ b/docs/articles/web_only/compiled_models.html @@ -29,7 +29,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -84,7 +84,7 @@

Performance benefit by using compiled model definitions in mkin

Johannes Ranke

-

2018-09-14

+

2018-09-18

@@ -125,9 +125,9 @@ }
## Lade nötiges Paket: rbenchmark
##                    test replications elapsed relative user.self sys.self
-## 3     deSolve, compiled            3   2.134    1.000     2.132        0
-## 1 deSolve, not compiled            3  16.165    7.575    16.157        0
-## 2      Eigenvalue based            3   2.597    1.217     2.595        0
+## 3     deSolve, compiled            3   2.001    1.000     1.999        0
+## 1 deSolve, not compiled            3  15.374    7.683    15.368        0
+## 2      Eigenvalue based            3   2.439    1.219     2.438        0
 ##   user.child sys.child
 ## 3          0         0
 ## 1          0         0
@@ -156,8 +156,8 @@
 }
## Successfully compiled differential equation model from auto-generated C code.
##                    test replications elapsed relative user.self sys.self
-## 2     deSolve, compiled            3   3.717    1.000     3.715        0
-## 1 deSolve, not compiled            3  34.646    9.321    34.630        0
+## 2     deSolve, compiled            3   3.608    1.000     3.607        0
+## 1 deSolve, not compiled            3  33.150    9.188    33.135        0
 ##   user.child sys.child
 ## 2          0         0
 ## 1          0         0
diff --git a/docs/authors.html b/docs/authors.html index fddc66c9..d80afb2e 100644 --- a/docs/authors.html +++ b/docs/authors.html @@ -58,7 +58,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/index.html b/docs/index.html index 60787c81..10b75279 100644 --- a/docs/index.html +++ b/docs/index.html @@ -36,7 +36,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -189,6 +189,7 @@

Dev status

  • +
  • Build Status
diff --git a/docs/news/index.html b/docs/news/index.html index 73eb7aa2..2636b8b0 100644 --- a/docs/news/index.html +++ b/docs/news/index.html @@ -58,7 +58,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -117,9 +117,18 @@ +
+

+mkin 0.9.47.6 (2018-09-18) Unreleased +

+
    +
  • ‘add_err’: Respect the argument giving the number of replicates in the synthetic dataset

  • +
  • ‘max_twa_parent’: Support maximum time weighted average concentration calculations for the hockey stick (HS) model

  • +
+

-mkin 0.9.47.5 (2018-09-14) Unreleased +mkin 0.9.47.5 (2018-09-14) 2018-09-14

  • Make the two-component error model stop in cases where it is inadequate to avoid nls crashes on windows

  • @@ -658,6 +667,7 @@

    Contents

    diff --git a/docs/reference/Extract.mmkin.html b/docs/reference/Extract.mmkin.html index 97562d44..39a8bb84 100644 --- a/docs/reference/Extract.mmkin.html +++ b/docs/reference/Extract.mmkin.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6
@@ -278,7 +278,7 @@ #> #> $time #> User System verstrichen -#> 0.177 0.000 0.176 +#> 0.161 0.000 0.162 #> #> $mkinmod #> <mkinmod> model generated with @@ -467,8 +467,8 @@ #> } #> return(mC) #> } -#> <bytecode: 0x55555bd7f230> -#> <environment: 0x55555bc85178> +#> <bytecode: 0x55555bd56848> +#> <environment: 0x55555bd53cb0> #> #> $cost_notrans #> function (P) @@ -490,8 +490,8 @@ #> scaleVar = scaleVar) #> return(mC) #> } -#> <bytecode: 0x55555ca9fca8> -#> <environment: 0x55555bc85178> +#> <bytecode: 0x55555c9bc2c0> +#> <environment: 0x55555bd53cb0> #> #> $hessian_notrans #> parent_0 k_parent_sink @@ -558,10 +558,10 @@ #> 99.17407 #> #> $date -#> [1] "Fri Sep 14 20:58:46 2018" +#> [1] "Tue Sep 18 09:49:15 2018" #> #> $version -#> [1] "0.9.47.5" +#> [1] "0.9.47.6" #> #> $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 d5354c28..6923f19a 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.5 + 0.9.47.6 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 f5c36792..90f6eb49 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.5 + 0.9.47.6 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 fb2cd7de..85a72047 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.5 + 0.9.47.6 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 dfccea5c..f2fb835b 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.5 + 0.9.47.6 diff --git a/docs/reference/FOCUS_2006_datasets.html b/docs/reference/FOCUS_2006_datasets.html index 7f89e33e..9023aee0 100644 --- a/docs/reference/FOCUS_2006_datasets.html +++ b/docs/reference/FOCUS_2006_datasets.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/FOMC.solution.html b/docs/reference/FOMC.solution.html index abda4d81..1d3e4dd3 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.5 + 0.9.47.6 diff --git a/docs/reference/HS.solution.html b/docs/reference/HS.solution.html index bb3768ba..99f537cf 100644 --- a/docs/reference/HS.solution.html +++ b/docs/reference/HS.solution.html @@ -62,7 +62,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/IORE.solution.html b/docs/reference/IORE.solution.html index d86ee0c3..8394cd52 100644 --- a/docs/reference/IORE.solution.html +++ b/docs/reference/IORE.solution.html @@ -62,7 +62,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/SFO.solution.html b/docs/reference/SFO.solution.html index 17f1920c..e123d358 100644 --- a/docs/reference/SFO.solution.html +++ b/docs/reference/SFO.solution.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/SFORB.solution.html b/docs/reference/SFORB.solution.html index 050d19cf..75449616 100644 --- a/docs/reference/SFORB.solution.html +++ b/docs/reference/SFORB.solution.html @@ -65,7 +65,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/add_err.html b/docs/reference/add_err.html index cea1e03c..db910f82 100644 --- a/docs/reference/add_err.html +++ b/docs/reference/add_err.html @@ -63,7 +63,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/endpoints.html b/docs/reference/endpoints.html index a54fb71e..6a505e9f 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.5 + 0.9.47.6 diff --git a/docs/reference/geometric_mean.html b/docs/reference/geometric_mean.html index 41ccbbfd..6e154149 100644 --- a/docs/reference/geometric_mean.html +++ b/docs/reference/geometric_mean.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/ilr.html b/docs/reference/ilr.html index 601ab1a2..722bb0e9 100644 --- a/docs/reference/ilr.html +++ b/docs/reference/ilr.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/index.html b/docs/reference/index.html index 615f6777..a7806970 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -58,7 +58,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/max_twa_parent.html b/docs/reference/max_twa_parent.html index 3a19c754..c760960f 100644 --- a/docs/reference/max_twa_parent.html +++ b/docs/reference/max_twa_parent.html @@ -34,7 +34,7 @@ @@ -65,7 +65,7 @@ guidance." /> mkin - 0.9.47.5 + 0.9.47.6 @@ -129,7 +129,7 @@ guidance." />

This function calculates maximum moving window time weighted average concentrations (TWAs) for kinetic models fitted with mkinfit. Currently, only -calculations for the parent are implemented for the SFO, FOMC and DFOP models, +calculations for the parent are implemented for the SFO, FOMC, DFOP and HS models, using the analytical formulas given in the PEC soil section of the FOCUS guidance.

diff --git a/docs/reference/mccall81_245T.html b/docs/reference/mccall81_245T.html index 52c09969..042073f2 100644 --- a/docs/reference/mccall81_245T.html +++ b/docs/reference/mccall81_245T.html @@ -63,7 +63,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -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.5 + summary(fit.1, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:58:58 2018 -#> Date of summary: Fri Sep 14 20:58:58 2018 +#> Date of fit: Tue Sep 18 09:49:26 2018 +#> Date of summary: Tue Sep 18 09:49:26 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.393 s +#> Fitted with method Port using 574 model solutions performed in 3.213 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.5 + summary(fit.2, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:58:59 2018 -#> Date of summary: Fri Sep 14 20:59:00 2018 +#> Date of fit: Tue Sep 18 09:49:27 2018 +#> Date of summary: Tue Sep 18 09:49: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.451 s +#> Fitted with method Port using 246 model solutions performed in 1.363 s #> #> Weighting: none #> diff --git a/docs/reference/mkin_long_to_wide.html b/docs/reference/mkin_long_to_wide.html index ea74ff47..36a7e0ae 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.5 + 0.9.47.6
diff --git a/docs/reference/mkin_wide_to_long.html b/docs/reference/mkin_wide_to_long.html index 369649e3..f09f5102 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.5 + 0.9.47.6 diff --git a/docs/reference/mkinds.html b/docs/reference/mkinds.html index d356fdab..357370ad 100644 --- a/docs/reference/mkinds.html +++ b/docs/reference/mkinds.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/mkinerrmin.html b/docs/reference/mkinerrmin.html index 4f70a274..dd947e65 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.5 + 0.9.47.6 diff --git a/docs/reference/mkinfit.html b/docs/reference/mkinfit.html index f3c6d595..1ae53f8a 100644 --- a/docs/reference/mkinfit.html +++ b/docs/reference/mkinfit.html @@ -71,7 +71,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -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.5 +summary(fit)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:02 2018 -#> Date of summary: Fri Sep 14 20:59:02 2018 +#> Date of fit: Tue Sep 18 09:49:30 2018 +#> Date of summary: Tue Sep 18 09:49:30 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.14 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.895 0.000 0.897
coef(fit)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.872 0.001 0.874
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.726 0.000 0.726
coef(fit.deSolve)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.690 0.000 0.689
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.5 +summary(f.noweight)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:13 2018 -#> Date of summary: Fri Sep 14 20:59:13 2018 +#> Date of fit: Tue Sep 18 09:49:40 2018 +#> Date of summary: Tue Sep 18 09:49: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.757 s +#> Fitted with method Port using 186 model solutions performed in 0.725 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.5 +summary(f.irls)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:15 2018 -#> Date of summary: Fri Sep 14 20:59:16 2018 +#> Date of fit: Tue Sep 18 09:49:42 2018 +#> Date of summary: Tue Sep 18 09:49:42 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.329 s +#> Fitted with method Port using 551 model solutions performed in 2.147 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.5 +summary(f.w.mean)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:16 2018 -#> Date of summary: Fri Sep 14 20:59:16 2018 +#> Date of fit: Tue Sep 18 09:49:43 2018 +#> Date of summary: Tue Sep 18 09:49: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.628 s +#> Fitted with method Port using 155 model solutions performed in 0.603 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.5 +summary(f.w.value)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:17 2018 -#> Date of summary: Fri Sep 14 20:59:17 2018 +#> Date of fit: Tue Sep 18 09:49:44 2018 +#> Date of summary: Tue Sep 18 09:49: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.713 s +#> Fitted with method Port using 174 model solutions performed in 0.69 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.5 +summary(f.w.man)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:18 2018 -#> Date of summary: Fri Sep 14 20:59:18 2018 +#> Date of fit: Tue Sep 18 09:49:45 2018 +#> Date of summary: Tue Sep 18 09:49: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.119 s +#> Fitted with method Port using 270 model solutions performed in 1.133 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.5 +summary(f.w.man.irls)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 20:59:21 2018 -#> Date of summary: Fri Sep 14 20:59:21 2018 +#> Date of fit: Tue Sep 18 09:49:48 2018 +#> Date of summary: Tue Sep 18 09:49:48 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.955 s +#> Fitted with method Port using 692 model solutions performed in 2.77 s #> #> Weighting: manual #> diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index 464178bc..c1e7b840 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.5 + 0.9.47.6
@@ -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 file7aee6cc2a6d.c 2> file7aee6cc2a6d.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB file73da22034c44.c 2> file73da22034c44.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: diff --git a/docs/reference/mkinparplot.html b/docs/reference/mkinparplot.html index 6ed32315..a57a439c 100644 --- a/docs/reference/mkinparplot.html +++ b/docs/reference/mkinparplot.html @@ -62,7 +62,7 @@ mkin - 0.9.47.5 + 0.9.47.6
diff --git a/docs/reference/mkinplot.html b/docs/reference/mkinplot.html index 72ff93f6..18da0660 100644 --- a/docs/reference/mkinplot.html +++ b/docs/reference/mkinplot.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index dfcd08a8..5fad64de 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -63,7 +63,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -321,17 +321,17 @@ c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "eigen")[201,]))
#> time parent m1 #> 201 20 4.978707 27.46227
#> User System verstrichen -#> 0.004 0.000 0.003
system.time( +#> 0.003 0.000 0.003
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")[201,]))
#> time parent m1 #> 201 20 4.978707 27.46227
#> User System verstrichen -#> 0.001 0.000 0.002
system.time( +#> 0.002 0.000 0.001
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 #> 201 20 4.978707 27.46227
#> User System verstrichen -#> 0.036 0.000 0.036
+#> 0.033 0.000 0.034
diff --git a/docs/reference/mkinsub.html b/docs/reference/mkinsub.html index 0a2bf41a..3f2d2f86 100644 --- a/docs/reference/mkinsub.html +++ b/docs/reference/mkinsub.html @@ -62,7 +62,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/mmkin.html b/docs/reference/mmkin.html index 383e5928..13cdedff 100644 --- a/docs/reference/mmkin.html +++ b/docs/reference/mmkin.html @@ -62,7 +62,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -189,8 +189,8 @@ time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE)) time_default
#> User System verstrichen -#> 0.056 0.024 6.712
time_1
#> User System verstrichen -#> 20.446 0.000 20.459
+#> 0.043 0.040 6.475
time_1
#> User System verstrichen +#> 19.165 0.000 19.179
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 e88c2025..c082f125 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.5 + 0.9.47.6
diff --git a/docs/reference/plot.mmkin.html b/docs/reference/plot.mmkin.html index d67d87d9..3f155473 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.5 + 0.9.47.6 diff --git a/docs/reference/print.mkinds.html b/docs/reference/print.mkinds.html index 2489269c..022efe67 100644 --- a/docs/reference/print.mkinds.html +++ b/docs/reference/print.mkinds.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/print.mkinmod.html b/docs/reference/print.mkinmod.html index b6cbad61..efa3272e 100644 --- a/docs/reference/print.mkinmod.html +++ b/docs/reference/print.mkinmod.html @@ -61,7 +61,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/schaefer07_complex_case.html b/docs/reference/schaefer07_complex_case.html index 4ceba867..b22c67fa 100644 --- a/docs/reference/schaefer07_complex_case.html +++ b/docs/reference/schaefer07_complex_case.html @@ -63,7 +63,7 @@ mkin - 0.9.47.5 + 0.9.47.6 diff --git a/docs/reference/sigma_twocomp.html b/docs/reference/sigma_twocomp.html index e74707ff..36612f18 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.5 + 0.9.47.6 diff --git a/docs/reference/summary.mkinfit.html b/docs/reference/summary.mkinfit.html index 317c7a87..0af65ed8 100644 --- a/docs/reference/summary.mkinfit.html +++ b/docs/reference/summary.mkinfit.html @@ -64,7 +64,7 @@ mkin - 0.9.47.5 + 0.9.47.6 @@ -204,17 +204,17 @@

Examples

-
summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
#> mkin version used for fitting: 0.9.47.5 +
summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 21:00:08 2018 -#> Date of summary: Fri Sep 14 21:00:08 2018 +#> Date of fit: Tue Sep 18 09:50:32 2018 +#> Date of summary: Tue Sep 18 09:50:32 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.081 s +#> Fitted with method Port using 35 model solutions performed in 0.071 s #> #> Weighting: none #> diff --git a/docs/reference/synthetic_data_for_UBA.html b/docs/reference/synthetic_data_for_UBA.html index 384d628d..94397ddf 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.5 + 0.9.47.6
diff --git a/docs/reference/test_data_from_UBA_2014.html b/docs/reference/test_data_from_UBA_2014.html index 094e003d..b8c4a76b 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.5 + 0.9.47.6
diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index 6f7ec4a4..ce6f6c8d 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.5 + 0.9.47.6 @@ -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.5 +summary(fit, data=FALSE) # See transformed and backtransformed parameters
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 21:00:16 2018 -#> Date of summary: Fri Sep 14 21:00:16 2018 +#> Date of fit: Tue Sep 18 09:50:39 2018 +#> Date of summary: Tue Sep 18 09:50:39 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.71 s +#> Fitted with method Port using 153 model solutions performed in 0.586 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.5 +summary(fit.2, data=FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 21:00:17 2018 -#> Date of summary: Fri Sep 14 21:00:17 2018 +#> Date of fit: Tue Sep 18 09:50:41 2018 +#> Date of summary: Tue Sep 18 09:50:41 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.417 s +#> Fitted with method Port using 350 model solutions performed in 1.341 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.5 +summary(fit.ff, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 21:00:18 2018 -#> Date of summary: Fri Sep 14 21:00:18 2018 +#> Date of fit: Tue Sep 18 09:50:42 2018 +#> Date of summary: Tue Sep 18 09:50:42 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.755 s +#> Fitted with method Port using 186 model solutions performed in 0.73 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.5 +summary(fit.ff.2, data = FALSE)
#> mkin version used for fitting: 0.9.47.6 #> R version used for fitting: 3.5.1 -#> Date of fit: Fri Sep 14 21:00:19 2018 -#> Date of summary: Fri Sep 14 21:00:19 2018 +#> Date of fit: Tue Sep 18 09:50:42 2018 +#> Date of summary: Tue Sep 18 09:50:42 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.416 s +#> Fitted with method Port using 104 model solutions performed in 0.401 s #> #> Weighting: none #> diff --git a/man/max_twa_parent.Rd b/man/max_twa_parent.Rd index b8c820bc..f599eb1c 100644 --- a/man/max_twa_parent.Rd +++ b/man/max_twa_parent.Rd @@ -6,7 +6,7 @@ \description{ This function calculates maximum moving window time weighted average concentrations (TWAs) for kinetic models fitted with \code{\link{mkinfit}}. Currently, only -calculations for the parent are implemented for the SFO, FOMC and DFOP models, +calculations for the parent are implemented for the SFO, FOMC, DFOP and HS models, using the analytical formulas given in the PEC soil section of the FOCUS guidance.} \usage{ diff --git a/test.log b/test.log index c4ced344..cd3ffc7c 100644 --- a/test.log +++ b/test.log @@ -2,19 +2,21 @@ 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.2 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) ⠦ | 7 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠧ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [6.5 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 [36.6 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.1 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) ⠦ | 7 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠧ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [6.1 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 [35.8 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 [22.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.5 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) [3.8 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.0 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.1 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.4 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) ⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ⠼ | 5 | Calculation of maximum time weighted average concentrations (TWAs) ⠴ | 6 | Calculation of maximum time weighted average concentrations (TWAs) ⠦ | 7 | Calculation of maximum time weighted average concentrations (TWAs) ⠧ | 8 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 8 | Calculation of maximum time weighted average concentrations (TWAs) [7.5 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 84.2 s +Duration: 85.3 s -OK: 46 +OK: 51 Failed: 0 Warnings: 0 Skipped: 0 + +Keep up the good work. diff --git a/tests/testthat/test_twa.R b/tests/testthat/test_twa.R index a84b2c4e..758c42c3 100644 --- a/tests/testthat/test_twa.R +++ b/tests/testthat/test_twa.R @@ -21,23 +21,29 @@ context("Calculation of maximum time weighted average concentrations (TWAs)") test_that("Time weighted average concentrations are correct", { skip_on_cran() - twa_models <- c("SFO", "FOMC", "DFOP") - fits <- mmkin(twa_models, list(FOCUS_D = FOCUS_2006_D), - quiet = TRUE, cores = 1) - - outtimes_7 <- seq(0, 7, length.out = 10000) - for (model in twa_models) { - fit <- fits[[model, 1]] - bpar <- summary(fit)$bpar[, "Estimate"] - pred_7 <- mkinpredict(fit$mkinmod, - odeparms = bpar[2:length(bpar)], - odeini = c(parent = bpar[[1]]), - outtimes = outtimes_7) - twa_num <- mean(pred_7$parent) - names(twa_num) <- 7 - twa_ana <- max_twa_parent(fit, 7) - - # Test for absolute difference (scale = 1) - expect_equal(twa_num, twa_ana, tolerance = 0.001, scale = 1) + twa_models <- c("SFO", "FOMC", "DFOP", "HS") + fits <- mmkin(twa_models, + list(FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), + quiet = TRUE, cores = 8) + + outtimes_10 <- seq(0, 10, length.out = 10000) + + for (ds in c("FOCUS_C", "FOCUS_D")) { + for (model in twa_models) { + fit <- fits[[model, ds]] + bpar <- summary(fit)$bpar[, "Estimate"] + pred_10 <- mkinpredict(fit$mkinmod, + odeparms = bpar[2:length(bpar)], + odeini = c(parent = bpar[[1]]), + outtimes = outtimes_10) + twa_num <- mean(pred_10$parent) + names(twa_num) <- 10 + twa_ana <- max_twa_parent(fit, 10) + + # Test for absolute difference (scale = 1) + # The tolerance can be reduced if the length of outtimes is increased, + # but this needs more computing time so we stay with lenght.out = 10k + expect_equal(twa_num, twa_ana, tolerance = 0.003, scale = 1) + } } }) -- cgit v1.2.1