From 91c5db736a4d3f2290a0cc5698fb4e35ae7bda59 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 18 May 2022 21:26:17 +0200 Subject: Remove outdated comment in FOCUS L vignette, update docs This also adds the first benchmark results obtained on my laptop system --- docs/articles/FOCUS_D.html | 22 +-- docs/articles/FOCUS_L.html | 184 ++++++++++----------- .../figure-html/unnamed-chunk-6-1.png | Bin 36101 -> 36120 bytes docs/articles/index.html | 2 +- docs/articles/mkin.html | 4 +- .../mkin_files/figure-html/unnamed-chunk-2-1.png | Bin 90167 -> 90169 bytes docs/articles/twa.html | 4 +- docs/articles/web_only/FOCUS_Z.html | 50 +++--- .../figure-html/FOCUS_2006_Z_fits_10-1.png | Bin 105896 -> 105896 bytes .../figure-html/FOCUS_2006_Z_fits_11-1.png | Bin 104793 -> 104797 bytes .../figure-html/FOCUS_2006_Z_fits_11a-1.png | Bin 75230 -> 75232 bytes .../figure-html/FOCUS_2006_Z_fits_11b-1.png | Bin 36314 -> 36302 bytes .../figure-html/FOCUS_2006_Z_fits_5-1.png | Bin 80373 -> 80380 bytes .../figure-html/FOCUS_2006_Z_fits_6-1.png | Bin 105210 -> 105229 bytes .../figure-html/FOCUS_2006_Z_fits_9-1.png | Bin 88801 -> 88797 bytes docs/articles/web_only/NAFTA_examples.html | 154 +++++++++-------- .../NAFTA_examples_files/figure-html/p10-1.png | Bin 79758 -> 79762 bytes .../NAFTA_examples_files/figure-html/p15a-1.png | Bin 76925 -> 76938 bytes .../NAFTA_examples_files/figure-html/p15b-1.png | Bin 78968 -> 78977 bytes .../NAFTA_examples_files/figure-html/p5b-1.png | Bin 80721 -> 80721 bytes .../NAFTA_examples_files/figure-html/p6-1.png | Bin 83052 -> 83052 bytes .../NAFTA_examples_files/figure-html/p7-1.png | Bin 102568 -> 102570 bytes docs/articles/web_only/benchmarks.html | 145 ++++++++++------ docs/articles/web_only/compiled_models.html | 30 ++-- docs/articles/web_only/dimethenamid_2018.html | 93 ++++++----- docs/articles/web_only/mkin_benchmarks.rda | Bin 0 -> 1273 bytes 26 files changed, 360 insertions(+), 328 deletions(-) create mode 100644 docs/articles/web_only/mkin_benchmarks.rda (limited to 'docs/articles') diff --git a/docs/articles/FOCUS_D.html b/docs/articles/FOCUS_D.html index 1363ef11..39cf7e1a 100644 --- a/docs/articles/FOCUS_D.html +++ b/docs/articles/FOCUS_D.html @@ -105,7 +105,7 @@

Example evaluation of FOCUS Example Dataset D

Johannes Ranke

-

Last change 31 January 2019 (rebuilt 2022-03-07)

+

Last change 31 January 2019 (rebuilt 2022-05-18)

Source: vignettes/FOCUS_D.rmd @@ -191,9 +191,9 @@
 summary(fit)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:15:58 2022 
-## Date of summary: Mon Mar  7 13:15:59 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:29 2022 
+## Date of summary: Wed May 18 20:42:30 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
@@ -201,7 +201,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 401 model solutions performed in 0.165 s
+## Fitted using 401 model solutions performed in 0.144 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -244,11 +244,11 @@
 ## 
 ## Parameter correlation:
 ##                   parent_0 log_k_parent   log_k_m1 f_parent_qlogis      sigma
-## parent_0         1.000e+00    5.174e-01 -1.688e-01      -5.471e-01 -1.172e-06
-## log_k_parent     5.174e-01    1.000e+00 -3.263e-01      -5.426e-01 -8.483e-07
-## log_k_m1        -1.688e-01   -3.263e-01  1.000e+00       7.478e-01  8.205e-07
-## f_parent_qlogis -5.471e-01   -5.426e-01  7.478e-01       1.000e+00  1.305e-06
-## sigma           -1.172e-06   -8.483e-07  8.205e-07       1.305e-06  1.000e+00
+## parent_0         1.000e+00    5.174e-01 -1.688e-01      -5.471e-01 -1.174e-06
+## log_k_parent     5.174e-01    1.000e+00 -3.263e-01      -5.426e-01 -8.492e-07
+## log_k_m1        -1.688e-01   -3.263e-01  1.000e+00       7.478e-01  8.220e-07
+## f_parent_qlogis -5.471e-01   -5.426e-01  7.478e-01       1.000e+00  1.307e-06
+## sigma           -1.174e-06   -8.492e-07  8.220e-07       1.307e-06  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -334,7 +334,7 @@
 
 

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/FOCUS_L.html b/docs/articles/FOCUS_L.html index d7412a56..5f41b6a3 100644 --- a/docs/articles/FOCUS_L.html +++ b/docs/articles/FOCUS_L.html @@ -105,7 +105,7 @@

Example evaluation of FOCUS Laboratory Data L1 to L3

Johannes Ranke

-

Last change 17 November 2016 (rebuilt 2022-03-07)

+

Last change 17 November 2016 (rebuilt 2022-05-18)

Source: vignettes/FOCUS_L.rmd @@ -132,16 +132,16 @@ m.L1.SFO <- mkinfit("SFO", FOCUS_2006_L1_mkin, quiet = TRUE) summary(m.L1.SFO)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:01 2022 
-## Date of summary: Mon Mar  7 13:16:01 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:32 2022 
+## Date of summary: Wed May 18 20:42:32 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 133 model solutions performed in 0.032 s
+## Fitted using 133 model solutions performed in 0.031 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -173,9 +173,9 @@
 ## 
 ## Parameter correlation:
 ##                parent_0 log_k_parent      sigma
-## parent_0      1.000e+00    6.186e-01 -1.516e-09
-## log_k_parent  6.186e-01    1.000e+00 -3.124e-09
-## sigma        -1.516e-09   -3.124e-09  1.000e+00
+## parent_0      1.000e+00    6.186e-01 -1.712e-09
+## log_k_parent  6.186e-01    1.000e+00 -3.237e-09
+## sigma        -1.712e-09   -3.237e-09  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -225,29 +225,26 @@
 

For comparison, the FOMC model is fitted as well, and the \(\chi^2\) error level is checked.

-m.L1.FOMC <- mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet=TRUE)
-
## Warning in mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet = TRUE): Optimisation did not converge:
-## false convergence (8)
-
-plot(m.L1.FOMC, show_errmin = TRUE, main = "FOCUS L1 - FOMC")
+m.L1.FOMC <- mkinfit("FOMC", FOCUS_2006_L1_mkin, quiet=TRUE) +plot(m.L1.FOMC, show_errmin = TRUE, main = "FOCUS L1 - FOMC")

-
+
 summary(m.L1.FOMC, data = FALSE)
## Warning in sqrt(diag(covar)): NaNs produced
## Warning in sqrt(1/diag(V)): NaNs produced
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
 ## doubtful
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:02 2022 
-## Date of summary: Mon Mar  7 13:16:02 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:33 2022 
+## Date of summary: Wed May 18 20:42:33 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 369 model solutions performed in 0.081 s
+## Fitted using 357 model solutions performed in 0.072 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -268,39 +265,34 @@
 ## Fixed parameter values:
 ## None
 ## 
-## 
-## Warning(s): 
-## Optimisation did not converge:
-## false convergence (8)
-## 
 ## Results:
 ## 
-##        AIC      BIC   logLik
-##   95.88781 99.44929 -43.9439
+##        AIC      BIC    logLik
+##   95.88804 99.44953 -43.94402
 ## 
 ## Optimised, transformed parameters with symmetric confidence intervals:
 ##           Estimate Std. Error  Lower  Upper
 ## parent_0     92.47     1.2820 89.720 95.220
-## log_alpha    13.78        NaN    NaN    NaN
-## log_beta     16.13        NaN    NaN    NaN
-## sigma         2.78     0.4598  1.794  3.766
+## log_alpha    11.37        NaN    NaN    NaN
+## log_beta     13.72        NaN    NaN    NaN
+## sigma         2.78     0.4621  1.789  3.771
 ## 
 ## Parameter correlation:
 ##            parent_0 log_alpha log_beta     sigma
-## parent_0  1.0000000       NaN      NaN 0.0001671
+## parent_0  1.0000000       NaN      NaN 0.0005548
 ## log_alpha       NaN         1      NaN       NaN
 ## log_beta        NaN       NaN        1       NaN
-## sigma     0.0001671       NaN      NaN 1.0000000
+## sigma     0.0005548       NaN      NaN 1.0000000
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
 ## t-test (unrealistically) based on the assumption of normal distribution
 ## for estimators of untransformed parameters.
 ##           Estimate t value Pr(>t)  Lower  Upper
-## parent_0 9.247e+01      NA     NA 89.720 95.220
-## alpha    9.658e+05      NA     NA     NA     NA
-## beta     1.010e+07      NA     NA     NA     NA
-## sigma    2.780e+00      NA     NA  1.794  3.766
+## parent_0     92.47      NA     NA 89.720 95.220
+## alpha     87110.00      NA     NA     NA     NA
+## beta     911100.00      NA     NA     NA     NA
+## sigma         2.78      NA     NA  1.789  3.771
 ## 
 ## FOCUS Chi2 error levels in percent:
 ##          err.min n.optim df
@@ -308,8 +300,8 @@
 ## parent     3.619       3  6
 ## 
 ## Estimated disappearance times:
-##        DT50  DT90 DT50back
-## parent 7.25 24.08     7.25
+## DT50 DT90 DT50back +## parent 7.249 24.08 7.249

We get a warning that the default optimisation algorithm Port did not converge, which is an indication that the model is overparameterised, i.e. contains too many parameters that are ill-defined as a consequence.

And in fact, due to the higher number of parameters, and the lower number of degrees of freedom of the fit, the \(\chi^2\) error level is actually higher for the FOMC model (3.6%) than for the SFO model (3.4%). Additionally, the parameters log_alpha and log_beta internally fitted in the model have excessive confidence intervals, that span more than 25 orders of magnitude (!) when backtransformed to the scale of alpha and beta. Also, the t-test for significant difference from zero does not indicate such a significant difference, with p-values greater than 0.1, and finally, the parameter correlation of log_alpha and log_beta is 1.000, clearly indicating that the model is overparameterised.

The \(\chi^2\) error levels reported in Appendix 3 and Appendix 7 to the FOCUS kinetics report are rounded to integer percentages and partly deviate by one percentage point from the results calculated by mkin. The reason for this is not known. However, mkin gives the same \(\chi^2\) error levels as the kinfit package and the calculation routines of the kinfit package have been extensively compared to the results obtained by the KinGUI software, as documented in the kinfit package vignette. KinGUI was the first widely used standard package in this field. Also, the calculation of \(\chi^2\) error levels was compared with KinGUII, CAKE and DegKin manager in a project sponsored by the German Umweltbundesamt (Ranke 2014).

@@ -318,7 +310,7 @@

Laboratory Data L2

The following code defines example dataset L2 from the FOCUS kinetics report, p. 287:

-
+
 FOCUS_2006_L2 = data.frame(
   t = rep(c(0, 1, 3, 7, 14, 28), each = 2),
   parent = c(96.1, 91.8, 41.4, 38.7,
@@ -329,7 +321,7 @@
 

SFO fit for L2

Again, the SFO model is fitted and the result is plotted. The residual plot can be obtained simply by adding the argument show_residuals to the plot command.

-
+
 m.L2.SFO <- mkinfit("SFO", FOCUS_2006_L2_mkin, quiet=TRUE)
 plot(m.L2.SFO, show_residuals = TRUE, show_errmin = TRUE,
      main = "FOCUS L2 - SFO")
@@ -342,24 +334,24 @@

FOMC fit for L2

For comparison, the FOMC model is fitted as well, and the \(\chi^2\) error level is checked.

-
+
 m.L2.FOMC <- mkinfit("FOMC", FOCUS_2006_L2_mkin, quiet = TRUE)
 plot(m.L2.FOMC, show_residuals = TRUE,
      main = "FOCUS L2 - FOMC")

-
+
 summary(m.L2.FOMC, data = FALSE)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:03 2022 
-## Date of summary: Mon Mar  7 13:16:03 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:33 2022 
+## Date of summary: Wed May 18 20:42:33 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 239 model solutions performed in 0.049 s
+## Fitted using 239 model solutions performed in 0.044 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -394,10 +386,10 @@
 ## 
 ## Parameter correlation:
 ##             parent_0  log_alpha   log_beta      sigma
-## parent_0   1.000e+00 -1.151e-01 -2.085e-01 -7.828e-09
-## log_alpha -1.151e-01  1.000e+00  9.741e-01 -1.602e-07
-## log_beta  -2.085e-01  9.741e-01  1.000e+00 -1.372e-07
-## sigma     -7.828e-09 -1.602e-07 -1.372e-07  1.000e+00
+## parent_0   1.000e+00 -1.151e-01 -2.085e-01 -7.637e-09
+## log_alpha -1.151e-01  1.000e+00  9.741e-01 -1.617e-07
+## log_beta  -2.085e-01  9.741e-01  1.000e+00 -1.387e-07
+## sigma     -7.637e-09 -1.617e-07 -1.387e-07  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -423,17 +415,17 @@
 

DFOP fit for L2

Fitting the four parameter DFOP model further reduces the \(\chi^2\) error level.

-
+
 m.L2.DFOP <- mkinfit("DFOP", FOCUS_2006_L2_mkin, quiet = TRUE)
 plot(m.L2.DFOP, show_residuals = TRUE, show_errmin = TRUE,
      main = "FOCUS L2 - DFOP")

-
+
 summary(m.L2.DFOP, data = FALSE)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:03 2022 
-## Date of summary: Mon Mar  7 13:16:03 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:34 2022 
+## Date of summary: Wed May 18 20:42:34 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -442,7 +434,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 581 model solutions performed in 0.132 s
+## Fitted using 581 model solutions performed in 0.121 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -473,18 +465,18 @@
 ## Optimised, transformed parameters with symmetric confidence intervals:
 ##          Estimate Std. Error      Lower     Upper
 ## parent_0   93.950  9.998e-01    91.5900   96.3100
-## log_k1      3.112  1.842e+03 -4353.0000 4359.0000
+## log_k1      3.113  1.845e+03 -4360.0000 4367.0000
 ## log_k2     -1.088  6.285e-02    -1.2370   -0.9394
 ## g_qlogis   -0.399  9.946e-02    -0.6342   -0.1638
 ## sigma       1.414  2.886e-01     0.7314    2.0960
 ## 
 ## Parameter correlation:
 ##            parent_0     log_k1     log_k2   g_qlogis      sigma
-## parent_0  1.000e+00  6.783e-07 -3.390e-10  2.665e-01 -2.967e-10
-## log_k1    6.783e-07  1.000e+00  1.116e-04 -2.196e-04 -1.031e-05
-## log_k2   -3.390e-10  1.116e-04  1.000e+00 -7.903e-01  2.917e-09
-## g_qlogis  2.665e-01 -2.196e-04 -7.903e-01  1.000e+00 -4.408e-09
-## sigma    -2.967e-10 -1.031e-05  2.917e-09 -4.408e-09  1.000e+00
+## parent_0  1.000e+00  6.784e-07 -5.188e-10  2.665e-01 -5.800e-10
+## log_k1    6.784e-07  1.000e+00  1.114e-04 -2.191e-04 -1.029e-05
+## log_k2   -5.188e-10  1.114e-04  1.000e+00 -7.903e-01  5.080e-09
+## g_qlogis  2.665e-01 -2.191e-04 -7.903e-01  1.000e+00 -7.991e-09
+## sigma    -5.800e-10 -1.029e-05  5.080e-09 -7.991e-09  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -492,7 +484,7 @@
 ## for estimators of untransformed parameters.
 ##          Estimate   t value    Pr(>t)   Lower   Upper
 ## parent_0  93.9500 9.397e+01 2.036e-12 91.5900 96.3100
-## k1        22.4800 5.553e-04 4.998e-01  0.0000     Inf
+## k1        22.4800 5.544e-04 4.998e-01  0.0000     Inf
 ## k2         0.3369 1.591e+01 4.697e-07  0.2904  0.3909
 ## g          0.4016 1.680e+01 3.238e-07  0.3466  0.4591
 ## sigma      1.4140 4.899e+00 8.776e-04  0.7314  2.0960
@@ -504,15 +496,15 @@
 ## 
 ## Estimated disappearance times:
 ##          DT50  DT90 DT50back DT50_k1 DT50_k2
-## parent 0.5335 5.311    1.599 0.03084   2.058
-

Here, the DFOP model is clearly the best-fit model for dataset L2 based on the chi^2 error level criterion. However, the failure to calculate the covariance matrix indicates that the parameter estimates correlate excessively. Therefore, the FOMC model may be preferred for this dataset.

+## parent 0.5335 5.311 1.599 0.03083 2.058
+

Here, the DFOP model is clearly the best-fit model for dataset L2 based on the chi^2 error level criterion.

Laboratory Data L3

The following code defines example dataset L3 from the FOCUS kinetics report, p. 290.

-
+
 FOCUS_2006_L3 = data.frame(
   t = c(0, 3, 7, 14, 30, 60, 91, 120),
   parent = c(97.8, 60, 51, 43, 35, 22, 15, 12))
@@ -521,7 +513,7 @@
 

Fit multiple models

As of mkin version 0.9-39 (June 2015), we can fit several models to one or more datasets in one call to the function mmkin. The datasets have to be passed in a list, in this case a named list holding only the L3 dataset prepared above.

-
+
 # Only use one core here, not to offend the CRAN checks
 mm.L3 <- mmkin(c("SFO", "FOMC", "DFOP"), cores = 1,
                list("FOCUS L3" = FOCUS_2006_L3_mkin), quiet = TRUE)
@@ -534,12 +526,12 @@
 
 

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

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

-
+
 summary(mm.L3[["DFOP", 1]])
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:04 2022 
-## Date of summary: Mon Mar  7 13:16:04 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:34 2022 
+## Date of summary: Wed May 18 20:42:35 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -548,7 +540,7 @@
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 376 model solutions performed in 0.08 s
+## Fitted using 376 model solutions performed in 0.073 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -586,11 +578,11 @@
 ## 
 ## Parameter correlation:
 ##            parent_0     log_k1     log_k2   g_qlogis      sigma
-## parent_0  1.000e+00  1.732e-01  2.282e-02  4.009e-01 -9.664e-08
-## log_k1    1.732e-01  1.000e+00  4.945e-01 -5.809e-01  7.147e-07
-## log_k2    2.282e-02  4.945e-01  1.000e+00 -6.812e-01  1.022e-06
-## g_qlogis  4.009e-01 -5.809e-01 -6.812e-01  1.000e+00 -7.926e-07
-## sigma    -9.664e-08  7.147e-07  1.022e-06 -7.926e-07  1.000e+00
+## parent_0  1.000e+00  1.732e-01  2.282e-02  4.009e-01 -9.632e-08
+## log_k1    1.732e-01  1.000e+00  4.945e-01 -5.809e-01  7.145e-07
+## log_k2    2.282e-02  4.945e-01  1.000e+00 -6.812e-01  1.021e-06
+## g_qlogis  4.009e-01 -5.809e-01 -6.812e-01  1.000e+00 -7.925e-07
+## sigma    -9.632e-08  7.145e-07  1.021e-06 -7.925e-07  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -622,7 +614,7 @@
 ##    60   parent     22.0     23.26 -1.25919
 ##    91   parent     15.0     15.18 -0.18181
 ##   120   parent     12.0     10.19  1.81395
-
+
 plot(mm.L3[["DFOP", 1]], show_errmin = TRUE)

Here, a look to the model plot, the confidence intervals of the parameters and the correlation matrix suggest that the parameter estimates are reliable, and the DFOP model can be used as the best-fit model based on the \(\chi^2\) error level criterion for laboratory data L3.

@@ -633,13 +625,13 @@

Laboratory Data L4

The following code defines example dataset L4 from the FOCUS kinetics report, p. 293:

-
+
 FOCUS_2006_L4 = data.frame(
   t = c(0, 3, 7, 14, 30, 60, 91, 120),
   parent = c(96.6, 96.3, 94.3, 88.8, 74.9, 59.9, 53.5, 49.0))
 FOCUS_2006_L4_mkin <- mkin_wide_to_long(FOCUS_2006_L4)

Fits of the SFO and FOMC models, plots and summaries are produced below:

-
+
 # Only use one core here, not to offend the CRAN checks
 mm.L4 <- mmkin(c("SFO", "FOMC"), cores = 1,
                list("FOCUS L4" = FOCUS_2006_L4_mkin),
@@ -647,19 +639,19 @@
 plot(mm.L4)

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

-
+
 summary(mm.L4[["SFO", 1]], data = FALSE)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:04 2022 
-## Date of summary: Mon Mar  7 13:16:05 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:35 2022 
+## Date of summary: Wed May 18 20:42:35 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - k_parent * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 142 model solutions performed in 0.029 s
+## Fitted using 142 model solutions performed in 0.027 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -691,9 +683,9 @@
 ## 
 ## Parameter correlation:
 ##               parent_0 log_k_parent     sigma
-## parent_0     1.000e+00    5.938e-01 3.387e-07
-## log_k_parent 5.938e-01    1.000e+00 5.830e-07
-## sigma        3.387e-07    5.830e-07 1.000e+00
+## parent_0     1.000e+00    5.938e-01 3.440e-07
+## log_k_parent 5.938e-01    1.000e+00 5.885e-07
+## sigma        3.440e-07    5.885e-07 1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -712,19 +704,19 @@
 ## Estimated disappearance times:
 ##        DT50 DT90
 ## parent  106  352
-
+
 summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version used for fitting:    1.1.0 
-## R version used for fitting:       4.1.2 
-## Date of fit:     Mon Mar  7 13:16:04 2022 
-## Date of summary: Mon Mar  7 13:16:05 2022 
+## R version used for fitting:       4.2.0 
+## Date of fit:     Wed May 18 20:42:35 2022 
+## Date of summary: Wed May 18 20:42:35 2022 
 ## 
 ## Equations:
 ## d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted using 224 model solutions performed in 0.045 s
+## Fitted using 224 model solutions performed in 0.041 s
 ## 
 ## Error model: Constant variance 
 ## 
@@ -759,10 +751,10 @@
 ## 
 ## Parameter correlation:
 ##             parent_0  log_alpha   log_beta      sigma
-## parent_0   1.000e+00 -4.696e-01 -5.543e-01 -2.468e-07
-## log_alpha -4.696e-01  1.000e+00  9.889e-01  2.478e-08
-## log_beta  -5.543e-01  9.889e-01  1.000e+00  5.211e-08
-## sigma     -2.468e-07  2.478e-08  5.211e-08  1.000e+00
+## parent_0   1.000e+00 -4.696e-01 -5.543e-01 -2.563e-07
+## log_alpha -4.696e-01  1.000e+00  9.889e-01  4.066e-08
+## log_beta  -5.543e-01  9.889e-01  1.000e+00  6.818e-08
+## sigma     -2.563e-07  4.066e-08  6.818e-08  1.000e+00
 ## 
 ## Backtransformed parameters:
 ## Confidence intervals for internally transformed parameters are asymmetric.
@@ -811,7 +803,7 @@
 
 

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/FOCUS_L_files/figure-html/unnamed-chunk-6-1.png b/docs/articles/FOCUS_L_files/figure-html/unnamed-chunk-6-1.png index b6130527..b56e91e1 100644 Binary files a/docs/articles/FOCUS_L_files/figure-html/unnamed-chunk-6-1.png and b/docs/articles/FOCUS_L_files/figure-html/unnamed-chunk-6-1.png differ diff --git a/docs/articles/index.html b/docs/articles/index.html index f340896b..89eb092b 100644 --- a/docs/articles/index.html +++ b/docs/articles/index.html @@ -112,7 +112,7 @@
-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/mkin.html b/docs/articles/mkin.html index 60d2ef1c..a32f4b41 100644 --- a/docs/articles/mkin.html +++ b/docs/articles/mkin.html @@ -105,7 +105,7 @@

Introduction to mkin

Johannes Ranke

-

Last change 15 February 2021 (rebuilt 2022-03-07)

+

Last change 15 February 2021 (rebuilt 2022-05-18)

Source: vignettes/mkin.rmd @@ -264,7 +264,7 @@

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png b/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png index 63246387..d1e7048d 100644 Binary files a/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png and b/docs/articles/mkin_files/figure-html/unnamed-chunk-2-1.png differ diff --git a/docs/articles/twa.html b/docs/articles/twa.html index d45b0ff4..dad8ee44 100644 --- a/docs/articles/twa.html +++ b/docs/articles/twa.html @@ -105,7 +105,7 @@

Calculation of time weighted average concentrations with mkin

Johannes Ranke

-

Last change 18 September 2019 (rebuilt 2022-03-07)

+

Last change 18 September 2019 (rebuilt 2022-05-18)

Source: vignettes/twa.rmd @@ -168,7 +168,7 @@

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/web_only/FOCUS_Z.html b/docs/articles/web_only/FOCUS_Z.html index 43508280..0dafb98a 100644 --- a/docs/articles/web_only/FOCUS_Z.html +++ b/docs/articles/web_only/FOCUS_Z.html @@ -105,7 +105,7 @@

Example evaluation of FOCUS dataset Z

Johannes Ranke

-

Last change 16 January 2018 (rebuilt 2022-03-07)

+

Last change 16 January 2018 (rebuilt 2022-05-18)

Source: vignettes/web_only/FOCUS_Z.rmd @@ -234,33 +234,31 @@ quiet = TRUE)
## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, :
 ## Observations with value of zero were removed from the data
-
## Warning in mkinfit(Z.FOCUS, FOCUS_2006_Z_mkin, parms.ini = m.Z.5$bparms.ode, : Optimisation did not converge:
-## false convergence (8)
-
+
 plot_sep(m.Z.FOCUS)

-
+
 summary(m.Z.FOCUS, data = FALSE)$bpar
##             Estimate se_notrans t value     Pr(>t)     Lower      Upper
-## Z0_0       96.838822   1.994274 48.5584 4.0280e-42 92.826981 100.850664
-## k_Z0        2.215393   0.118458 18.7019 1.0413e-23  1.989456   2.466989
-## k_Z1        0.478305   0.028258 16.9266 6.2418e-22  0.424708   0.538666
-## k_Z2        0.451627   0.042139 10.7176 1.6314e-14  0.374339   0.544872
-## k_Z3        0.058692   0.015245  3.8499 1.7803e-04  0.034808   0.098965
-## f_Z2_to_Z3  0.471502   0.058351  8.0805 9.6608e-11  0.357769   0.588274
+## Z0_0       96.838397   1.994270 48.5583 4.0284e-42 92.826435 100.850359
+## k_Z0        2.215406   0.118459 18.7018 1.0416e-23  1.989466   2.467005
+## k_Z1        0.478300   0.028257 16.9267 6.2409e-22  0.424702   0.538662
+## k_Z2        0.451616   0.042137 10.7178 1.6305e-14  0.374328   0.544863
+## k_Z3        0.058693   0.015245  3.8499 1.7803e-04  0.034805   0.098976
+## f_Z2_to_Z3  0.471509   0.058352  8.0804 9.6622e-11  0.357739   0.588317
 ## sigma       3.984431   0.383402 10.3923 4.5575e-14  3.213126   4.755736
-
+
 endpoints(m.Z.FOCUS)
## $ff
 ##   Z2_Z3 Z2_sink 
-##  0.4715  0.5285 
+## 0.47151 0.52849 
 ## 
 ## $distimes
 ##        DT50    DT90
 ## Z0  0.31288  1.0394
-## Z1  1.44917  4.8141
-## Z2  1.53478  5.0984
-## Z3 11.80986 39.2315
+## Z1 1.44919 4.8141 +## Z2 1.53481 5.0985 +## Z3 11.80971 39.2310

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

@@ -268,32 +266,34 @@

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

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

-
+
 Z.mkin.1 <- mkinmod(Z0 = mkinsub("SFO", "Z1", sink = FALSE),
                     Z1 = mkinsub("SFO", "Z2", sink = FALSE),
                     Z2 = mkinsub("SFO", "Z3"),
                     Z3 = mkinsub("SFORB"))
## Temporary DLL for differentials generated and loaded
-
+
 m.Z.mkin.1 <- mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE)
## Warning in mkinfit(Z.mkin.1, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
 ## value of zero were removed from the data
-
+
 plot_sep(m.Z.mkin.1)

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

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

-
+
 Z.mkin.3 <- mkinmod(Z0 = mkinsub("SFORB", "Z1", sink = FALSE),
                     Z1 = mkinsub("SFO", "Z2", sink = FALSE),
                     Z2 = mkinsub("SFO"))
## Temporary DLL for differentials generated and loaded
-
+
 m.Z.mkin.3 <- mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE)
## Warning in mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE): Observations with
 ## value of zero were removed from the data
+
## Warning in mkinfit(Z.mkin.3, FOCUS_2006_Z_mkin, quiet = TRUE): Optimisation did not converge:
+## false convergence (8)
 plot_sep(m.Z.mkin.3)

@@ -359,11 +359,11 @@ ## ## $SFORB ## Z0_b1 Z0_b2 Z3_b1 Z3_b2 -## 2.4471322 0.0075125 0.0800069 0.0000000 +## 2.4471376 0.0075126 0.0800073 0.0000000 ## ## $distimes ## DT50 DT90 DT50back DT50_Z0_b1 DT50_Z0_b2 DT50_Z3_b1 DT50_Z3_b2 -## Z0 0.3043 1.1848 0.35666 0.28325 92.266 NA NA +## Z0 0.3043 1.1848 0.35666 0.28325 92.264 NA NA ## Z1 1.5148 5.0320 NA NA NA NA NA ## Z2 1.6414 5.4526 NA NA NA NA NA ## Z3 NA NA NA NA NA 8.6636 Inf
@@ -398,7 +398,7 @@

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png index bc6efaf7..229bae82 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_10-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png index 55c1b645..e13ad9aa 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png index 8e63cd04..ae160414 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11a-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png index 3902e059..23e270d1 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_11b-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png index d95cac25..77965455 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_5-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png index cb333a1c..250d0df5 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_6-1.png differ diff --git a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png index db807f14..5a01c03e 100644 Binary files a/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png and b/docs/articles/web_only/FOCUS_Z_files/figure-html/FOCUS_2006_Z_fits_9-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples.html b/docs/articles/web_only/NAFTA_examples.html index 996e5d49..df1e06db 100644 --- a/docs/articles/web_only/NAFTA_examples.html +++ b/docs/articles/web_only/NAFTA_examples.html @@ -43,7 +43,7 @@ Functions and data
@@ -212,7 +212,7 @@ ## Estimate Pr(>t) Lower Upper ## parent_0 9.84e+01 1.24e-27 97.8078 98.9187 ## k1 1.55e-02 4.10e-04 0.0143 0.0167 -## k2 8.63e-12 5.00e-01 0.0000 Inf +## k2 9.41e-12 5.00e-01 0.0000 Inf ## g 6.89e-01 2.92e-03 0.6626 0.7142 ## sigma 6.48e-01 2.38e-05 0.4147 0.8813 ## @@ -221,7 +221,7 @@ ## DT50 DT90 DT50_rep ## SFO 86.6 2.88e+02 8.66e+01 ## IORE 85.5 7.17e+02 2.16e+02 -## DFOP 83.6 1.32e+11 8.04e+10 +## DFOP 83.6 1.21e+11 7.36e+10 ## ## Representative half-life: ## [1] 215.87
@@ -263,7 +263,7 @@ ## Estimate Pr(>t) Lower Upper ## parent_0 9.66e+01 1.57e-25 95.3476 97.8979 ## k1 2.55e-02 7.33e-06 0.0233 0.0278 -## k2 3.22e-11 5.00e-01 0.0000 Inf +## k2 4.40e-11 5.00e-01 0.0000 Inf ## g 8.61e-01 7.55e-06 0.8314 0.8867 ## sigma 1.46e+00 6.93e-06 0.9661 1.9483 ## @@ -272,7 +272,7 @@ ## DT50 DT90 DT50_rep ## SFO 38.6 1.28e+02 3.86e+01 ## IORE 34.0 1.77e+02 5.32e+01 -## DFOP 34.1 1.01e+10 2.15e+10 +## DFOP 34.1 7.43e+09 1.58e+10 ## ## Representative half-life: ## [1] 53.17
@@ -314,7 +314,7 @@ ## Estimate Pr(>t) Lower Upper ## parent_0 9.89e+01 9.44e-49 95.4640 102.2573 ## k1 1.81e-02 1.75e-01 0.0116 0.0281 -## k2 3.63e-10 5.00e-01 0.0000 Inf +## k2 2.81e-10 5.00e-01 0.0000 Inf ## g 6.06e-01 2.19e-01 0.4826 0.7178 ## sigma 7.40e+00 2.97e-15 6.0201 8.7754 ## @@ -323,7 +323,7 @@ ## DT50 DT90 DT50_rep ## SFO 94.3 3.13e+02 9.43e+01 ## IORE 96.7 1.51e+03 4.55e+02 -## DFOP 96.4 3.77e+09 1.91e+09 +## DFOP 96.4 4.87e+09 2.46e+09 ## ## Representative half-life: ## [1] 454.55
@@ -434,7 +434,7 @@ ## DT50 DT90 DT50_rep ## SFO 16.9 5.63e+01 1.69e+01 ## IORE 11.6 3.37e+02 1.01e+02 -## DFOP 10.5 1.38e+12 7.69e+11 +## DFOP 10.5 1.38e+12 7.68e+11 ## ## Representative half-life: ## [1] 101.43
@@ -445,17 +445,12 @@
 p9b <- nafta(NAFTA_SOP_Attachment[["p9b"]])
-
## Warning in sqrt(diag(covar)): NaNs produced
-
## Warning in sqrt(diag(covar_notrans)): NaNs produced
-
## Warning in sqrt(1/diag(V)): NaNs produced
-
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
-## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p9b)

-
+
 print(p9b)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -482,8 +477,8 @@
 ##          Estimate   Pr(>t)   Lower   Upper
 ## parent_0  94.7123 1.61e-16 93.1355 96.2891
 ## k1         0.0389 1.08e-04  0.0266  0.0569
-## k2         0.0389 2.23e-04  0.0255  0.0592
-## g          0.5256      NaN      NA      NA
+## k2         0.0389 2.24e-04  0.0255  0.0592
+## g          0.5256 5.00e-01  0.0000  1.0000
 ## sigma      1.5957 2.50e-04  0.9135  2.2779
 ## 
 ## 
@@ -500,7 +495,7 @@
 

Example on page 10

-
+
 p10 <- nafta(NAFTA_SOP_Attachment[["p10"]])
## Warning in sqrt(diag(covar)): NaNs produced
## Warning in sqrt(1/diag(V)): NaNs produced
@@ -508,10 +503,10 @@ ## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p10)

-
+
 print(p10)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -537,8 +532,8 @@
 ## $DFOP
 ##          Estimate   Pr(>t)   Lower    Upper
 ## parent_0 101.7315 1.41e-09 91.6534 111.8097
-## k1         0.0495 6.58e-03  0.0303   0.0809
-## k2         0.0495 2.60e-03  0.0410   0.0598
+## k1         0.0495 6.32e-03  0.0241   0.1018
+## k2         0.0495 2.41e-03  0.0272   0.0901
 ## g          0.4487 5.00e-01      NA       NA
 ## sigma      8.0152 2.50e-04  4.5886  11.4418
 ## 
@@ -560,14 +555,14 @@
 

Example on page 11

-
+
 p11 <- nafta(NAFTA_SOP_Attachment[["p11"]])
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p11)

-
+
 print(p11)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -594,7 +589,7 @@
 ##          Estimate   Pr(>t)    Lower    Upper
 ## parent_0 1.05e+02 9.47e-13  99.9990 109.1224
 ## k1       4.41e-02 5.95e-03   0.0296   0.0658
-## k2       9.94e-13 5.00e-01   0.0000      Inf
+## k2       9.93e-13 5.00e-01   0.0000      Inf
 ## g        3.22e-01 1.45e-03   0.2814   0.3650
 ## sigma    3.22e+00 3.52e-04   1.8410   4.5906
 ## 
@@ -606,7 +601,7 @@
 ## DFOP 3.07e+11 1.93e+12 6.98e+11
 ## 
 ## Representative half-life:
-## [1] 41148170
+## [1] 41148171

In this case, the DFOP fit reported for PestDF resulted in a negative value for the slower rate constant, which is not possible in mkin. The other results are in agreement.

@@ -617,21 +612,19 @@

Example on page 12, upper panel

-
+
 p12a <- nafta(NAFTA_SOP_Attachment[["p12a"]])
## Warning in summary.mkinfit(x): Could not calculate correlation; no covariance
+## matrix
+
+## Warning in summary.mkinfit(x): Could not calculate correlation; no covariance
 ## matrix
-
## Warning in sqrt(diag(covar)): NaNs produced
-
## Warning in sqrt(diag(covar_notrans)): NaNs produced
-
## Warning in sqrt(1/diag(V)): NaNs produced
-
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
-## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p12a)

-
+
 print(p12a)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -655,12 +648,12 @@
 ## sigma             3.965     NA    NA    NA
 ## 
 ## $DFOP
-##          Estimate   Pr(>t)   Lower   Upper
-## parent_0  100.521 2.74e-10 92.2366 108.805
-## k1          0.124 2.53e-05  0.0908   0.170
-## k2          0.124 2.52e-02  0.0456   0.339
-## g           0.793      NaN      NA      NA
-## sigma       7.048 2.50e-04  4.0349  10.061
+##          Estimate Pr(>t) Lower Upper
+## parent_0  100.521     NA    NA    NA
+## k1          0.124     NA    NA    NA
+## k2          0.124     NA    NA    NA
+## g           0.793     NA    NA    NA
+## sigma       7.048     NA    NA    NA
 ## 
 ## 
 ## DTx values:
@@ -675,18 +668,17 @@
 

Example on page 12, lower panel

-
+
 p12b <- nafta(NAFTA_SOP_Attachment[["p12b"]])
## Warning in qt(alpha/2, rdf): NaNs produced
## Warning in qt(1 - alpha/2, rdf): NaNs produced
-
## Warning in sqrt(diag(covar_notrans)): NaNs produced
## Warning in pt(abs(tval), rdf, lower.tail = FALSE): NaNs produced
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p12b)

-
+
 print(p12b)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -730,14 +722,18 @@
 

Example on page 13

-
+
 p13 <- nafta(NAFTA_SOP_Attachment[["p13"]])
+
## Warning in sqrt(diag(covar)): NaNs produced
+
## Warning in sqrt(1/diag(V)): NaNs produced
+
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
+## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p13)

-
+
 print(p13)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -763,9 +759,9 @@
 ## $DFOP
 ##          Estimate Pr(>t)    Lower    Upper
 ## parent_0 92.73500     NA 8.95e+01 95.92118
-## k1        0.00258     NA 4.14e-04  0.01611
-## k2        0.00258     NA 1.74e-03  0.00383
-## g         0.16452     NA 0.00e+00  1.00000
+## k1        0.00258     NA 4.24e-04  0.01573
+## k2        0.00258     NA 1.76e-03  0.00379
+## g         0.16452     NA       NA       NA
 ## sigma     3.41172     NA 2.02e+00  4.79960
 ## 
 ## 
@@ -782,7 +778,7 @@
 

DT50 not observed in the study and DFOP problems in PestDF

-
+
 p14 <- nafta(NAFTA_SOP_Attachment[["p14"]])
## Warning in sqrt(diag(covar)): NaNs produced
## Warning in sqrt(1/diag(V)): NaNs produced
@@ -790,10 +786,10 @@ ## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p14)

-
+
 print(p14)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -820,7 +816,7 @@
 ##          Estimate   Pr(>t)    Lower    Upper
 ## parent_0 1.00e+02 2.96e-28 99.40280 101.2768
 ## k1       9.53e-03 1.20e-01  0.00638   0.0143
-## k2       6.08e-12 5.00e-01  0.00000      Inf
+## k2       5.03e-12 5.00e-01  0.00000      Inf
 ## g        3.98e-01 2.19e-01  0.30481   0.4998
 ## sigma    1.17e+00 7.68e-06  0.77406   1.5610
 ## 
@@ -829,7 +825,7 @@
 ##          DT50     DT90 DT50_rep
 ## SFO  2.48e+02 8.25e+02 2.48e+02
 ## IORE 4.34e+02 2.22e+04 6.70e+03
-## DFOP 3.05e+10 2.95e+11 1.14e+11
+## DFOP 3.69e+10 3.57e+11 1.38e+11
 ## 
 ## Representative half-life:
 ## [1] 6697.44
@@ -838,14 +834,18 @@

N is less than 1 and DFOP fraction parameter is below zero

-
+
 p15a <- nafta(NAFTA_SOP_Attachment[["p15a"]])
+
## Warning in sqrt(diag(covar)): NaNs produced
+
## Warning in sqrt(1/diag(V)): NaNs produced
+
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
+## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p15a)

-
+
 print(p15a)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -871,9 +871,9 @@
 ## $DFOP
 ##          Estimate   Pr(>t)    Lower    Upper
 ## parent_0 97.96751 2.85e-13 94.21913 101.7159
-## k1        0.00952 6.28e-02  0.00250   0.0363
-## k2        0.00952 1.27e-04  0.00646   0.0140
-## g         0.21241 5.00e-01  0.00000   1.0000
+## k1        0.00952 6.28e-02  0.00260   0.0349
+## k2        0.00952 1.27e-04  0.00652   0.0139
+## g         0.21241 5.00e-01       NA       NA
 ## sigma     4.18778 2.50e-04  2.39747   5.9781
 ## 
 ## 
@@ -885,18 +885,14 @@
 ## 
 ## Representative half-life:
 ## [1] 41.33
-
+
 p15b <- nafta(NAFTA_SOP_Attachment[["p15b"]])
-
## Warning in sqrt(diag(covar)): NaNs produced
-
## Warning in sqrt(1/diag(V)): NaNs produced
-
## Warning in cov2cor(ans$covar): diag(.) had 0 or NA entries; non-finite result is
-## doubtful
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The half-life obtained from the IORE model may be used
-
+
 plot(p15b)

-
+
 print(p15b)
## Sums of squares:
 ##       SFO      IORE      DFOP 
@@ -916,15 +912,15 @@
 ##                Estimate   Pr(>t)    Lower  Upper
 ## parent_0          99.83 1.81e-16 97.51349 102.14
 ## k__iore_parent     0.38 3.22e-01  0.00352  41.05
-## N_parent           0.00 5.00e-01 -1.07696   1.08
+## N_parent           0.00 5.00e-01 -1.07695   1.08
 ## sigma              2.21 2.57e-04  1.23245   3.19
 ## 
 ## $DFOP
 ##          Estimate Pr(>t)    Lower    Upper
 ## parent_0 1.01e+02     NA 9.82e+01 1.04e+02
-## k1       4.86e-03     NA 8.63e-04 2.73e-02
+## k1       4.86e-03     NA 8.62e-04 2.74e-02
 ## k2       4.86e-03     NA 3.21e-03 7.35e-03
-## g        1.88e-01     NA       NA       NA
+## g        1.88e-01     NA 0.00e+00 1.00e+00
 ## sigma    2.76e+00     NA 1.58e+00 3.94e+00
 ## 
 ## 
@@ -941,16 +937,16 @@
 

The DFOP fraction parameter is greater than 1

-
+
 p16 <- nafta(NAFTA_SOP_Attachment[["p16"]])
## The SFO model is rejected as S_SFO is equal or higher than the critical value S_c
## The representative half-life of the IORE model is longer than the one corresponding
## to the terminal degradation rate found with the DFOP model.
## The representative half-life obtained from the DFOP model may be used
-
+
 plot(p16)

-
+
 print(p16)
## Sums of squares:
 ##      SFO     IORE     DFOP 
@@ -1026,7 +1022,7 @@
 
 

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p10-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p10-1.png index 75611a70..a53c48b2 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p10-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p10-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p15a-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p15a-1.png index b6faeff9..fb211a8e 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p15a-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p15a-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p15b-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p15b-1.png index 6b9ba98c..9aedbf16 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p15b-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p15b-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p5b-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p5b-1.png index db90244b..034eed46 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p5b-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p5b-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p6-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p6-1.png index a33372e8..86cd9755 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p6-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p6-1.png differ diff --git a/docs/articles/web_only/NAFTA_examples_files/figure-html/p7-1.png b/docs/articles/web_only/NAFTA_examples_files/figure-html/p7-1.png index d64ea98d..10225504 100644 Binary files a/docs/articles/web_only/NAFTA_examples_files/figure-html/p7-1.png and b/docs/articles/web_only/NAFTA_examples_files/figure-html/p7-1.png differ diff --git a/docs/articles/web_only/benchmarks.html b/docs/articles/web_only/benchmarks.html index 2eea3cb2..058d43fa 100644 --- a/docs/articles/web_only/benchmarks.html +++ b/docs/articles/web_only/benchmarks.html @@ -43,7 +43,7 @@ Functions and data
## Temporary DLL for differentials generated and loaded
-FOCUS_D <- subset(FOCUS_2006_D, value != 0)
+FOCUS_D <- subset(FOCUS_2006_D, value != 0)

We can compare the performance of the Eigenvalue based solution against the compiled version and the R implementation of the differential equations using the benchmark package. In the output of below code, the warnings about zero being removed from the FOCUS D dataset are suppressed. Since mkin version 0.9.49.11, an analytical solution is also implemented, which is included in the tests below.

 if (require(rbenchmark)) {
-  b.1 <- benchmark(
+  b.1 <- benchmark(
     "deSolve, not compiled" = mkinfit(SFO_SFO, FOCUS_D,
        solution_type = "deSolve",
        use_compiled = FALSE, quiet = TRUE),
@@ -162,11 +162,7 @@
 } else {
   print("R package rbenchmark is not available")
 }
-
##                    test replications relative elapsed
-## 4            analytical            1    1.000   0.216
-## 3     deSolve, compiled            1    1.708   0.369
-## 2      Eigenvalue based            1    1.866   0.403
-## 1 deSolve, not compiled            1   34.009   7.346
+
## [1] "R package rbenchmark is not available"

We see that using the compiled model is by more than a factor of 10 faster than using deSolve without compiled code.

@@ -179,7 +175,7 @@ parent = mkinsub("FOMC", "m1"), m1 = mkinsub( "SFO")) - b.2 <- benchmark( + b.2 <- benchmark( "deSolve, not compiled" = mkinfit(FOMC_SFO, FOCUS_D, use_compiled = FALSE, quiet = TRUE), "deSolve, compiled" = mkinfit(FOMC_SFO, FOCUS_D, quiet = TRUE), @@ -191,16 +187,14 @@ factor_FOMC_SFO <- NA print("R package benchmark is not available") }
-
## Temporary DLL for differentials generated and loaded
-
##                    test replications relative elapsed
-## 2     deSolve, compiled            1    1.000   0.533
-## 1 deSolve, not compiled            1   25.146  13.403
-

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

+
## Loading required package: rbenchmark
+
## [1] "R package benchmark is not available"
+

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

This vignette was built with mkin 1.1.0 on

-
## R version 4.1.2 (2021-11-01)
+
## R version 4.2.0 (2022-04-22)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
 ## Running under: Debian GNU/Linux 11 (bullseye)
-
## CPU model: AMD Ryzen 7 1700 Eight-Core Processor
+
## CPU model: Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
@@ -221,7 +215,7 @@

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/web_only/dimethenamid_2018.html b/docs/articles/web_only/dimethenamid_2018.html index 09aa5150..7650f06f 100644 --- a/docs/articles/web_only/dimethenamid_2018.html +++ b/docs/articles/web_only/dimethenamid_2018.html @@ -105,7 +105,7 @@

Example evaluations of the dimethenamid data from 2018

Johannes Ranke

-

Last change 7 March 2022, built on 16 Mar 2022

+

Last change 7 March 2022, built on 18 May 2022

Source: vignettes/web_only/dimethenamid_2018.rmd @@ -178,7 +178,7 @@ Status of individual fits: dataset model Calke Borstel Flaach BBA 2.2 BBA 2.3 Elliot - DFOP OK OK C OK C OK + DFOP OK OK OK OK C OK OK: No warnings C: Optimisation did not converge: @@ -231,32 +231,41 @@ f_parent_nlme_dfop_tc 3 10 671.91 702.34 -325.96 2 vs 3 134.69 <.0001

The saemix package provided the first Open Source implementation of the Stochastic Approximation to the Expectation Maximisation (SAEM) algorithm. SAEM fits of degradation models can be conveniently performed using an interface to the saemix package available in current development versions of the mkin package.

The corresponding SAEM fits of the four combinations of degradation and error models are fitted below. As there is no convergence criterion implemented in the saemix package, the convergence plots need to be manually checked for every fit. We define control settings that work well for all the parent data fits shown in this vignette.

-library(saemix)
-saemix_control <- saemixControl(nbiter.saemix = c(800, 300), nb.chains = 15,
+library(saemix)
+
Loading required package: npde
+
Package saemix, version 3.0
+  please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr
+

+Attaching package: 'saemix'
+
The following objects are masked from 'package:npde':
+
+    kurtosis, skewness
+
+saemix_control <- saemixControl(nbiter.saemix = c(800, 300), nb.chains = 15,
     print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
 saemix_control_moreiter <- saemixControl(nbiter.saemix = c(1600, 300), nb.chains = 15,
     print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)
 saemix_control_10k <- saemixControl(nbiter.saemix = c(10000, 300), nb.chains = 15,
     print = FALSE, save = FALSE, save.graphs = FALSE, displayProgress = FALSE)

The convergence plot for the SFO model using constant variance is shown below.

-
+
 f_parent_saemix_sfo_const <- mkin::saem(f_parent_mkin_const["SFO", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_sfo_const$so, plot.type = "convergence")

Obviously the selected number of iterations is sufficient to reach convergence. This can also be said for the SFO fit using the two-component error model.

-
+
 f_parent_saemix_sfo_tc <- mkin::saem(f_parent_mkin_tc["SFO", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_sfo_tc$so, plot.type = "convergence")

When fitting the DFOP model with constant variance (see below), parameter convergence is not as unambiguous.

-
+
 f_parent_saemix_dfop_const <- mkin::saem(f_parent_mkin_const["DFOP", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 plot(f_parent_saemix_dfop_const$so, plot.type = "convergence")

-
+
 print(f_parent_saemix_dfop_const)
Kinetic nonlinear mixed-effects model fit by SAEM
 Structural model:
@@ -277,21 +286,23 @@ DMTA_0    97.99583 96.50079 99.4909
 k1         0.06377  0.03432  0.0932
 k2         0.00848  0.00444  0.0125
 g          0.95701  0.91313  1.0009
-a.1        1.82141  1.65974  1.9831
-SD.DMTA_0  1.64787  0.45779  2.8379
+a.1        1.82141  1.60516  2.0377
+SD.DMTA_0  1.64787  0.45729  2.8384
 SD.k1      0.57439  0.24731  0.9015
-SD.k2      0.03296 -2.50143  2.5673
-SD.g       1.10266  0.32371  1.8816
+SD.k2 0.03296 -2.50524 2.5712 +SD.g 1.10266 0.32354 1.8818

While the other parameters converge to credible values, the variance of k2 (omega2.k2) converges to a very small value. The printout of the saem.mmkin model shows that the estimated standard deviation of k2 across the population of soils (SD.k2) is ill-defined, indicating overparameterisation of this model.

When the DFOP model is fitted with the two-component error model, we also observe that the estimated variance of k2 becomes very small, while being ill-defined, as illustrated by the excessive confidence interval of SD.k2.

-
+
 f_parent_saemix_dfop_tc <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
   control = saemix_control, transformations = "saemix")
 f_parent_saemix_dfop_tc_moreiter <- mkin::saem(f_parent_mkin_tc["DFOP", ], quiet = TRUE,
-  control = saemix_control_moreiter, transformations = "saemix")
-plot(f_parent_saemix_dfop_tc$so, plot.type = "convergence")
+ control = saemix_control_moreiter, transformations = "saemix")
+
Likelihood cannot be computed by Importance Sampling.
+
+plot(f_parent_saemix_dfop_tc$so, plot.type = "convergence")

-
+
 print(f_parent_saemix_dfop_tc)
Kinetic nonlinear mixed-effects model fit by SAEM
 Structural model:
@@ -307,21 +318,21 @@ Likelihood computed by importance sampling
   666 664   -323
 
 Fitted parameters:
-          estimate    lower    upper
-DMTA_0    98.27617  96.3088 100.2436
-k1         0.06437   0.0337   0.0950
-k2         0.00880   0.0063   0.0113
-g          0.95249   0.9100   0.9949
-a.1        1.06161   0.8625   1.2607
-b.1        0.02967   0.0226   0.0367
-SD.DMTA_0  2.06075   0.4187   3.7028
-SD.k1      0.59357   0.2561   0.9310
-SD.k2      0.00292 -10.2960  10.3019
-SD.g       1.05725   0.3808   1.7337
+ estimate lower upper +DMTA_0 9.82e+01 96.27937 100.1783 +k1 6.41e-02 0.03333 0.0948 +k2 8.56e-03 0.00608 0.0110 +g 9.55e-01 0.91440 0.9947 +a.1 1.07e+00 0.86542 1.2647 +b.1 2.96e-02 0.02258 0.0367 +SD.DMTA_0 2.04e+00 0.40629 3.6678 +SD.k1 5.98e-01 0.25796 0.9373 +SD.k2 5.28e-04 -58.93251 58.9336 +SD.g 1.04e+00 0.36509 1.7083

Doubling the number of iterations in the first phase of the algorithm leads to a slightly lower likelihood, and therefore to slightly higher AIC and BIC values. With even more iterations, the algorithm stops with an error message. This is related to the variance of k2 approximating zero and has been submitted as a bug to the saemix package, as the algorithm does not converge in this case.

An alternative way to fit DFOP in combination with the two-component error model is to use the model formulation with transformed parameters as used per default in mkin. When using this option, convergence is slower, but eventually the algorithm stops as well with the same error message.

The four combinations (SFO/const, SFO/tc, DFOP/const and DFOP/tc) and the version with increased iterations can be compared using the model comparison function of the saemix package:

-
+
 AIC_parent_saemix <- saemix::compare.saemix(
   f_parent_saemix_sfo_const$so,
   f_parent_saemix_sfo_tc$so,
@@ -329,7 +340,7 @@ SD.g       1.05725   0.3808   1.7337
f_parent_saemix_dfop_tc$so, f_parent_saemix_dfop_tc_moreiter$so)
Likelihoods calculated by importance sampling
-
+
 rownames(AIC_parent_saemix) <- c(
   "SFO const", "SFO tc", "DFOP const", "DFOP tc", "DFOP tc more iterations")
 print(AIC_parent_saemix)
@@ -337,10 +348,10 @@ SD.g 1.05725 0.3808 1.7337
SFO const 796.38 795.34 SFO tc 798.38 797.13 DFOP const 705.75 703.88 -DFOP tc 665.65 663.57 -DFOP tc more iterations 665.88 663.80
+DFOP tc 665.72 663.63 +DFOP tc more iterations NaN NaN

In order to check the influence of the likelihood calculation algorithms implemented in saemix, the likelihood from Gaussian quadrature is added to the best fit, and the AIC values obtained from the three methods are compared.

-
+
 f_parent_saemix_dfop_tc$so <-
   saemix::llgq.saemix(f_parent_saemix_dfop_tc$so)
 AIC_parent_saemix_methods <- c(
@@ -350,9 +361,9 @@ DFOP tc more iterations 665.88 663.80
) print(AIC_parent_saemix_methods)
    is     gq    lin 
-665.65 665.68 665.11 
+665.72 665.88 665.15

The AIC values based on importance sampling and Gaussian quadrature are very similar. Using linearisation is known to be less accurate, but still gives a similar value. In order to illustrate that the comparison of the three method depends on the degree of convergence obtained in the fit, the same comparison is shown below for the fit using the defaults for the number of iterations and the number of MCMC chains.

-
+
 f_parent_saemix_dfop_tc_defaults <- mkin::saem(f_parent_mkin_tc["DFOP", ])
 f_parent_saemix_dfop_tc_defaults$so <-
   saemix::llgq.saemix(f_parent_saemix_dfop_tc_defaults$so)
@@ -363,14 +374,14 @@ DFOP tc more iterations 665.88 663.80
) print(AIC_parent_saemix_methods_defaults)
    is     gq    lin 
-668.27 718.36 666.49 
+668.91 663.61 667.40

Comparison

The following table gives the AIC values obtained with both backend packages using the same control parameters (800 iterations burn-in, 300 iterations second phase, 15 chains). Note that

-
+
 AIC_all <- data.frame(
   check.names = FALSE,
   "Degradation model" = c("SFO", "SFO", "DFOP", "DFOP"),
@@ -395,7 +406,7 @@ DFOP tc more iterations 665.88 663.80
SFO const 796.60 -796.60 +794.17 796.38 @@ -409,15 +420,15 @@ DFOP tc more iterations 665.88 663.80
DFOP const NA -671.98 +704.95 705.75 DFOP tc 671.91 -665.11 -665.65 +665.15 +665.72 @@ -464,7 +475,7 @@ DFOP tc more iterations 665.88 663.80

-

Site built with pkgdown 2.0.2.

+

Site built with pkgdown 2.0.3.

diff --git a/docs/articles/web_only/mkin_benchmarks.rda b/docs/articles/web_only/mkin_benchmarks.rda new file mode 100644 index 00000000..e26caf64 Binary files /dev/null and b/docs/articles/web_only/mkin_benchmarks.rda differ -- cgit v1.2.1