From 48a314feb6538774504c2b118cdbaededd2eb25b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 28 Jun 2016 08:06:03 +0200 Subject: Attempts to reduce vignette size Reducing the size of some figures and switching of retina figures in the preamble only gives a small decrease in vignette size, but may be enough to get the size of the doc directory below 5 MB to avoid the NOTE in the corresponding check (which I did not get locally, nor on winbuilder using r-devel. --- vignettes/FOCUS_D.Rmd | 5 ++-- vignettes/FOCUS_D.html | 19 ++++++++----- vignettes/FOCUS_L.Rmd | 1 + vignettes/FOCUS_L.html | 60 +++++++++++++++++++++--------------------- vignettes/compiled_models.Rmd | 5 ++-- vignettes/compiled_models.html | 49 ++++++++++++++++++---------------- vignettes/mkin.Rmd | 1 + vignettes/mkin.html | 12 ++++++--- 8 files changed, 86 insertions(+), 66 deletions(-) (limited to 'vignettes') diff --git a/vignettes/FOCUS_D.Rmd b/vignettes/FOCUS_D.Rmd index 4c65b80a..4edc7bf2 100644 --- a/vignettes/FOCUS_D.Rmd +++ b/vignettes/FOCUS_D.Rmd @@ -6,6 +6,7 @@ output: html_document: mathjax: null theme: united + fig_retina: null vignette: > %\VignetteIndexEntry{Example evaluation of FOCUS Example Dataset D} %\VignetteEngine{knitr::rmarkdown} @@ -52,14 +53,14 @@ fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) A plot of the fit including a residual plot for both observed variables is obtained using the `plot` method for `mkinfit` objects. -```{r, fig.height = 7} +```{r, fig.height = 5} plot(fit, show_residuals = TRUE) ``` Confidence intervals for the parameter estimates are obtained using the `mkinparplot` function. -```{r} +```{r, fig.height = 4} mkinparplot(fit) ``` diff --git a/vignettes/FOCUS_D.html b/vignettes/FOCUS_D.html index e01c5869..f3eb6a0c 100644 --- a/vignettes/FOCUS_D.html +++ b/vignettes/FOCUS_D.html @@ -124,8 +124,13 @@ $(document).ready(function () {

This is just a very simple vignette showing how to fit a degradation model for a parent compound with one transformation product using mkin. After loading the library we look a the data. We have observed concentrations in the column named value at the times specified in column time for the two observed variables named parent and m1.

-
library("mkin")
-print(FOCUS_2006_D)
+
library("mkin")
+
## Loading required package: minpack.lm
+
## Loading required package: rootSolve
+
## Loading required package: inline
+
## Loading required package: methods
+
## Loading required package: parallel
+
print(FOCUS_2006_D)
##      name time  value
 ## 1  parent    0  99.46
 ## 2  parent    0 102.04
@@ -184,16 +189,16 @@ print(FOCUS_2006_D)
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)

A plot of the fit including a residual plot for both observed variables is obtained using the plot method for mkinfit objects.

plot(fit, show_residuals = TRUE)
-

+

Confidence intervals for the parameter estimates are obtained using the mkinparplot function.

mkinparplot(fit)
-

+

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

summary(fit)
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:43 2016 
-## Date of summary: Tue Jun 28 01:59:44 2016 
+## Date of fit:     Tue Jun 28 07:48:50 2016 
+## Date of summary: Tue Jun 28 07:48:50 2016 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent - k_parent_m1 * parent
@@ -201,7 +206,7 @@ print(FOCUS_2006_D)
## ## Model predictions using solution type deSolve ## -## Fitted with method Port using 153 model solutions performed in 1.698 s +## Fitted with method Port using 153 model solutions performed in 1.659 s ## ## Weighting: none ## diff --git a/vignettes/FOCUS_L.Rmd b/vignettes/FOCUS_L.Rmd index ed480643..72a5ba34 100644 --- a/vignettes/FOCUS_L.Rmd +++ b/vignettes/FOCUS_L.Rmd @@ -7,6 +7,7 @@ output: toc: true toc_float: true mathjax: null + fig_retina: null references: - id: ranke2014 title: Prüfung und Validierung von Modellierungssoftware als Alternative zu diff --git a/vignettes/FOCUS_L.html b/vignettes/FOCUS_L.html index 828d9def..8435ce23 100644 --- a/vignettes/FOCUS_L.html +++ b/vignettes/FOCUS_L.html @@ -235,15 +235,15 @@ FOCUS_2006_L1_mkin <- mkin_wide_to_long(FOCUS_2006_L1) summary(m.L1.SFO)
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:45 2016 
-## Date of summary: Tue Jun 28 01:59:45 2016 
+## Date of fit:     Tue Jun 28 07:38:06 2016 
+## Date of summary: Tue Jun 28 07:38:06 2016 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 37 model solutions performed in 0.243 s
+## Fitted with method Port using 37 model solutions performed in 0.235 s
 ## 
 ## Weighting: none
 ## 
@@ -315,21 +315,21 @@ summary(m.L1.SFO)
## 30 parent 4.0 5.251 -1.2513

A plot of the fit is obtained with the plot function for mkinfit objects.

plot(m.L1.SFO, show_errmin = TRUE, main = "FOCUS L1 - SFO")
-

+

The residual plot can be easily obtained by

mkinresplot(m.L1.SFO, ylab = "Observed", xlab = "Time")
-

+

For comparison, the FOMC model is fitted as well, and the χ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 by method Port did not converge.
 ## Convergence code is 1
plot(m.L1.FOMC, show_errmin = TRUE, main = "FOCUS L1 - FOMC")
-

+

summary(m.L1.FOMC, data = FALSE)
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:47 2016 
-## Date of summary: Tue Jun 28 01:59:47 2016 
+## Date of fit:     Tue Jun 28 07:38:07 2016 
+## Date of summary: Tue Jun 28 07:38:07 2016 
 ## 
 ## 
 ## Warning: Optimisation by method Port did not converge.
@@ -341,7 +341,7 @@ summary(m.L1.SFO)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 188 model solutions performed in 1.241 s +## Fitted with method Port using 188 model solutions performed in 1.119 s ## ## Weighting: none ## @@ -410,7 +410,7 @@ FOCUS_2006_L2_mkin <- mkin_wide_to_long(FOCUS_2006_L2)
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")
-

+

The χ2 error level of 14% suggests that the model does not fit very well. This is also obvious from the plots of the fit, in which we have included the residual plot.

In the FOCUS kinetics report, it is stated that there is no apparent systematic error observed from the residual plot up to the measured DT90 (approximately at day 5), and there is an underestimation beyond that point.

We may add that it is difficult to judge the random nature of the residuals just from the three samplings at days 0, 1 and 3. Also, it is not clear a priori why a consistent underestimation after the approximate DT90 should be irrelevant. However, this can be rationalised by the fact that the FOCUS fate models generally only implement SFO kinetics.

@@ -421,19 +421,19 @@ plot(m.L2.SFO, show_residuals = TRUE, show_errmin = TRUE,
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:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:49 2016 
-## Date of summary: Tue Jun 28 01:59:49 2016 
+## Date of fit:     Tue Jun 28 07:38:09 2016 
+## Date of summary: Tue Jun 28 07:38:09 2016 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 81 model solutions performed in 0.534 s
+## Fitted with method Port using 81 model solutions performed in 0.492 s
 ## 
 ## Weighting: none
 ## 
@@ -491,12 +491,12 @@ plot(m.L2.FOMC, show_residuals = TRUE,
 
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:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:52 2016 
-## Date of summary: Tue Jun 28 01:59:52 2016 
+## Date of fit:     Tue Jun 28 07:38:11 2016 
+## Date of summary: Tue Jun 28 07:38:11 2016 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -505,7 +505,7 @@ plot(m.L2.DFOP, show_residuals = TRUE, show_errmin = TRUE,
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 336 model solutions performed in 2.286 s
+## Fitted with method Port using 336 model solutions performed in 2.04 s
 ## 
 ## Weighting: none
 ## 
@@ -574,7 +574,7 @@ FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3)
mm.L3 <- mmkin(c("SFO", "FOMC", "DFOP"), cores = 1, list("FOCUS L3" = FOCUS_2006_L3_mkin), quiet = TRUE) plot(mm.L3)
-

+

The χ2 error level of 21% as well as the plot suggest that the SFO model does not fit very well. The FOMC model performs better, with an error level at which the χ2 test passes of 7%. Fitting the four parameter DFOP model further reduces the χ2 error level considerably.

@@ -584,8 +584,8 @@ plot(mm.L3)
summary(mm.L3[["DFOP", 1]])
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:55 2016 
-## Date of summary: Tue Jun 28 01:59:56 2016 
+## Date of fit:     Tue Jun 28 07:38:13 2016 
+## Date of summary: Tue Jun 28 07:38:13 2016 
 ## 
 ## Equations:
 ## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -594,7 +594,7 @@ plot(mm.L3)
## ## Model predictions using solution type analytical ## -## Fitted with method Port using 137 model solutions performed in 0.907 s +## Fitted with method Port using 137 model solutions performed in 0.846 s ## ## Weighting: none ## @@ -661,7 +661,7 @@ plot(mm.L3) ## 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 χ2 error level criterion for laboratory data L3.

This is also an example where the standard t-test for the parameter g_ilr is misleading, as it tests for a significant difference from zero. In this case, zero appears to be the correct value for this parameter, and the confidence interval for the backtransformed parameter g is quite narrow.

@@ -679,20 +679,20 @@ mm.L4 <- mmkin(c("SFO", "FOMC"), cores = 1, list("FOCUS L4" = FOCUS_2006_L4_mkin), quiet = TRUE) plot(mm.L4) -

+

The χ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 χ2 test passes is slightly lower for the FOMC model. However, the difference appears negligible.

summary(mm.L4[["SFO", 1]], data = FALSE)
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:57 2016 
-## Date of summary: Tue Jun 28 01:59:58 2016 
+## Date of fit:     Tue Jun 28 07:38:14 2016 
+## Date of summary: Tue Jun 28 07:38:14 2016 
 ## 
 ## Equations:
 ## d_parent = - k_parent_sink * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 46 model solutions performed in 0.306 s
+## Fitted with method Port using 46 model solutions performed in 0.283 s
 ## 
 ## Weighting: none
 ## 
@@ -744,15 +744,15 @@ plot(mm.L4)
summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version:    0.9.43 
 ## R version:       3.3.1 
-## Date of fit:     Tue Jun 28 01:59:57 2016 
-## Date of summary: Tue Jun 28 01:59:58 2016 
+## Date of fit:     Tue Jun 28 07:38:14 2016 
+## Date of summary: Tue Jun 28 07:38:15 2016 
 ## 
 ## Equations:
 ## d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent
 ## 
 ## Model predictions using solution type analytical 
 ## 
-## Fitted with method Port using 66 model solutions performed in 0.42 s
+## Fitted with method Port using 66 model solutions performed in 0.383 s
 ## 
 ## Weighting: none
 ## 
diff --git a/vignettes/compiled_models.Rmd b/vignettes/compiled_models.Rmd
index 03604cc7..7a8ef6f1 100644
--- a/vignettes/compiled_models.Rmd
+++ b/vignettes/compiled_models.Rmd
@@ -4,6 +4,7 @@ author: "Johannes Ranke"
 date: "`r Sys.Date()`"
 output:
   html_document:
+    theme: united
     toc: true
     toc_float: true
     mathjax: null
@@ -43,7 +44,7 @@ compiled version and the R implementation of the differential equations using
 the microbenchmark package.
 
 
-```{r benchmark_SFO_SFO}
+```{r benchmark_SFO_SFO, fig.height = 3}
 library("microbenchmark")
 library("ggplot2")
 mb.1 <- microbenchmark(
@@ -76,7 +77,7 @@ smb.1["median"]/smb.1["deSolve, compiled", "median"]
 
 This evaluation is also taken from the example section of mkinfit. 
 
-```{r benchmark_FOMC_SFO}
+```{r benchmark_FOMC_SFO, fig.height = 3}
 FOMC_SFO <- mkinmod(
   parent = mkinsub("FOMC", "m1"),
   m1 = mkinsub( "SFO"))
diff --git a/vignettes/compiled_models.html b/vignettes/compiled_models.html
index 5e426a7f..c3ffb035 100644
--- a/vignettes/compiled_models.html
+++ b/vignettes/compiled_models.html
@@ -20,7 +20,7 @@
 
 
 
-
+
 
 
 
@@ -226,8 +226,13 @@ div.tocify {
 
##            gcc 
 ## "/usr/bin/gcc"

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

-
library("mkin")
-SFO_SFO <- mkinmod(
+
library("mkin")
+
## Loading required package: minpack.lm
+
## Loading required package: rootSolve
+
## Loading required package: inline
+
## Loading required package: methods
+
## Loading required package: parallel
+
SFO_SFO <- mkinmod(
   parent = mkinsub("SFO", "m1"),
   m1 = mkinsub("SFO"))
## Successfully compiled differential equation model from auto-generated C code.
@@ -250,22 +255,22 @@ mb.1 <- microbenchmark( print(mb.1)
## Unit: seconds
 ##                   expr       min        lq      mean    median        uq
-##  deSolve, not compiled 25.042204 25.078629 25.467550 25.115054 25.680223
-##       Eigenvalue based  2.273059  2.277424  2.285719  2.281790  2.292049
-##      deSolve, compiled  1.878785  1.883750  1.891594  1.888716  1.897998
+##  deSolve, not compiled 13.694897 13.774112 13.820936 13.853327 13.883956
+##       Eigenvalue based  2.087861  2.089503  2.116323  2.091145  2.130555
+##      deSolve, compiled  1.794975  1.799892  1.814653  1.804808  1.824492
 ##        max neval cld
-##  26.245391     3   b
-##   2.302308     3  a 
-##   1.907281     3  a
+## 13.914585 3 c +## 2.169964 3 b +## 1.844177 3 a
autoplot(mb.1)
-

-

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

+

+

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

rownames(smb.1) <- smb.1$expr
 smb.1["median"]/smb.1["deSolve, compiled", "median"]
-
##                          median
-## deSolve, not compiled 13.297425
-## Eigenvalue based       1.208117
-## deSolve, compiled      1.000000
+
##                         median
+## deSolve, not compiled 7.675788
+## Eigenvalue based      1.158652
+## deSolve, compiled     1.000000

Benchmark for a model that can not be solved with Eigenvalues

@@ -285,19 +290,19 @@ smb.1["median"]/smb.1["deSolve, compiled", "median"
smb.2 <- summary(mb.2)
 print(mb.2)
## Unit: seconds
-##                   expr      min        lq      mean    median        uq
-##  deSolve, not compiled 53.69252 53.938844 54.137601 54.185167 54.360141
-##      deSolve, compiled  3.42508  3.526298  3.588392  3.627516  3.670048
+##                   expr       min        lq      mean   median        uq
+##  deSolve, not compiled 29.120048 29.170013 29.246607 29.21998 29.309886
+##      deSolve, compiled  3.338458  3.343954  3.379437  3.34945  3.399926
 ##        max neval cld
-##  54.535116     3   b
-##   3.712579     3  a
+## 29.399796 3 b +## 3.450402 3 a
smb.2["median"]/smb.2["deSolve, compiled", "median"]
##   median
 ## 1     NA
 ## 2     NA
autoplot(mb.2)
-

-

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

+

+

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

This vignette was built with mkin 0.9.43 on

## R version 3.3.1 (2016-06-21)
 ## Platform: x86_64-pc-linux-gnu (64-bit)
diff --git a/vignettes/mkin.Rmd b/vignettes/mkin.Rmd
index 03e8548a..3f579519 100644
--- a/vignettes/mkin.Rmd
+++ b/vignettes/mkin.Rmd
@@ -7,6 +7,7 @@ output:
     toc: true
     toc_float: true
     code_folding: hide
+    fig_retina: null
 bibliography: references.bib
 vignette: >
   %\VignetteEngine{knitr::rmarkdown}
diff --git a/vignettes/mkin.html b/vignettes/mkin.html
index 9a76dc48..54605dfc 100644
--- a/vignettes/mkin.html
+++ b/vignettes/mkin.html
@@ -236,8 +236,14 @@ div.tocify {
 

Abstract

In the regulatory evaluation of chemical substances like plant protection products (pesticides), biocides and other chemicals, degradation data play an important role. For the evaluation of pesticide degradation experiments, detailed guidance has been developed, based on nonlinear optimisation. The R add-on package mkin (Ranke 2016) implements fitting some of the models recommended in this guidance from within R and calculates some statistical measures for data series within one or more compartments, for parent and metabolites.

-
require(mkin)
-m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
+
require(mkin)
+
## Loading required package: mkin
+
## Loading required package: minpack.lm
+
## Loading required package: rootSolve
+
## Loading required package: inline
+
## Loading required package: methods
+
## Loading required package: parallel
+
m_SFO_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"),
                          M1 = mkinsub("SFO", "M2"),
                          M2 = mkinsub("SFO"), 
                          use_of_ff = "max", quiet = TRUE)
@@ -256,7 +262,7 @@ d_SFO_SFO_SFO_err <- add_err(d_SFO_SFO_SFO, function(x) 3, n = 1, seed = 1234
 f_SFO_SFO_SFO <- mkinfit(m_SFO_SFO_SFO, d_SFO_SFO_SFO_err[[1]], quiet = TRUE)
 
 plot_sep(f_SFO_SFO_SFO, lpos = c("topright", "bottomright", "bottomright"))
-

+

Background

-- cgit v1.2.1