From be809ea23b256f627216958fcd90489ee0844ab8 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Mon, 25 Feb 2019 14:50:13 +0100 Subject: Add plotting tests, add nafta to pkgdown --- DESCRIPTION | 5 +- _pkgdown.yml | 1 + docs/articles/FOCUS_D.html | 8 +- docs/articles/FOCUS_L.html | 44 +- docs/articles/mkin.html | 2 +- docs/articles/twa.html | 2 +- docs/articles/web_only/FOCUS_Z.html | 2 +- docs/articles/web_only/compiled_models.html | 12 +- docs/reference/Extract.mmkin.html | 12 +- docs/reference/index.html | 6 + docs/reference/mccall81_245T.html | 12 +- docs/reference/mkinfit.html | 46 +- docs/reference/mkinmod.html | 2 +- docs/reference/mkinpredict.html | 4 +- docs/reference/mmkin.html | 4 +- docs/reference/summary.mkinfit.html | 6 +- docs/reference/transform_odeparms.html | 24 +- test.log | 20 +- tests/figs/deps.txt | 3 + tests/figs/plotting/mmkin-plot-for-focus-c.svg | 569 +++++++++++++++++++++ .../plotting/mmkin-plot-for-sfo-focus-c-and-d.svg | 300 +++++++++++ tests/testthat/test_plots_twa.R | 61 +++ tests/testthat/test_twa.R | 49 -- 23 files changed, 1044 insertions(+), 150 deletions(-) create mode 100644 tests/figs/deps.txt create mode 100644 tests/figs/plotting/mmkin-plot-for-focus-c.svg create mode 100644 tests/figs/plotting/mmkin-plot-for-sfo-focus-c-and-d.svg create mode 100644 tests/testthat/test_plots_twa.R delete mode 100644 tests/testthat/test_twa.R diff --git a/DESCRIPTION b/DESCRIPTION index 138440fc..87823866 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,7 +2,7 @@ Package: mkin Type: Package Title: Kinetic Evaluation of Chemical Degradation Data Version: 0.9.48.1 -Date: 2019-02-21 +Date: 2019-02-22 Authors@R: c(person("Johannes", "Ranke", role = c("aut", "cre", "cph"), email = "jranke@uni-bremen.de", comment = c(ORCID = "0000-0003-4371-6538")), @@ -19,7 +19,8 @@ Description: Calculation routines based on the FOCUS Kinetics Report (2006, purpose. Imports: stats, graphics, methods, FME, deSolve, R6, minpack.lm, rootSolve, inline, parallel, plyr -Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr +Suggests: knitr, rbenchmark, tikzDevice, testthat, rmarkdown, covr, vdiffr +Remotes: r-lib/vdiffr License: GPL LazyLoad: yes LazyData: yes diff --git a/_pkgdown.yml b/_pkgdown.yml index 20854d5b..03305d9a 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -10,6 +10,7 @@ reference: - mkinmod - mkinfit - mmkin + - nafta - title: Show results desc: Functions working with mkinfit objects contents: diff --git a/docs/articles/FOCUS_D.html b/docs/articles/FOCUS_D.html index ad8413dc..a470cdb6 100644 --- a/docs/articles/FOCUS_D.html +++ b/docs/articles/FOCUS_D.html @@ -85,7 +85,7 @@

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

2019-02-22

+

2019-02-25

@@ -163,8 +163,8 @@
summary(fit)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:30 2019 
-## Date of summary: Fri Feb 22 20:48:31 2019 
+## Date of fit:     Mon Feb 25 14:54:38 2019 
+## Date of summary: Mon Feb 25 14:54:38 2019 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent
@@ -172,7 +172,7 @@
 ## 
 ## Model predictions using solution type deSolve 
 ## 
-## Fitted with method Port using 153 model solutions performed in 0.731 s
+## Fitted with method Port using 153 model solutions performed in 0.712 s
 ## 
 ## Weighting: none
 ## 
diff --git a/docs/articles/FOCUS_L.html b/docs/articles/FOCUS_L.html
index 17c7bf59..e8a81075 100644
--- a/docs/articles/FOCUS_L.html
+++ b/docs/articles/FOCUS_L.html
@@ -85,7 +85,7 @@
       

Example evaluation of FOCUS Laboratory Data L1 to L3

Johannes Ranke

-

2019-02-22

+

2019-02-25

@@ -111,15 +111,15 @@ summary(m.L1.SFO)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:32 2019 
-## Date of summary: Fri Feb 22 20:48:32 2019 
+## Date of fit:     Mon Feb 25 14:54:40 2019 
+## Date of summary: Mon Feb 25 14:54:40 2019 
 ## 
 ## 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.105 s
+## Fitted with method Port using 37 model solutions performed in 0.096 s
 ## 
 ## Weighting: none
 ## 
@@ -202,15 +202,15 @@
 
summary(m.L1.FOMC, data = FALSE)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:34 2019 
-## Date of summary: Fri Feb 22 20:48:34 2019 
+## Date of fit:     Mon Feb 25 14:54:42 2019 
+## Date of summary: Mon Feb 25 14:54:42 2019 
 ## 
 ## 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.604 s
+## Fitted with method Port using 611 model solutions performed in 1.529 s
 ## 
 ## Weighting: none
 ## 
@@ -297,15 +297,15 @@
 
summary(m.L2.FOMC, data = FALSE)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:35 2019 
-## Date of summary: Fri Feb 22 20:48:35 2019 
+## Date of fit:     Mon Feb 25 14:54:42 2019 
+## Date of summary: Mon Feb 25 14:54:42 2019 
 ## 
 ## 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.216 s
+## Fitted with method Port using 81 model solutions performed in 0.199 s
 ## 
 ## Weighting: none
 ## 
@@ -368,8 +368,8 @@
 
summary(m.L2.DFOP, data = FALSE)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:36 2019 
-## Date of summary: Fri Feb 22 20:48:36 2019 
+## Date of fit:     Mon Feb 25 14:54:44 2019 
+## Date of summary: Mon Feb 25 14:54:44 2019 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -378,7 +378,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 336 model solutions performed in 0.864 s
+## Fitted with method Port using 336 model solutions performed in 0.853 s
 ## 
 ## Weighting: none
 ## 
@@ -460,8 +460,8 @@
 
summary(mm.L3[["DFOP", 1]])
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:37 2019 
-## Date of summary: Fri Feb 22 20:48:38 2019 
+## Date of fit:     Mon Feb 25 14:54:45 2019 
+## Date of summary: Mon Feb 25 14:54:45 2019 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) *
@@ -470,7 +470,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 137 model solutions performed in 0.362 s
+## Fitted with method Port using 137 model solutions performed in 0.348 s
 ## 
 ## Weighting: none
 ## 
@@ -561,15 +561,15 @@
 
summary(mm.L4[["SFO", 1]], data = FALSE)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:38 2019 
-## Date of summary: Fri Feb 22 20:48:38 2019 
+## Date of fit:     Mon Feb 25 14:54:45 2019 
+## Date of summary: Mon Feb 25 14:54:45 2019 
 ## 
 ## 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.123 s
+## Fitted with method Port using 46 model solutions performed in 0.112 s
 ## 
 ## Weighting: none
 ## 
@@ -621,15 +621,15 @@
 
summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version used for fitting:    0.9.48.1 
 ## R version used for fitting:       3.5.2 
-## Date of fit:     Fri Feb 22 20:48:38 2019 
-## Date of summary: Fri Feb 22 20:48:38 2019 
+## Date of fit:     Mon Feb 25 14:54:45 2019 
+## Date of summary: Mon Feb 25 14:54:45 2019 
 ## 
 ## 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.184 s
+## Fitted with method Port using 66 model solutions performed in 0.165 s
 ## 
 ## Weighting: none
 ## 
diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html
index 9baa44e4..bffd19dd 100644
--- a/docs/articles/mkin.html
+++ b/docs/articles/mkin.html
@@ -85,7 +85,7 @@
       

Introduction to mkin

Johannes Ranke

-

2019-02-22

+

2019-02-25

diff --git a/docs/articles/twa.html b/docs/articles/twa.html index 8c340557..83b05989 100644 --- a/docs/articles/twa.html +++ b/docs/articles/twa.html @@ -85,7 +85,7 @@

Calculation of time weighted average concentrations with mkin

Johannes Ranke

-

2019-02-22

+

2019-02-25

diff --git a/docs/articles/web_only/FOCUS_Z.html b/docs/articles/web_only/FOCUS_Z.html index b1e2811c..c3ee7415 100644 --- a/docs/articles/web_only/FOCUS_Z.html +++ b/docs/articles/web_only/FOCUS_Z.html @@ -85,7 +85,7 @@

Example evaluation of FOCUS dataset Z

Johannes Ranke

-

2019-02-22

+

2019-02-25

diff --git a/docs/articles/web_only/compiled_models.html b/docs/articles/web_only/compiled_models.html index fbf2de33..4209d2bc 100644 --- a/docs/articles/web_only/compiled_models.html +++ b/docs/articles/web_only/compiled_models.html @@ -85,7 +85,7 @@

Performance benefit by using compiled model definitions in mkin

Johannes Ranke

-

2019-02-22

+

2019-02-25

@@ -126,9 +126,9 @@ }
## Lade nötiges Paket: rbenchmark
##                    test replications elapsed relative user.self sys.self
-## 3     deSolve, compiled            3   2.484    1.000     2.483        0
-## 1 deSolve, not compiled            3  17.963    7.231    17.951        0
-## 2      Eigenvalue based            3   3.146    1.267     3.144        0
+## 3     deSolve, compiled            3   2.394    1.000     2.388    0.004
+## 1 deSolve, not compiled            3  17.923    7.487    17.910    0.000
+## 2      Eigenvalue based            3   3.021    1.262     3.018    0.000
 ##   user.child sys.child
 ## 3          0         0
 ## 1          0         0
@@ -157,8 +157,8 @@
 }
## Successfully compiled differential equation model from auto-generated C code.
##                    test replications elapsed relative user.self sys.self
-## 2     deSolve, compiled            3   4.232    1.000     4.226    0.004
-## 1 deSolve, not compiled            3  37.946    8.966    37.924    0.000
+## 2     deSolve, compiled            3   4.162    1.000     4.158        0
+## 1 deSolve, not compiled            3  37.536    9.019    37.517        0
 ##   user.child sys.child
 ## 2          0         0
 ## 1          0         0
diff --git a/docs/reference/Extract.mmkin.html b/docs/reference/Extract.mmkin.html index e3285ed3..95b1558e 100644 --- a/docs/reference/Extract.mmkin.html +++ b/docs/reference/Extract.mmkin.html @@ -280,7 +280,7 @@ #> #> $time #> User System verstrichen -#> 0.201 0.000 0.200 +#> 0.196 0.000 0.196 #> #> $mkinmod #> <mkinmod> model generated with @@ -469,8 +469,8 @@ #> } #> return(mC) #> } -#> <bytecode: 0x555559103bf0> -#> <environment: 0x55555a51ba10> +#> <bytecode: 0x555559255c78> +#> <environment: 0x55555add1128> #> #> $cost_notrans #> function (P) @@ -492,8 +492,8 @@ #> scaleVar = scaleVar) #> return(mC) #> } -#> <bytecode: 0x55555a537b00> -#> <environment: 0x55555a51ba10> +#> <bytecode: 0x55555a1e9540> +#> <environment: 0x55555add1128> #> #> $hessian_notrans #> parent_0 k_parent_sink @@ -560,7 +560,7 @@ #> 99.17407 #> #> $date -#> [1] "Fri Feb 22 20:46:31 2019" +#> [1] "Mon Feb 25 14:52:43 2019" #> #> $version #> [1] "0.9.48.1" diff --git a/docs/reference/index.html b/docs/reference/index.html index f31a72fe..24f3df0c 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -151,6 +151,12 @@

mmkin()

Fit one or more kinetic models with one or more state variables to one or more datasets

+ + + +

nafta()

+ +

Evaluate parent kinetics using the NAFTA guidance

diff --git a/docs/reference/mccall81_245T.html b/docs/reference/mccall81_245T.html index 7b3418de..bcc871d8 100644 --- a/docs/reference/mccall81_245T.html +++ b/docs/reference/mccall81_245T.html @@ -160,8 +160,8 @@ 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:46:54 2019 -#> Date of summary: Fri Feb 22 20:46:54 2019 +#> Date of fit: Mon Feb 25 14:53:05 2019 +#> Date of summary: Mon Feb 25 14:53:05 2019 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -171,7 +171,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 574 model solutions performed in 4.461 s +#> Fitted with method Port using 574 model solutions performed in 3.873 s #> #> Weighting: none #> @@ -249,8 +249,8 @@ fixed_parms = "k_phenol_sink", quiet = TRUE) summary(fit.2, data = FALSE)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:46:56 2019 -#> Date of summary: Fri Feb 22 20:46:56 2019 +#> Date of fit: Mon Feb 25 14:53:07 2019 +#> Date of summary: Mon Feb 25 14:53:07 2019 #> #> Equations: #> d_T245/dt = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -260,7 +260,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 246 model solutions performed in 1.709 s +#> Fitted with method Port using 246 model solutions performed in 1.623 s #> #> Weighting: none #> diff --git a/docs/reference/mkinfit.html b/docs/reference/mkinfit.html index dfdddb25..80278890 100644 --- a/docs/reference/mkinfit.html +++ b/docs/reference/mkinfit.html @@ -438,15 +438,15 @@ fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:46:59 2019 -#> Date of summary: Fri Feb 22 20:46:59 2019 +#> Date of fit: Mon Feb 25 14:53:09 2019 +#> Date of summary: Mon Feb 25 14:53:09 2019 #> #> 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.185 s +#> Fitted with method Port using 64 model solutions performed in 0.168 s #> #> Weighting: none #> @@ -515,7 +515,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 -#> 1.071 0.000 1.072
coef(fit)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 1.038 0.000 1.039
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 @@ -590,7 +590,7 @@ #> Model cost at call 146 : 371.2134 #> Optimisation by method Port successfully terminated. #> User System verstrichen -#> 0.852 0.000 0.852
coef(fit.deSolve)
#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 0.827 0.000 0.827
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 @@ -628,8 +628,8 @@ 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:11 2019 -#> Date of summary: Fri Feb 22 20:47:11 2019 +#> Date of fit: Mon Feb 25 14:53:22 2019 +#> Date of summary: Mon Feb 25 14:53:22 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -637,7 +637,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 186 model solutions performed in 0.864 s +#> Fitted with method Port using 186 model solutions performed in 0.898 s #> #> Weighting: none #> @@ -745,8 +745,8 @@ #> 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:14 2019 -#> Date of summary: Fri Feb 22 20:47:14 2019 +#> Date of fit: Mon Feb 25 14:53:24 2019 +#> Date of summary: Mon Feb 25 14:53:24 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -754,7 +754,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 551 model solutions performed in 2.584 s +#> Fitted with method Port using 551 model solutions performed in 2.572 s #> #> Weighting: none #> @@ -867,8 +867,8 @@ #> 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:15 2019 -#> Date of summary: Fri Feb 22 20:47:15 2019 +#> Date of fit: Mon Feb 25 14:53:25 2019 +#> Date of summary: Mon Feb 25 14:53:25 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -876,7 +876,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 155 model solutions performed in 0.716 s +#> Fitted with method Port using 155 model solutions performed in 0.709 s #> #> Weighting: mean #> @@ -985,8 +985,8 @@ quiet = TRUE) summary(f.w.value)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:16 2019 -#> Date of summary: Fri Feb 22 20:47:16 2019 +#> Date of fit: Mon Feb 25 14:53:26 2019 +#> Date of summary: Mon Feb 25 14:53:26 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -994,7 +994,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 174 model solutions performed in 0.83 s +#> Fitted with method Port using 174 model solutions performed in 0.81 s #> #> Weighting: manual #> @@ -1105,8 +1105,8 @@ f.w.man <- mkinfit(SFO_SFO.ff, dw, err = "err.man", quiet = TRUE) summary(f.w.man)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:17 2019 -#> Date of summary: Fri Feb 22 20:47:17 2019 +#> Date of fit: Mon Feb 25 14:53:28 2019 +#> Date of summary: Mon Feb 25 14:53:28 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1114,7 +1114,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 270 model solutions performed in 1.286 s +#> Fitted with method Port using 270 model solutions performed in 1.25 s #> #> Weighting: manual #> @@ -1223,8 +1223,8 @@ reweight.method = "obs") summary(f.w.man.irls)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:47:21 2019 -#> Date of summary: Fri Feb 22 20:47:21 2019 +#> Date of fit: Mon Feb 25 14:53:31 2019 +#> Date of summary: Mon Feb 25 14:53:31 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -1232,7 +1232,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 692 model solutions performed in 3.38 s +#> Fitted with method Port using 692 model solutions performed in 3.302 s #> #> Weighting: manual #> diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index 64fba5e5..ba26c686 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -231,7 +231,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 file622753352edd.c 2> file622753352edd.c.err.txt +#> /usr/lib/R/bin/R CMD SHLIB file481263217c00.c 2> file481263217c00.c.err.txt #> Program source: #> 1: #include <R.h> #> 2: diff --git a/docs/reference/mkinpredict.html b/docs/reference/mkinpredict.html index 2b4c33aa..738eeb9d 100644 --- a/docs/reference/mkinpredict.html +++ b/docs/reference/mkinpredict.html @@ -325,7 +325,7 @@ 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 @@ -335,7 +335,7 @@ 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.039 0.000 0.040
+#> 0.047 0.000 0.047
# Predict from a fitted model f <- mkinfit(SFO_SFO, FOCUS_2006_C)
#> Model cost at call 1 : 552.5739 #> Model cost at call 3 : 552.5739 diff --git a/docs/reference/mmkin.html b/docs/reference/mmkin.html index 71ec89e8..1a60e3ea 100644 --- a/docs/reference/mmkin.html +++ b/docs/reference/mmkin.html @@ -191,8 +191,8 @@ time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE)) time_default
#> User System verstrichen -#> 0.052 0.044 7.383
time_1
#> User System verstrichen -#> 23.652 0.004 23.672
+#> 0.036 0.039 7.196
time_1
#> User System verstrichen +#> 22.818 0.000 22.834
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/summary.mkinfit.html b/docs/reference/summary.mkinfit.html index 39ef962c..f0d4a060 100644 --- a/docs/reference/summary.mkinfit.html +++ b/docs/reference/summary.mkinfit.html @@ -208,15 +208,15 @@

Examples

summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:48:16 2019 -#> Date of summary: Fri Feb 22 20:48:16 2019 +#> Date of fit: Mon Feb 25 14:54:24 2019 +#> Date of summary: Mon Feb 25 14:54:24 2019 #> #> 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.088 s +#> Fitted with method Port using 35 model solutions performed in 0.085 s #> #> Weighting: none #> diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index 9d18fbb2..1071a932 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -202,8 +202,8 @@ The transformation of sets of formation fractions is fragile, as it supposes 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:48:24 2019 -#> Date of summary: Fri Feb 22 20:48:24 2019 +#> Date of fit: Mon Feb 25 14:54:32 2019 +#> Date of summary: Mon Feb 25 14:54:32 2019 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -211,7 +211,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.717 s +#> Fitted with method Port using 153 model solutions performed in 0.704 s #> #> Weighting: none #> @@ -278,8 +278,8 @@ The transformation of sets of formation fractions is fragile, as it supposes
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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:48:26 2019 -#> Date of summary: Fri Feb 22 20:48:26 2019 +#> Date of fit: Mon Feb 25 14:54:34 2019 +#> Date of summary: Mon Feb 25 14:54:34 2019 #> #> Equations: #> d_parent/dt = - k_parent_sink * parent - k_parent_m1 * parent @@ -287,7 +287,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.661 s +#> Fitted with method Port using 350 model solutions performed in 1.62 s #> #> Weighting: none #> @@ -366,8 +366,8 @@ The transformation of sets of formation fractions is fragile, as it supposes fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) summary(fit.ff, data = FALSE)
#> mkin version used for fitting: 0.9.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:48:27 2019 -#> Date of summary: Fri Feb 22 20:48:27 2019 +#> Date of fit: Mon Feb 25 14:54:35 2019 +#> Date of summary: Mon Feb 25 14:54:35 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -375,7 +375,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.871 s +#> Fitted with method Port using 186 model solutions performed in 0.856 s #> #> Weighting: none #> @@ -450,8 +450,8 @@ The transformation of sets of formation fractions is fragile, as it supposes 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.48.1 #> R version used for fitting: 3.5.2 -#> Date of fit: Fri Feb 22 20:48:28 2019 -#> Date of summary: Fri Feb 22 20:48:28 2019 +#> Date of fit: Mon Feb 25 14:54:36 2019 +#> Date of summary: Mon Feb 25 14:54:36 2019 #> #> Equations: #> d_parent/dt = - k_parent * parent @@ -459,7 +459,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.484 s +#> Fitted with method Port using 104 model solutions performed in 0.482 s #> #> Weighting: none #> diff --git a/test.log b/test.log index 5a71534f..345746e2 100644 --- a/test.log +++ b/test.log @@ -1,28 +1,30 @@ Loading mkin 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.5 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) [7.2 s] - ⠏ | 0 | Iteratively reweighted least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighted least squares (IRLS) fitting ⠙ | 1 1 | Iteratively reweighted least squares (IRLS) fitting ✔ | 1 1 | Iteratively reweighted least squares (IRLS) fitting [9.0 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.4 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) [7.1 s] + ⠏ | 0 | Iteratively reweighted least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighted least squares (IRLS) fitting ⠙ | 1 1 | Iteratively reweighted least squares (IRLS) fitting ✔ | 1 1 | Iteratively reweighted least squares (IRLS) fitting [8.8 s] ──────────────────────────────────────────────────────────────────────────────── test_irls.R:44: skip: Reweighting method 'tc' works Too much trouble with datasets that are randomly generated ──────────────────────────────────────────────────────────────────────────────── ⠏ | 0 | Fitting the logistic model ⠋ | 1 | Fitting the logistic model ⠙ | 1 1 | Fitting the logistic model ✔ | 1 1 | Fitting the logistic model [0.5 s] ──────────────────────────────────────────────────────────────────────────────── -test_logistic.R:42: skip: The logistic fit can be done via differential equation +test_logistic.R:41: skip: The logistic fit can be done via differential equation Skip slow fit of logistic model using deSolve without compilation ──────────────────────────────────────────────────────────────────────────────── ⠏ | 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 [23.9 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 [6.0 s] + ⠏ | 0 | Evaluations according to the NAFTA guidance from 2015 ⠋ | 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 1 1 | Evaluations according to the NAFTA guidance from 2015 ⠙ | 2 | Evaluations according to the NAFTA guidance from 2015 ⠹ | 3 | Evaluations according to the NAFTA guidance from 2015 ⠸ | 4 | Evaluations according to the NAFTA guidance from 2015 ⠼ | 5 | Evaluations according to the NAFTA guidance from 2015 ⠴ | 6 | Evaluations according to the NAFTA guidance from 2015 ⠦ | 7 | Evaluations according to the NAFTA guidance from 2015 ✔ | 7 | Evaluations according to the NAFTA guidance from 2015 [0.7 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 [23.8 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.2 s] + ⠏ | 0 | Plotting ⠋ | 1 | Plotting ⠙ | 2 | Plotting ✔ | 2 | Plotting [0.4 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.9 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) [7.5 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) [8.4 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 65.5 s +Duration: 65.9 s -OK: 50 +OK: 59 Failed: 0 Warnings: 0 Skipped: 2 diff --git a/tests/figs/deps.txt b/tests/figs/deps.txt new file mode 100644 index 00000000..0f6c3754 --- /dev/null +++ b/tests/figs/deps.txt @@ -0,0 +1,3 @@ +- vdiffr-svg-engine: 1.0 +- vdiffr: 0.3.0.9000 +- freetypeharfbuzz: 0.2.5 diff --git a/tests/figs/plotting/mmkin-plot-for-focus-c.svg b/tests/figs/plotting/mmkin-plot-for-focus-c.svg new file mode 100644 index 00000000..1c697328 --- /dev/null +++ b/tests/figs/plotting/mmkin-plot-for-focus-c.svg @@ -0,0 +1,569 @@ + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +20 +40 +60 +80 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + +parent + + + + + +FOCUS_C +SFO + +χ +2 + +error level += +15.8% + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +-10 +-5 +0 +5 +10 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + +SFO residuals + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +20 +40 +60 +80 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + +FOCUS_C +FOMC + +χ +2 + +error level += +6.66% + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + + +-3 +-1 +1 +2 +3 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + +FOMC residuals + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +20 +40 +60 +80 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + +FOCUS_C +DFOP + +χ +2 + +error level += +2.66% + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + + +-1.5 +-0.5 +0.5 +1.5 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + +DFOP residuals + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +20 +40 +60 +80 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + +FOCUS_C +HS + +χ +2 + +error level += +4.7% + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +-2 +-1 +0 +1 +2 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + +HS residuals + + + + + + diff --git a/tests/figs/plotting/mmkin-plot-for-sfo-focus-c-and-d.svg b/tests/figs/plotting/mmkin-plot-for-sfo-focus-c-and-d.svg new file mode 100644 index 00000000..72496e86 --- /dev/null +++ b/tests/figs/plotting/mmkin-plot-for-sfo-focus-c-and-d.svg @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +0 +20 +40 +60 +80 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + +parent + + + + + +SFO +FOCUS_C + +χ +2 + +error level += +15.8% + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + +-10 +-5 +0 +5 +10 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + +FOCUS_C residuals + + + + + + + + + + + + + + + +0 +20 +40 +60 + + + + + + + +0 +20 +40 +60 +80 +100 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +SFO +FOCUS_D + +χ +2 + +error level += +6.45% + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 + + + + + + +-10 +-5 +0 +5 +10 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +FOCUS_D residuals + + + + + + diff --git a/tests/testthat/test_plots_twa.R b/tests/testthat/test_plots_twa.R new file mode 100644 index 00000000..fe0ba325 --- /dev/null +++ b/tests/testthat/test_plots_twa.R @@ -0,0 +1,61 @@ +# Copyright (C) 2016-2019 Johannes Ranke +# Contact: jranke@uni-bremen.de + +# This file is part of the R package mkin + +# mkin is free software: you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. + +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. + +# You should have received a copy of the GNU General Public License along with +# this program. If not, see + +models <- c("SFO", "FOMC", "DFOP", "HS") +fits <- mmkin(models, + list(FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), + quiet = TRUE, cores = if (Sys.getenv("TRAVIS") == "") 15 else 1) + +context("Calculation of maximum time weighted average concentrations (TWAs)") + +test_that("Time weighted average concentrations are correct", { + skip_on_cran() + + outtimes_10 <- seq(0, 10, length.out = 10000) + + for (ds in c("FOCUS_C", "FOCUS_D")) { + for (model in 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) + } + } +}) + +context("Plotting") + +test_that("Plotting mmkin objects is reproducible", { + skip_on_cran() + mmkin_FOCUS_C <- function() plot(fits[, "FOCUS_C"]) + mmkin_SFO <- function() plot(fits["SFO",]) + + vdiffr::expect_doppelganger("mmkin plot for FOCUS C", mmkin_FOCUS_C) + vdiffr::expect_doppelganger("mmkin plot for SFO (FOCUS C and D)", mmkin_SFO) +}) + diff --git a/tests/testthat/test_twa.R b/tests/testthat/test_twa.R deleted file mode 100644 index 42b74a7f..00000000 --- a/tests/testthat/test_twa.R +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright (C) 2016,2017,2018 Johannes Ranke -# Contact: jranke@uni-bremen.de - -# This file is part of the R package mkin - -# mkin is free software: you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later -# version. - -# This program is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -# details. - -# You should have received a copy of the GNU General Public License along with -# this program. If not, see - -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", "HS") - fits <- mmkin(twa_models, - list(FOCUS_C = FOCUS_2006_C, FOCUS_D = FOCUS_2006_D), - quiet = TRUE, cores = if (Sys.getenv("TRAVIS") == "") 15 else 1) - - 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