From f39815aa87272849f8e0c808099c4cee780c2a81 Mon Sep 17 00:00:00 2001
From: Johannes Ranke A plot of the fit including a residual plot for both observed variables is obtained using the Confidence intervals for the parameter estimates are obtained using the A comprehensive report of the results is obtained using the fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
plot
method for mkinfit
objects.plot(fit, show_residuals = TRUE)
mkinparplot
function.mkinparplot(fit)
summary
method for mkinfit
objects.summary(fit)
## mkin version: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:10 2016
-## Date of summary: Wed Oct 26 23:18:10 2016
+## R version: 3.3.2
+## Date of fit: Wed Nov 2 16:25:22 2016
+## Date of summary: Wed Nov 2 16:25:22 2016
##
## Equations:
## d_parent = - k_parent_sink * parent - k_parent_m1 * parent
@@ -122,7 +125,7 @@
##
## Model predictions using solution type deSolve
##
-## Fitted with method Port using 153 model solutions performed in 0.628 s
+## Fitted with method Port using 153 model solutions performed in 0.665 s
##
## Weighting: none
##
@@ -243,7 +246,7 @@
summary(m.L1.FOMC, data = FALSE)
## mkin version: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:12 2016
-## Date of summary: Wed Oct 26 23:18:12 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:49 2016
+## Date of summary: Thu Nov 3 17:47:49 2016
##
##
## Warning: Optimisation by method Port did not converge.
@@ -166,7 +169,7 @@ FOCUS_2006_L1_mkin <-
summary(m.L2.FOMC, data = FALSE)
## mkin version: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:12 2016
-## Date of summary: Wed Oct 26 23:18:12 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:49 2016
+## Date of summary: Thu Nov 3 17:47:49 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.191 s
+## Fitted with method Port using 81 model solutions performed in 0.189 s
##
## Weighting: none
##
@@ -319,9 +322,9 @@ FOCUS_2006_L2_mkin <-
summary(m.L2.DFOP, data = FALSE)
## mkin version: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:13 2016
-## Date of summary: Wed Oct 26 23:18:14 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:50 2016
+## Date of summary: Thu Nov 3 17:47:50 2016
##
## Equations:
## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -330,7 +333,7 @@ FOCUS_2006_L2_mkin <- t = c(0, 3, 7, 14, 30, 60, 91, 120),
parent = c(97.8, 60, 51, 43, 35, 22, 15, 12))
FOCUS_2006_L3_mkin <- mkin_wide_to_long(FOCUS_2006_L3)
-
- Use mmkin to fit multiple models
+
+ 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,
@@ -402,15 +405,15 @@ mm.L3 <-
The \(\chi^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 \(\chi^2\) test passes of 7%. Fitting the four parameter DFOP model further reduces the \(\chi^2\) error level considerably.
-
- Accessing elements of mmkin objects
+
+ Accessing mmkin objects
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: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:15 2016
-## Date of summary: Wed Oct 26 23:18:15 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:51 2016
+## Date of summary: Thu Nov 3 17:47:52 2016
##
## Equations:
## d_parent = - ((k1 * g * exp(-k1 * time) + k2 * (1 - g) * exp(-k2 *
@@ -419,7 +422,7 @@ mm.L3 <- \(\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: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:15 2016
-## Date of summary: Wed Oct 26 23:18:16 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:52 2016
+## Date of summary: Thu Nov 3 17:47:52 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.108 s
+## Fitted with method Port using 46 model solutions performed in 0.107 s
##
## Weighting: none
##
@@ -568,16 +571,16 @@ mm.L4 <- summary(mm.L4[["FOMC", 1]], data = FALSE)
## mkin version: 0.9.44.9000
-## R version: 3.3.1
-## Date of fit: Wed Oct 26 23:18:16 2016
-## Date of summary: Wed Oct 26 23:18:16 2016
+## R version: 3.3.2
+## Date of fit: Thu Nov 3 17:47:52 2016
+## Date of summary: Thu Nov 3 17:47:52 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.151 s
+## Fitted with method Port using 66 model solutions performed in 0.148 s
##
## Weighting: none
##
@@ -647,8 +650,8 @@ mm.L4 <- FOMC fit for L2
DFOP fit for L2
- Laboratory Data L3
diff --git a/docs/articles/FOCUS_Z.pdf b/docs/articles/FOCUS_Z.pdf
index bc37c873..6f71d018 100644
Binary files a/docs/articles/FOCUS_Z.pdf and b/docs/articles/FOCUS_Z.pdf differ
diff --git a/docs/articles/compiled_models.html b/docs/articles/compiled_models.html
index e02b9cf3..5a04168e 100644
--- a/docs/articles/compiled_models.html
+++ b/docs/articles/compiled_models.html
@@ -16,13 +16,16 @@
@@ -75,21 +78,21 @@ mb.1 <- micr
print(mb.1)
## Unit: milliseconds
## expr min lq mean median uq
-## deSolve, not compiled 6298.7342 6308.6792 6343.9668 6318.6243 6366.5831
-## Eigenvalue based 871.7379 880.7757 903.5267 889.8135 919.4211
-## deSolve, compiled 724.9025 730.6729 732.9837 736.4432 737.0243
+## deSolve, not compiled 6306.4527 6340.7895 6403.5937 6375.1264 6452.1643
+## Eigenvalue based 918.0808 929.7217 948.9742 941.3626 964.4210
+## deSolve, compiled 736.1337 753.6016 773.5605 771.0696 792.2739
## max neval cld
-## 6414.5420 3 c
-## 949.0287 3 b
-## 737.6054 3 a
+## 6529.2022 3 b
+## 987.4793 3 a
+## 813.4783 3 a
autoplot(mb.1)
-We see that using the compiled model is by a factor of 8.6 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 8.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:
rownames(smb.1) <- smb.1$expr
smb.1["median"]/smb.1["deSolve, compiled", "median"]
## median
-## deSolve, not compiled 8.579920
-## Eigenvalue based 1.208258
+## deSolve, not compiled 8.267900
+## Eigenvalue based 1.220853
## deSolve, compiled 1.000000
@@ -111,20 +114,20 @@ smb.1["median"]/smbprint(mb.2)
## Unit: seconds
## expr min lq mean median uq
-## deSolve, not compiled 13.265212 13.330161 13.412053 13.395109 13.485473
-## deSolve, compiled 1.322466 1.326851 1.364827 1.331236 1.386007
+## deSolve, not compiled 13.604720 13.667244 13.689764 13.729768 13.732286
+## deSolve, compiled 1.305077 1.311124 1.328943 1.317172 1.340876
## max neval cld
-## 13.575837 3 b
-## 1.440779 3 a
+## 13.734804 3 b
+## 1.364579 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 10.1 using the version of the differential equation model compiled from C code!
+Here we get a performance benefit of a factor of 10.4 using the version of the differential equation model compiled from C code!
This vignette was built with mkin 0.9.44.9000 on
-## R version 3.3.1 (2016-06-21)
+## R version 3.3.2 (2016-10-31)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Debian GNU/Linux 8 (jessie)
## CPU model: Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz
@@ -144,7 +147,7 @@ smb.1["median"]/smb
@@ -125,10 +130,7 @@
Technology 24, 1032-1038
-
-
- Examples
-
+ Examples
plot(function(x) FOMC.solution(x, 100, 10, 2), 0, 2, ylim = c(0, 100))
@@ -111,10 +116,7 @@
http://focus.jrc.ec.europa.eu/dk
-
-
- Examples
-
+ Examples
plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100))
@@ -112,10 +117,7 @@
Media
-
-
- Examples
-
+ Examples
plot(function(x) IORE.solution(x, 100, 0.2, 1.3), 0, 2,
ylim = c(0, 100)) fit.fomc <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE)
fit.iore <- mkinfit("IORE", FOCUS_2006_C, quiet = TRUE)
@@ -125,13 +127,11 @@
row.names = paste("model par", 1:3)))#> coef.fit.fomc. coef.fit.iore. coef.fit.iore.deS.
#> model par 1 85.87489063 85.874891 85.874890
#> model par 2 0.05192238 -4.826631 -4.826631
-#> model par 3 0.65096665 1.949403 1.949403
-#> print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes,
+#> model par 3 0.65096665 1.949403 1.949403 print(rbind(fomc = endpoints(fit.fomc)$distimes, iore = endpoints(fit.iore)$distimes,
iore.deS = endpoints(fit.iore)$distimes))#> DT50 DT90 DT50back
#> fomc 1.785233 15.1479 4.559973
#> iore 1.785233 15.1479 4.559973
-#> iore.deS 1.785233 15.1479 4.559973
-#>
+#> iore.deS 1.785233 15.1479 4.559973
@@ -104,10 +109,7 @@
http://focus.jrc.ec.europa.eu/dk
- @@ -113,10 +118,7 @@ http://focus.jrc.ec.europa.eu/dk -## Not run: plot(function(x) SFO.solution(x, 100, 3), 0, 2)
@@ -135,13 +140,10 @@ http://chem.uft.uni-bremen.de/ranke/posters/piacenza_2015.pdf -## Not run: plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)
@@ -80,175 +85,180 @@# The kinetic model m_SFO_SFO <- mkinmod(parent = mkinsub("SFO", "M1"), - M1 = mkinsub("SFO"), use_of_ff = "max")Successfully compiled differential equation model from auto-generated C code.#># Generate a prediction for a specific set of parameters sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) @@ -200,7 +202,7 @@@@ -96,7 +101,7 @@ with the advantage that the SFORB model can also be used for metabolites. -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/endpoints.html b/docs/reference/endpoints.html index 73d7e746..6ff7ac36 100644 --- a/docs/reference/endpoints.html +++ b/docs/reference/endpoints.html @@ -61,7 +61,12 @@Note
-The function is used internally by
+summary.mkinfit
.The function is used internally by
summary.mkinfit
.Value
@@ -123,7 +128,7 @@ with the advantage that the SFORB model can also be used for metabolites. -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/geometric_mean.html b/docs/reference/geometric_mean.html index 62a9163f..a4b661e2 100644 --- a/docs/reference/geometric_mean.html +++ b/docs/reference/geometric_mean.html @@ -60,7 +60,12 @@@@ -94,14 +99,8 @@The geometric mean.
-- - Examples -
-+geometric_mean(c(1,3, 9))#> [1] 3 -#>geometric_mean(c(1,3, NA))#> [1] NA -#>geometric_mean(c(1,3, NA), na.rm = TRUE)#> [1] 1.732051 -#>Examples
+@@ -107,31 +112,17 @@geometric_mean(c(1,3, 9))#> [1] 3geometric_mean(c(1,3, NA))#> [1] NAgeometric_mean(c(1,3, NA), na.rm = TRUE)#> [1] 1.732051Another implementation can be found in R package
-robCompositions
.- - Examples -
+Examples
+length(b) # Four elements# Order matters -ilr(c(0.1, 1, 10))#> [1] -1.628174 -2.820079 -#>ilr(c(10, 1, 0.1))#> [1] 1.628174 2.820079 -#># Equal entries give ilr transformations with zeros as elements -ilr(c(3, 3, 3))#> [1] 0 0 -#># Almost equal entries give small numbers -ilr(c(0.3, 0.4, 0.3))#> [1] -0.2034219 0.1174457 -#># Only the ratio between the numbers counts, not their sum -invilr(ilr(c(0.7, 0.29, 0.01)))#> [1] 0.70 0.29 0.01 -#>invilr(ilr(2.1 * c(0.7, 0.29, 0.01)))#> [1] 0.70 0.29 0.01 -#># Inverse transformation of larger numbers gives unequal elements -invilr(-10)#> [1] 7.213536e-07 9.999993e-01 -#>invilr(c(-10, 0))#> [1] 7.207415e-07 9.991507e-01 8.486044e-04 -#># The sum of the elements of the inverse ilr is 1 -sum(invilr(c(-10, 0)))#> [1] 1 -#># This is why we do not need all elements of the inverse transformation to go back: +ilr(c(0.1, 1, 10))#> [1] -1.628174 -2.820079ilr(c(10, 1, 0.1))#> [1] 1.628174 2.820079# Equal entries give ilr transformations with zeros as elements +ilr(c(3, 3, 3))#> [1] 0 0# Almost equal entries give small numbers +ilr(c(0.3, 0.4, 0.3))#> [1] -0.2034219 0.1174457# Only the ratio between the numbers counts, not their sum +invilr(ilr(c(0.7, 0.29, 0.01)))#> [1] 0.70 0.29 0.01invilr(ilr(2.1 * c(0.7, 0.29, 0.01)))#> [1] 0.70 0.29 0.01# Inverse transformation of larger numbers gives unequal elements +invilr(-10)#> [1] 7.213536e-07 9.999993e-01invilr(c(-10, 0))#> [1] 7.207415e-07 9.991507e-01 8.486044e-04# The sum of the elements of the inverse ilr is 1 +sum(invilr(c(-10, 0)))#> [1] 1# This is why we do not need all elements of the inverse transformation to go back: a <- c(0.1, 0.3, 0.5) b <- invilr(a) -length(b) # Four elements#> [1] 4 -#>ilr(c(b[1:3], 1 - sum(b[1:3]))) # Gives c(0.1, 0.3, 0.5)#> [1] 0.1 0.3 0.5 -#>#> [1] 4ilr(c(b[1:3], 1 - sum(b[1:3]))) # Gives c(0.1, 0.3, 0.5)#> [1] 0.1 0.3 0.5
Essential functionality
- + +Fit a kinetic model to data with one or more state variables
- + +Function to set up a kinetic model with one or more state variables
- + +Fit one or more kinetic models with one or more state variables to one or more datasets
Functions working with mkinfit objects
- + +Function to calculate endpoints for further use from kinetic models fitted with mkinfit
- + +Calculate the minimum error to assume in order to pass the variance test
- + +Function to plot the confidence intervals obtained using + mkinfit
- + +Function to plot residuals stored in an mkin object
- - - -Functions working with aggregated results
+Subsetting method for mmkin objects
- + +Plot model fits (observed and fitted) and the residuals for a row or column of an mmkin object
Results of fitting the DFOP model to Datasets A to B of FOCUS (2006)
- + +Results of fitting the FOMC model to Datasets A to F of FOCUS (2006)
- + +Results of fitting the HS model to Datasets A to F of FOCUS (2006)
- + +Results of fitting the SFO model to Datasets A to F of FOCUS (2006)
- + +Datasets on aerobic soil metabolism of 2,4,5-T in six soils
- + + - + + +print.mkinds
Synthetic datasets for one parent compound with two metabolites
Convert a dataframe from long to wide format
- + +Convert a dataframe with observations over time into long format
- + +Produce predictions from a kinetic model using specific parameters
- + +Function to set up a kinetic submodel for one state variable
- - - + + - -Parent only model solutions
- + +Double First-Order in Parallel kinetics
-First-Order Multi-Compartment kinetics
+ +First-Order Multi-Compartment kinetics
- + + -Indeterminate order rate equation kinetics
+ +Indeterminate order rate equation kinetics
-Single First-Order Reversible Binding kinetics
+ + +SFO.solution
Single First-Order Reversible Binding kinetics
+Add normally distributed errors to simulated kinetic degradation data
+add_err
Functions that have been superseeded
- + +Plot the observed data and the fitted model of an mkinfit object
@@ -265,6 +275,7 @@Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
+#> anisole 103.784 344.763 @@ -108,10 +113,7 @@SFO_SFO_SFO <- mkinmod(T245 = list(type = "SFO", to = "phenol"), phenol = list(type = "SFO", to = "anisole"), - anisole = list(type = "SFO"))Successfully compiled differential equation model from auto-generated C code.## Not run: ------------------------------------ + anisole = list(type = "SFO"))#>## Not run: ------------------------------------ # fit.1 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce")) # summary(fit.1, data = FALSE) # @@ -121,9 +123,9 @@ parms.ini = c(k_phenol_sink = 0), fixed_parms = "k_phenol_sink", quiet = TRUE) summary(fit.2, data = FALSE)#> mkin version: 0.9.44.9000 -#> R version: 3.3.1 -#> Date of fit: Wed Oct 26 23:50:40 2016 -#> Date of summary: Wed Oct 26 23:50:40 2016 +#> R version: 3.3.2 +#> Date of fit: Thu Nov 3 17:46:24 2016 +#> Date of summary: Thu Nov 3 17:46:24 2016 #> #> Equations: #> d_T245 = - k_T245_sink * T245 - k_T245_phenol * T245 @@ -133,7 +135,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 246 model solutions performed in 1.43 s +#> Fitted with method Port using 246 model solutions performed in 1.662 s #> #> Weighting: none #> @@ -213,8 +215,7 @@ #> DT50 DT90 #> T245 15.982 53.091 #> phenol 1.711 5.685 -#> anisole 103.784 344.763 -#>
Dataframe in wide format.
-+#> 22 120 NA 33.31 @@ -102,10 +107,7 @@mkin_long_to_wide(FOCUS_2006_D)#> time parent m1 #> 1 0 99.46 0.00 #> 2 0 102.04 0.00 @@ -134,8 +136,7 @@ #> 19 100 NA 31.04 #> 20 100 NA 33.13 #> 21 120 NA 25.15 -#> 22 120 NA 33.31 -#>
Dataframe in long format as needed for modCost
.
+#> 6 y 3 5 @@ -100,10 +105,7 @@ in order to be compatible with mkinfit -wide <- data.frame(t = c(1,2,3), x = c(1,4,7), y = c(3,4,5)) mkin_wide_to_long(wide)#> name time value #> 1 x 1 1 @@ -113,8 +115,7 @@ #> 3 x 3 7 #> 4 y 1 3 #> 5 y 2 4 -#> 6 y 3 5 -#>
@@ -105,7 +110,7 @@ as defined in the FOCUS kinetics report from 2006.mds <- mkinds$new("FOCUS A", FOCUS_2006_A)
This function is used internally by summary.mkinfit
.
This function is used internally by summary.mkinfit
.
+#> m1 0.1095 2 6 @@ -251,7 +256,7 @@ to do transformations. If TRUE, the g parameter of the DFOP and HS models are also transformed, as they can also be seen as compositional data. The transformation used for these transformations is the -SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), m1 = list(type = "SFO"), - use_of_ff = "max")Successfully compiled differential equation model from auto-generated C code.+ use_of_ff = "max")#>#> err.min n.optim df #> All data 0.0640 4 15 #> parent 0.0646 2 7 -#> m1 0.0469 2 8 -#>#> err.min n.optim df #> All data 0.1544 4 13 #> parent 0.1659 2 7 -#> m1 0.1095 2 6 -#>
ilr
transformation.
+ ilr
transformation.
A list with "mkinfit" and "modFit" in the class attribute.
- A summary can be obtained by summary.mkinfit
.
summary.mkinfit
.
Plotting methods plot.mkinfit
and
+
Plotting methods plot.mkinfit
and
mkinparplot
.
Fitting of several models to several datasets in a single call to
mmkin
.
# Use shorthand notation for parent only degradation fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) summary(fit)#> mkin version: 0.9.44.9000 -#> R version: 3.3.1 -#> Date of fit: Wed Oct 26 23:50:42 2016 -#> Date of summary: Wed Oct 26 23:50:42 2016 +#> R version: 3.3.2 +#> Date of fit: Thu Nov 3 17:46:27 2016 +#> Date of summary: Thu Nov 3 17:46:27 2016 #> #> Equations: #> d_parent = - (alpha/beta) * 1/((time/beta) + 1) * parent #> #> Model predictions using solution type analytical #> -#> Fitted with method Port using 64 model solutions performed in 0.168 s +#> Fitted with method Port using 64 model solutions performed in 0.147 s #> #> Weighting: none #> @@ -428,19 +430,16 @@ #> 28 parent 6.6 4.754 1.8460 #> 63 parent 4.0 2.102 1.8977 #> 91 parent 3.9 1.441 2.4590 -#> 119 parent 0.6 1.092 -0.4919 -#>+#> 119 parent 0.6 1.092 -0.4919# One parent compound, one metabolite, both single first order. # Use mkinsub for convenience in model formulation. Pathway to sink included per default. SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), - 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 elapsed -#> 1.272 1.204 0.943 -#>coef(fit)#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink -#> 99.59848 -3.03822 -2.98030 -5.24750 -#>endpoints(fit)#> $ff +#> 1.204 1.244 0.932coef(fit)#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink +#> 99.59848 -3.03822 -2.98030 -5.24750endpoints(fit)#> $ff #> parent_sink parent_m1 m1_sink #> 0.485524 0.514476 1.000000 #> @@ -451,7 +450,6 @@ #> DT50 DT90 #> parent 7.022929 23.32967 #> m1 131.760712 437.69961 -#> #>## Not run: ------------------------------------ # # deSolve is slower when no C compiler (gcc) was available during model generation # print(system.time(fit.deSolve <- mkinfit(SFO_SFO, FOCUS_2006_D, @@ -535,7 +533,7 @@@@ -153,17 +158,14 @@ Media - -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/mkinmod.html b/docs/reference/mkinmod.html index 40381656..bdfd0e09 100644 --- a/docs/reference/mkinmod.html +++ b/docs/reference/mkinmod.html @@ -61,7 +61,12 @@- - Examples -
+Examples
# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) SFO <- mkinmod(parent = list(type = "SFO")) # One parent compound, one metabolite, both single first order SFO_SFO <- mkinmod( parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"))Successfully compiled differential equation model from auto-generated C code.#>## Not run: ------------------------------------ # # The above model used to be specified like this, before the advent of mkinsub() # SFO_SFO <- mkinmod( @@ -210,7 +212,7 @@@@ -97,14 +102,11 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/mkinparplot.html b/docs/reference/mkinparplot.html index dff30930..f8151c16 100644 --- a/docs/reference/mkinparplot.html +++ b/docs/reference/mkinparplot.html @@ -61,7 +61,12 @@Nothing is returned by this function, as it is called for its side effect, namely to produce a plot.
-- - Examples -
+Examples
@@ -78,7 +83,7 @@ -model <- mkinmod( T245 = list(type = "SFO", to = c("phenol"), sink = FALSE), phenol = list(type = "SFO", to = c("anisole")), - anisole = list(type = "SFO"), use_of_ff = "max")Successfully compiled differential equation model from auto-generated C code.fit <- mkinfit(model, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE) + anisole = list(type = "SFO"), use_of_ff = "max")#>Deprecated function. It now only calls the plot method
+plot.mkinfit
.Deprecated function. It now only calls the plot method
plot.mkinfit
.mkinplot(fit, ...)@@ -91,7 +96,7 @@
plot.mkinfit
.
+ further arguments passed to plot.mkinfit
.
Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
A matrix in the same format as the output of ode
.
+#> 201 20 4.978707 27.46227SFO <- mkinmod(degradinol = list(type = "SFO")) # Compare solution types mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, @@ -182,8 +184,7 @@ #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve")#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -205,8 +206,7 @@ #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, solution_type = "deSolve", use_compiled = FALSE)#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -228,8 +228,7 @@ #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, solution_type = "eigen")#> time degradinol #> 1 0 100.0000000 #> 2 1 74.0818221 @@ -251,57 +250,44 @@ #> 18 17 0.6096747 #> 19 18 0.4516581 #> 20 19 0.3345965 -#> 21 20 0.2478752 -#>+#> 21 20 0.2478752# Compare integration methods to analytical solution mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, solution_type = "analytical")[21,]#> time degradinol -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, method = "lsoda")[21,]#> time degradinol -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, method = "ode45")[21,]#> time degradinol -#> 21 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, +#> 21 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), 0:20, method = "rk4")[21,]#> time degradinol -#> 21 20 0.2480043 -#># rk4 is not as precise here +#> 21 20 0.2480043# rk4 is not as precise here # The number of output times used to make a lot of difference until the # default for atol was adjusted mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), seq(0, 20, by = 0.1))[201,]#> time degradinol -#> 201 20 0.2478752 -#>mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), +#> 201 20 0.2478752mkinpredict(SFO, c(k_degradinol_sink = 0.3), c(degradinol = 100), seq(0, 20, by = 0.01))[2001,]#> time degradinol -#> 2001 20 0.2478752 -#>+#> 2001 20 0.2478752# Check compiled model versions - they are faster than the eigenvalue based solutions! SFO_SFO = mkinmod(parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"))Successfully compiled differential equation model from auto-generated C code.system.time( + m1 = list(type = "SFO"))#>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 = "eigen")[201,]))#> time parent m1 -#> 201 20 4.978707 27.46227 -#>#> user system elapsed -#> 0.028 0.004 0.004 -#>system.time( +#> 201 20 4.978707 27.46227#> user system elapsed +#> 0.004 0.024 0.004system.time( print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve")[201,]))#> time parent m1 -#> 201 20 4.978707 27.46227 -#>#> user system elapsed -#> 0.016 0.004 0.002 -#>system.time( +#> 201 20 4.978707 27.46227#> user system elapsed +#> 0.004 0.016 0.003system.time( print(mkinpredict(SFO_SFO, c(k_parent_m1 = 0.05, k_parent_sink = 0.1, k_m1_sink = 0.01), c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), solution_type = "deSolve", use_compiled = FALSE)[201,]))#> time parent m1 -#> 201 20 4.978707 27.46227 -#>#> user system elapsed -#> 0.052 0.000 0.052 -#>
This function plots the residuals for the specified subset of the
observed variables from an mkinfit object. A combined plot of the fitted
- model and the residuals can be obtained using plot.mkinfit
+ model and the residuals can be obtained using plot.mkinfit
using the argument show_residuals = TRUE
.
@@ -124,10 +129,7 @@Successfully compiled differential equation model from auto-generated C code.@@ -115,22 +120,19 @@A list for use with
-mkinmod
.- - Examples -
+Examples
+ m1 = mkinsub("SFO", full_name = "Metabolite M1"))# One parent compound, one metabolite, both single first order. SFO_SFO <- mkinmod( parent = list(type = "SFO", to = "m1"), - m1 = list(type = "SFO"))Successfully compiled differential equation model from auto-generated C code.+ m1 = list(type = "SFO"))#># The same model using mkinsub SFO_SFO.2 <- mkinmod( parent = mkinsub("SFO", "m1"), - m1 = mkinsub("SFO"))Successfully compiled differential equation model from auto-generated C code.+ m1 = mkinsub("SFO"))#># Now supplying full names SFO_SFO.2 <- mkinmod( parent = mkinsub("SFO", "m1", full_name = "Test compound"), - m1 = mkinsub("SFO", full_name = "Metabolite M1"))Successfully compiled differential equation model from auto-generated C code.#>
[.mmkin
for subsetting, plot.mmkin
for plotting.
## Not run: ------------------------------------ # m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), # M1 = mkinsub("SFO", "M2"), @@ -182,7 +184,7 @@@@ -199,14 +204,11 @@ plot_sep(fit, sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE, … -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/plot.mkinfit.html b/docs/reference/plot.mkinfit.html index 4eb7369a..61a597e7 100644 --- a/docs/reference/plot.mkinfit.html +++ b/docs/reference/plot.mkinfit.html @@ -61,7 +61,12 @@The function is called for its side effect.
-- - Examples -
+Examples
# One parent compound, one metabolite, both single first order, path from # parent to sink included, use Levenberg-Marquardt for speed SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1", full = "Parent"), - m1 = mkinsub("SFO", full = "Metabolite M1" ))Successfully compiled differential equation model from auto-generated C code.fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, method.modFit = "Marq") + m1 = mkinsub("SFO", full = "Metabolite M1" ))#>plot(fit, show_residuals = TRUE)# Show the observed variables separately plot(fit, sep_obs = TRUE, lpos = c("topright", "bottomright"))@@ -235,7 +237,7 @@ plot_sep(fit, sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE, …@@ -119,7 +124,7 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/plot.mmkin.html b/docs/reference/plot.mmkin.html index e0a20f3d..b107ca70 100644 --- a/docs/reference/plot.mmkin.html +++ b/docs/reference/plot.mmkin.html @@ -61,7 +61,12 @@
plot.mkinfit
and mkinresplot
.
+ Further arguments passed to plot.mkinfit
and mkinresplot
.
The function is called for its side effect.
-@@ -136,21 +141,18 @@ http://focus.jrc.ec.europa.eu/dk -# Only use one core not to offend CRAN checks, use Levenberg-Marquardt for speed fits <- mmkin(c("FOMC", "HS"), list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), cores = 1, quiet = TRUE, method.modFit = "Marq") @@ -160,7 +162,7 @@@@ -109,7 +114,7 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/print.mkinds.html b/docs/reference/print.mkinds.html index a586a103..9bd088b1 100644 --- a/docs/reference/print.mkinds.html +++ b/docs/reference/print.mkinds.html @@ -61,7 +61,12 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/print.mkinmod.html b/docs/reference/print.mkinmod.html index 73bfd60e..11b96036 100644 --- a/docs/reference/print.mkinmod.html +++ b/docs/reference/print.mkinmod.html @@ -61,7 +61,12 @@@@ -109,7 +114,7 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/schaefer07_complex_case.html b/docs/reference/schaefer07_complex_case.html index 4714747a..526dde10 100644 --- a/docs/reference/schaefer07_complex_case.html +++ b/docs/reference/schaefer07_complex_case.html @@ -61,7 +61,12 @@@@ -106,17 +111,14 @@ Symposium Pesticide Chemistry, Piacenza, 2007, p. 916-923. -- - Examples -
+Examples
+ A2 = list(type = "SFO"), use_of_ff = "max")data <- mkin_wide_to_long(schaefer07_complex_case, time = "time") model <- mkinmod( parent = list(type = "SFO", to = c("A1", "B1", "C1"), sink = FALSE), A1 = list(type = "SFO", to = "A2"), B1 = list(type = "SFO"), C1 = list(type = "SFO"), - A2 = list(type = "SFO"), use_of_ff = "max")Successfully compiled differential equation model from auto-generated C code.## Not run: mkinfit(model, data, plot=TRUE)#>## Not run: mkinfit(model, data, plot=TRUE)
+#> 118 parent 0.39 1.351 -0.9613 @@ -117,10 +122,7 @@ measurement error in analytical chemistry. Technometrics 37(2), 176-184. -#> mkin version: 0.9.44.9000 -#> R version: 3.3.1 -#> Date of fit: Wed Oct 26 23:50:50 2016 -#> Date of summary: Wed Oct 26 23:50:50 2016 +#> R version: 3.3.2 +#> Date of fit: Thu Nov 3 17:46:35 2016 +#> Date of summary: Thu Nov 3 17:46:35 2016 #> #> Equations: #> d_parent = - k_parent_sink * parent #> #> Model predictions using solution type analytical #> -#> Fitted with method Port using 35 model solutions performed in 0.083 s +#> Fitted with method Port using 35 model solutions performed in 0.08 s #> #> Weighting: none #> @@ -209,8 +211,7 @@ #> 30 parent 29.71 35.738 -6.0283 #> 62 parent 5.98 10.862 -4.8818 #> 90 parent 1.54 3.831 -2.2911 -#> 118 parent 0.39 1.351 -0.9613 -#>
## Not run: ------------------------------------ # m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), # M1 = list(type = "SFO", to = "M2"), @@ -160,7 +162,7 @@@@ -83,7 +88,7 @@ constants and other paramters that can only take on positive values, a simple log transformation is used. For compositional parameters, such as the formations fractions that should always sum up to 1 and can not be - negative, the -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/docs/reference/transform_odeparms.html b/docs/reference/transform_odeparms.html index ab5ce062..ccd56ca4 100644 --- a/docs/reference/transform_odeparms.html +++ b/docs/reference/transform_odeparms.html @@ -61,7 +61,12 @@ilr
transformation is used. + negative, theilr
transformation is used.The transformation of sets of formation fractions is fragile, as it supposes the same ordering of the components in forward and backward transformation. @@ -109,7 +114,7 @@
mkinmod
, containing the names of
the model variables that are needed for grouping the formation fractions
- before ilr
transformation, the parameter names and
+ before ilr
transformation, the parameter names and
the information if the pathway to sink is included in the model.
ilr
+ transformation used for these transformations is the ilr
transformation.
@@ -139,18 +144,15 @@
as the original parameters.
- Successfully compiled differential equation model from auto-generated C code.# Fit the model to the FOCUS example dataset D using defaults + m1 = list(type = "SFO"))#># Fit the model to the FOCUS example dataset D using defaults fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) summary(fit, data=FALSE) # See transformed and backtransformed parameters#> mkin version: 0.9.44.9000 -#> R version: 3.3.1 -#> Date of fit: Wed Oct 26 23:50:51 2016 -#> Date of summary: Wed Oct 26 23:50:51 2016 +#> R version: 3.3.2 +#> Date of fit: Thu Nov 3 17:46:36 2016 +#> Date of summary: Thu Nov 3 17:46:36 2016 #> #> Equations: #> d_parent = - k_parent_sink * parent - k_parent_m1 * parent @@ -158,7 +160,7 @@ #> #> Model predictions using solution type deSolve #> -#> Fitted with method Port using 153 model solutions performed in 0.629 s +#> Fitted with method Port using 153 model solutions performed in 0.657 s #> #> Weighting: none #> @@ -221,8 +223,7 @@ #> Estimated disappearance times: #> DT50 DT90 #> parent 7.023 23.33 -#> m1 131.761 437.70 -#>+#> m1 131.761 437.70## Not run: ------------------------------------ # fit.2 <- mkinfit(SFO_SFO, FOCUS_2006_D, transform_rates = FALSE) # summary(fit.2, data=FALSE) @@ -233,10 +234,8 @@ transformed <- fit$start_transformed$value names(transformed) <- rownames(fit$start_transformed) transform_odeparms(initials, SFO_SFO)#> parent_0 log_k_parent_sink log_k_parent_m1 log_k_m1_sink -#> 100.750000 -2.302585 -2.301586 -2.300587 -#>backtransform_odeparms(transformed, SFO_SFO)#> parent_0 k_parent_sink k_parent_m1 k_m1_sink -#> 100.7500 0.1000 0.1001 0.1002 -#>+#> 100.750000 -2.302585 -2.301586 -2.300587backtransform_odeparms(transformed, SFO_SFO)#> parent_0 k_parent_sink k_parent_m1 k_m1_sink +#> 100.7500 0.1000 0.1001 0.1002## Not run: ------------------------------------ # # The case of formation fractions # SFO_SFO.ff <- mkinmod( @@ -280,7 +279,7 @@ -Developed by Johannes Ranke, Eurofins Regulatory AG.
+Developed by Johannes Ranke.
diff --git a/test.R b/test.R new file mode 100644 index 00000000..264c2239 --- /dev/null +++ b/test.R @@ -0,0 +1,33 @@ +library(pkgdown) + +debug(pkgdown:::as_pkgdown) +debug(pkgdown:::topic_index) +debug(pkgdown:::package_rd) # creates rd object (list of Rd file representations) + + +undebug(pkgdown:::rd_file) # creates rd file representations + +build_reference_index(".") + +extract_tag(rd[[1]], "tag_title") # gives "\n" +extract_tag(rd[[4]], "tag_title") # gives the title + +library(magrittr) +library(stringr) +extract_tag_local <- function(x, tag) { + x %>% + purrr::keep(inherits, tag) %>% + unlist %>% + paste(collapse = "") %>% + str_trim +} + +extract_tag_local(rd[[1]], "tag_title") +extract_tag_local(rd[[4]], "tag_title") + + +titles <- purrr::map_chr(rd, extract_tag, "tag_title") + +titles <- purrr::map_chr(rd, extract_tag_local, "tag_title") + +rd[[2]] -- cgit v1.2.1