From a77a10ea6c607346778ba0700b3b66ac393101a2 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 27 May 2020 06:06:08 +0200 Subject: Create up to date pkgdown docs in development mode --- docs/dev/reference/AIC.mmkin.html | 240 +++++ docs/dev/reference/CAKE_export.html | 261 +++++ docs/dev/reference/DFOP.solution-1.png | Bin 0 -> 19369 bytes docs/dev/reference/DFOP.solution.html | 236 +++++ docs/dev/reference/Extract.mmkin.html | 253 +++++ docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html | 212 ++++ docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html | 211 ++++ docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html | 212 ++++ docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html | 210 ++++ docs/dev/reference/FOCUS_2006_datasets.html | 213 ++++ docs/dev/reference/FOMC.solution-1.png | Bin 0 -> 18630 bytes docs/dev/reference/FOMC.solution.html | 245 +++++ docs/dev/reference/HS.solution-1.png | Bin 0 -> 18893 bytes docs/dev/reference/HS.solution.html | 237 +++++ docs/dev/reference/IORE.solution-1.png | Bin 0 -> 18668 bytes docs/dev/reference/IORE.solution.html | 245 +++++ docs/dev/reference/NAFTA_SOP_2015-1.png | Bin 0 -> 41379 bytes docs/dev/reference/NAFTA_SOP_2015.html | 240 +++++ docs/dev/reference/NAFTA_SOP_Attachment-1.png | Bin 0 -> 42204 bytes docs/dev/reference/NAFTA_SOP_Attachment.html | 234 +++++ docs/dev/reference/SFO.solution-1.png | Bin 0 -> 18661 bytes docs/dev/reference/SFO.solution.html | 225 +++++ docs/dev/reference/SFORB.solution-1.png | Bin 0 -> 20190 bytes docs/dev/reference/SFORB.solution.html | 243 +++++ docs/dev/reference/add_err-1.png | Bin 0 -> 111278 bytes docs/dev/reference/add_err-2.png | Bin 0 -> 63031 bytes docs/dev/reference/add_err-3.png | Bin 0 -> 60608 bytes docs/dev/reference/add_err.html | 287 ++++++ docs/dev/reference/aw.html | 221 ++++ docs/dev/reference/confint.mkinfit.html | 419 ++++++++ docs/dev/reference/create_deg_func.html | 225 +++++ docs/dev/reference/endpoints.html | 232 +++++ docs/dev/reference/experimental_data_for_UBA-1.png | Bin 0 -> 107152 bytes docs/dev/reference/experimental_data_for_UBA.html | 300 ++++++ docs/dev/reference/get_deg_func.html | 185 ++++ docs/dev/reference/ilr.html | 220 ++++ docs/dev/reference/index.html | 699 +++++++++++++ docs/dev/reference/loftest-1.png | Bin 0 -> 27354 bytes docs/dev/reference/loftest-2.png | Bin 0 -> 27721 bytes docs/dev/reference/loftest-3.png | Bin 0 -> 78754 bytes docs/dev/reference/loftest-4.png | Bin 0 -> 76899 bytes docs/dev/reference/loftest-5.png | Bin 0 -> 75806 bytes docs/dev/reference/loftest.html | 349 +++++++ docs/dev/reference/logLik.mkinfit.html | 229 +++++ docs/dev/reference/logistic.solution-1.png | Bin 0 -> 80598 bytes docs/dev/reference/logistic.solution-2.png | Bin 0 -> 29336 bytes docs/dev/reference/logistic.solution.html | 275 +++++ docs/dev/reference/lrtest.mkinfit.html | 265 +++++ docs/dev/reference/max_twa_parent.html | 270 +++++ docs/dev/reference/mccall81_245T.html | 245 +++++ docs/dev/reference/mkin_long_to_wide.html | 233 +++++ docs/dev/reference/mkin_wide_to_long.html | 213 ++++ docs/dev/reference/mkinds.html | 253 +++++ docs/dev/reference/mkinerrmin.html | 233 +++++ docs/dev/reference/mkinerrplot-1.png | Bin 0 -> 41458 bytes docs/dev/reference/mkinerrplot.html | 272 +++++ docs/dev/reference/mkinfit.html | 1054 ++++++++++++++++++++ docs/dev/reference/mkinmod.html | 320 ++++++ docs/dev/reference/mkinparplot-1.png | Bin 0 -> 16468 bytes docs/dev/reference/mkinparplot.html | 203 ++++ docs/dev/reference/mkinplot.html | 198 ++++ docs/dev/reference/mkinpredict.html | 447 +++++++++ docs/dev/reference/mkinresplot-1.png | Bin 0 -> 14861 bytes docs/dev/reference/mkinresplot.html | 275 +++++ docs/dev/reference/mkinsub.html | 228 +++++ docs/dev/reference/mmkin-1.png | Bin 0 -> 115683 bytes docs/dev/reference/mmkin-2.png | Bin 0 -> 113464 bytes docs/dev/reference/mmkin-3.png | Bin 0 -> 100817 bytes docs/dev/reference/mmkin-4.png | Bin 0 -> 70430 bytes docs/dev/reference/mmkin-5.png | Bin 0 -> 66959 bytes docs/dev/reference/mmkin.html | 271 +++++ docs/dev/reference/nafta-1.png | Bin 0 -> 41379 bytes docs/dev/reference/nafta.html | 283 ++++++ docs/dev/reference/nlme-1.png | Bin 0 -> 71631 bytes docs/dev/reference/nlme.html | 281 ++++++ docs/dev/reference/nlme.mmkin-1.png | Bin 0 -> 81816 bytes docs/dev/reference/nlme.mmkin-2.png | Bin 0 -> 82384 bytes docs/dev/reference/nlme.mmkin-3.png | Bin 0 -> 82591 bytes docs/dev/reference/nlme.mmkin-4.png | Bin 0 -> 86006 bytes docs/dev/reference/nlme.mmkin-5.png | Bin 0 -> 85418 bytes docs/dev/reference/nlme.mmkin-6.png | Bin 0 -> 84796 bytes docs/dev/reference/nlme.mmkin-7.png | Bin 0 -> 84926 bytes docs/dev/reference/nlme.mmkin.html | 463 +++++++++ docs/dev/reference/nobs.mkinfit.html | 197 ++++ docs/dev/reference/parms.html | 292 ++++++ docs/dev/reference/plot.mkinfit-1.png | Bin 0 -> 53973 bytes docs/dev/reference/plot.mkinfit-2.png | Bin 0 -> 75079 bytes docs/dev/reference/plot.mkinfit-3.png | Bin 0 -> 70266 bytes docs/dev/reference/plot.mkinfit-4.png | Bin 0 -> 74166 bytes docs/dev/reference/plot.mkinfit-5.png | Bin 0 -> 68692 bytes docs/dev/reference/plot.mkinfit-6.png | Bin 0 -> 75012 bytes docs/dev/reference/plot.mkinfit-7.png | Bin 0 -> 75692 bytes docs/dev/reference/plot.mkinfit.html | 379 +++++++ docs/dev/reference/plot.mmkin-1.png | Bin 0 -> 34273 bytes docs/dev/reference/plot.mmkin-2.png | Bin 0 -> 34629 bytes docs/dev/reference/plot.mmkin-3.png | Bin 0 -> 32259 bytes docs/dev/reference/plot.mmkin-4.png | Bin 0 -> 25550 bytes docs/dev/reference/plot.mmkin-5.png | Bin 0 -> 38129 bytes docs/dev/reference/plot.mmkin.html | 287 ++++++ docs/dev/reference/plot.nafta.html | 210 ++++ docs/dev/reference/plot.nlme.mmkin-1.png | Bin 0 -> 35382 bytes docs/dev/reference/plot.nlme.mmkin-2.png | Bin 0 -> 35346 bytes docs/dev/reference/plot.nlme.mmkin.html | 275 +++++ docs/dev/reference/print.mkinds.html | 194 ++++ docs/dev/reference/print.mkinmod.html | 217 ++++ docs/dev/reference/reexports.html | 190 ++++ docs/dev/reference/residuals.mkinfit.html | 204 ++++ docs/dev/reference/saemix-1.png | Bin 0 -> 31551 bytes docs/dev/reference/saemix-2.png | Bin 0 -> 58815 bytes docs/dev/reference/saemix.html | 446 +++++++++ docs/dev/reference/schaefer07_complex_case-1.png | Bin 0 -> 67741 bytes docs/dev/reference/schaefer07_complex_case.html | 239 +++++ docs/dev/reference/sigma_twocomp.html | 219 ++++ docs/dev/reference/summary.mkinfit.html | 337 +++++++ .../reference/synthetic_data_for_UBA_2014-1.png | Bin 0 -> 70430 bytes .../dev/reference/synthetic_data_for_UBA_2014.html | 470 +++++++++ docs/dev/reference/test_data_from_UBA_2014-1.png | Bin 0 -> 59294 bytes docs/dev/reference/test_data_from_UBA_2014-2.png | Bin 0 -> 78194 bytes docs/dev/reference/test_data_from_UBA_2014.html | 251 +++++ docs/dev/reference/transform_odeparms.html | 319 ++++++ docs/dev/reference/update.mkinfit-1.png | Bin 0 -> 28678 bytes docs/dev/reference/update.mkinfit-2.png | Bin 0 -> 28541 bytes docs/dev/reference/update.mkinfit.html | 214 ++++ 123 files changed, 18305 insertions(+) create mode 100644 docs/dev/reference/AIC.mmkin.html create mode 100644 docs/dev/reference/CAKE_export.html create mode 100644 docs/dev/reference/DFOP.solution-1.png create mode 100644 docs/dev/reference/DFOP.solution.html create mode 100644 docs/dev/reference/Extract.mmkin.html create mode 100644 docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html create mode 100644 docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html create mode 100644 docs/dev/reference/FOCUS_2006_datasets.html create mode 100644 docs/dev/reference/FOMC.solution-1.png create mode 100644 docs/dev/reference/FOMC.solution.html create mode 100644 docs/dev/reference/HS.solution-1.png create mode 100644 docs/dev/reference/HS.solution.html create mode 100644 docs/dev/reference/IORE.solution-1.png create mode 100644 docs/dev/reference/IORE.solution.html create mode 100644 docs/dev/reference/NAFTA_SOP_2015-1.png create mode 100644 docs/dev/reference/NAFTA_SOP_2015.html create mode 100644 docs/dev/reference/NAFTA_SOP_Attachment-1.png create mode 100644 docs/dev/reference/NAFTA_SOP_Attachment.html create mode 100644 docs/dev/reference/SFO.solution-1.png create mode 100644 docs/dev/reference/SFO.solution.html create mode 100644 docs/dev/reference/SFORB.solution-1.png create mode 100644 docs/dev/reference/SFORB.solution.html create mode 100644 docs/dev/reference/add_err-1.png create mode 100644 docs/dev/reference/add_err-2.png create mode 100644 docs/dev/reference/add_err-3.png create mode 100644 docs/dev/reference/add_err.html create mode 100644 docs/dev/reference/aw.html create mode 100644 docs/dev/reference/confint.mkinfit.html create mode 100644 docs/dev/reference/create_deg_func.html create mode 100644 docs/dev/reference/endpoints.html create mode 100644 docs/dev/reference/experimental_data_for_UBA-1.png create mode 100644 docs/dev/reference/experimental_data_for_UBA.html create mode 100644 docs/dev/reference/get_deg_func.html create mode 100644 docs/dev/reference/ilr.html create mode 100644 docs/dev/reference/index.html create mode 100644 docs/dev/reference/loftest-1.png create mode 100644 docs/dev/reference/loftest-2.png create mode 100644 docs/dev/reference/loftest-3.png create mode 100644 docs/dev/reference/loftest-4.png create mode 100644 docs/dev/reference/loftest-5.png create mode 100644 docs/dev/reference/loftest.html create mode 100644 docs/dev/reference/logLik.mkinfit.html create mode 100644 docs/dev/reference/logistic.solution-1.png create mode 100644 docs/dev/reference/logistic.solution-2.png create mode 100644 docs/dev/reference/logistic.solution.html create mode 100644 docs/dev/reference/lrtest.mkinfit.html create mode 100644 docs/dev/reference/max_twa_parent.html create mode 100644 docs/dev/reference/mccall81_245T.html create mode 100644 docs/dev/reference/mkin_long_to_wide.html create mode 100644 docs/dev/reference/mkin_wide_to_long.html create mode 100644 docs/dev/reference/mkinds.html create mode 100644 docs/dev/reference/mkinerrmin.html create mode 100644 docs/dev/reference/mkinerrplot-1.png create mode 100644 docs/dev/reference/mkinerrplot.html create mode 100644 docs/dev/reference/mkinfit.html create mode 100644 docs/dev/reference/mkinmod.html create mode 100644 docs/dev/reference/mkinparplot-1.png create mode 100644 docs/dev/reference/mkinparplot.html create mode 100644 docs/dev/reference/mkinplot.html create mode 100644 docs/dev/reference/mkinpredict.html create mode 100644 docs/dev/reference/mkinresplot-1.png create mode 100644 docs/dev/reference/mkinresplot.html create mode 100644 docs/dev/reference/mkinsub.html create mode 100644 docs/dev/reference/mmkin-1.png create mode 100644 docs/dev/reference/mmkin-2.png create mode 100644 docs/dev/reference/mmkin-3.png create mode 100644 docs/dev/reference/mmkin-4.png create mode 100644 docs/dev/reference/mmkin-5.png create mode 100644 docs/dev/reference/mmkin.html create mode 100644 docs/dev/reference/nafta-1.png create mode 100644 docs/dev/reference/nafta.html create mode 100644 docs/dev/reference/nlme-1.png create mode 100644 docs/dev/reference/nlme.html create mode 100644 docs/dev/reference/nlme.mmkin-1.png create mode 100644 docs/dev/reference/nlme.mmkin-2.png create mode 100644 docs/dev/reference/nlme.mmkin-3.png create mode 100644 docs/dev/reference/nlme.mmkin-4.png create mode 100644 docs/dev/reference/nlme.mmkin-5.png create mode 100644 docs/dev/reference/nlme.mmkin-6.png create mode 100644 docs/dev/reference/nlme.mmkin-7.png create mode 100644 docs/dev/reference/nlme.mmkin.html create mode 100644 docs/dev/reference/nobs.mkinfit.html create mode 100644 docs/dev/reference/parms.html create mode 100644 docs/dev/reference/plot.mkinfit-1.png create mode 100644 docs/dev/reference/plot.mkinfit-2.png create mode 100644 docs/dev/reference/plot.mkinfit-3.png create mode 100644 docs/dev/reference/plot.mkinfit-4.png create mode 100644 docs/dev/reference/plot.mkinfit-5.png create mode 100644 docs/dev/reference/plot.mkinfit-6.png create mode 100644 docs/dev/reference/plot.mkinfit-7.png create mode 100644 docs/dev/reference/plot.mkinfit.html create mode 100644 docs/dev/reference/plot.mmkin-1.png create mode 100644 docs/dev/reference/plot.mmkin-2.png create mode 100644 docs/dev/reference/plot.mmkin-3.png create mode 100644 docs/dev/reference/plot.mmkin-4.png create mode 100644 docs/dev/reference/plot.mmkin-5.png create mode 100644 docs/dev/reference/plot.mmkin.html create mode 100644 docs/dev/reference/plot.nafta.html create mode 100644 docs/dev/reference/plot.nlme.mmkin-1.png create mode 100644 docs/dev/reference/plot.nlme.mmkin-2.png create mode 100644 docs/dev/reference/plot.nlme.mmkin.html create mode 100644 docs/dev/reference/print.mkinds.html create mode 100644 docs/dev/reference/print.mkinmod.html create mode 100644 docs/dev/reference/reexports.html create mode 100644 docs/dev/reference/residuals.mkinfit.html create mode 100644 docs/dev/reference/saemix-1.png create mode 100644 docs/dev/reference/saemix-2.png create mode 100644 docs/dev/reference/saemix.html create mode 100644 docs/dev/reference/schaefer07_complex_case-1.png create mode 100644 docs/dev/reference/schaefer07_complex_case.html create mode 100644 docs/dev/reference/sigma_twocomp.html create mode 100644 docs/dev/reference/summary.mkinfit.html create mode 100644 docs/dev/reference/synthetic_data_for_UBA_2014-1.png create mode 100644 docs/dev/reference/synthetic_data_for_UBA_2014.html create mode 100644 docs/dev/reference/test_data_from_UBA_2014-1.png create mode 100644 docs/dev/reference/test_data_from_UBA_2014-2.png create mode 100644 docs/dev/reference/test_data_from_UBA_2014.html create mode 100644 docs/dev/reference/transform_odeparms.html create mode 100644 docs/dev/reference/update.mkinfit-1.png create mode 100644 docs/dev/reference/update.mkinfit-2.png create mode 100644 docs/dev/reference/update.mkinfit.html (limited to 'docs/dev/reference') diff --git a/docs/dev/reference/AIC.mmkin.html b/docs/dev/reference/AIC.mmkin.html new file mode 100644 index 00000000..517aff12 --- /dev/null +++ b/docs/dev/reference/AIC.mmkin.html @@ -0,0 +1,240 @@ + + + + + + + + +Calculate the AIC for a column of an mmkin object — AIC.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Provides a convenient way to compare different kinetic models fitted to the +same dataset.

+
+ +
# S3 method for mmkin
+AIC(object, ..., k = 2)
+
+# S3 method for mmkin
+BIC(object, ...)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

An object of class mmkin, containing only one +column.

...

For compatibility with the generic method

k

As in the generic method

+ +

Value

+ +

As in the generic method (a numeric value for single fits, or a +dataframe if there are several fits in the column).

+ +

Examples

+
+ # skip, as it takes > 10 s on winbuilder + f <- mmkin(c("SFO", "FOMC", "DFOP"), + list("FOCUS A" = FOCUS_2006_A, + "FOCUS C" = FOCUS_2006_C), cores = 1, quiet = TRUE)
#> Warning: Optimisation did not converge: +#> false convergence (8)
# We get a warning because the FOMC model does not converge for the + # FOCUS A dataset, as it is well described by SFO + + AIC(f["SFO", "FOCUS A"]) # We get a single number for a single fit
#> [1] 55.28197
AIC(f[["SFO", "FOCUS A"]]) # or when extracting an mkinfit object
#> [1] 55.28197
+ # For FOCUS A, the models fit almost equally well, so the higher the number + # of parameters, the higher (worse) the AIC + AIC(f[, "FOCUS A"])
#> df AIC +#> SFO 3 55.28197 +#> FOMC 4 57.28202 +#> DFOP 5 59.28197
AIC(f[, "FOCUS A"], k = 0) # If we do not penalize additional parameters, we get nearly the same
#> df AIC +#> SFO 3 49.28197 +#> FOMC 4 49.28202 +#> DFOP 5 49.28197
BIC(f[, "FOCUS A"]) # Comparing the BIC gives a very similar picture
#> df BIC +#> SFO 3 55.52030 +#> FOMC 4 57.59979 +#> DFOP 5 59.67918
+ # For FOCUS C, the more complex models fit better + AIC(f[, "FOCUS C"])
#> df AIC +#> SFO 3 59.29336 +#> FOMC 4 44.68652 +#> DFOP 5 29.02372
BIC(f[, "FOCUS C"])
#> df BIC +#> SFO 3 59.88504 +#> FOMC 4 45.47542 +#> DFOP 5 30.00984
+ +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/CAKE_export.html b/docs/dev/reference/CAKE_export.html new file mode 100644 index 00000000..ce8a3444 --- /dev/null +++ b/docs/dev/reference/CAKE_export.html @@ -0,0 +1,261 @@ + + + + + + + + +Export a list of datasets format to a CAKE study file — CAKE_export • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

In addition to the datasets, the pathways in the degradation model can be +specified as well.

+
+ +
CAKE_export(
+  ds,
+  map = c(parent = "Parent"),
+  links = NA,
+  filename = "CAKE_export.csf",
+  path = ".",
+  overwrite = FALSE,
+  study = "Codlemone aerobic soil degradation",
+  description = "",
+  time_unit = "days",
+  res_unit = "% AR",
+  comment = "Created using mkin::CAKE_export",
+  date = Sys.Date(),
+  optimiser = "IRLS"
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ds

A named list of datasets in long format as compatible with +mkinfit.

map

A character vector with CAKE compartment names (Parent, A1, ...), +named with the names used in the list of datasets.

links

An optional character vector of target compartments, named with +the names of the source compartments. In order to make this easier, the +names are used as in the datasets supplied.

filename

Where to write the result. Should end in .csf in order to be +compatible with CAKE.

path

An optional path to the output file.

overwrite

If TRUE, existing files are overwritten.

study

The name of the study.

description

An optional description.

time_unit

The time unit for the residue data.

res_unit

The unit used for the residues.

comment

An optional comment.

date

The date of file creation.

optimiser

Can be OLS or IRLS.

+ +

Value

+ +

The function is called for its side effect.

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/DFOP.solution-1.png b/docs/dev/reference/DFOP.solution-1.png new file mode 100644 index 00000000..a2d75ccc Binary files /dev/null and b/docs/dev/reference/DFOP.solution-1.png differ diff --git a/docs/dev/reference/DFOP.solution.html b/docs/dev/reference/DFOP.solution.html new file mode 100644 index 00000000..48c3aabb --- /dev/null +++ b/docs/dev/reference/DFOP.solution.html @@ -0,0 +1,236 @@ + + + + + + + + +Double First-Order in Parallel kinetics — DFOP.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing decline from a defined starting value using the sum of +two exponential decline functions.

+
+ +
DFOP.solution(t, parent_0, k1, k2, g)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k1

First kinetic constant.

k2

Second kinetic constant.

g

Fraction of the starting value declining according to the first +kinetic constant.

+ +

Value

+ +

The value of the response variable at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

See also

+ + + +

Examples

+
+ plot(function(x) DFOP.solution(x, 100, 5, 0.5, 0.3), 0, 4, ylim = c(0,100))
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/Extract.mmkin.html b/docs/dev/reference/Extract.mmkin.html new file mode 100644 index 00000000..c69259b6 --- /dev/null +++ b/docs/dev/reference/Extract.mmkin.html @@ -0,0 +1,253 @@ + + + + + + + + +Subsetting method for mmkin objects — [.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Subsetting method for mmkin objects.

+
+ +
# S3 method for mmkin
+[(x, i, j, ..., drop = FALSE)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
x

An mmkin object

i

Row index selecting the fits for specific models

j

Column index selecting the fits to specific datasets

...

Not used, only there to satisfy the generic method definition

drop

If FALSE, the method always returns an mmkin object, otherwise +either a list of mkinfit objects or a single mkinfit object.

+ +

Value

+ +

An object of class mmkin.

+ +

Examples

+
+ # Only use one core, to pass R CMD check --as-cran + fits <- mmkin(c("SFO", "FOMC"), list(B = FOCUS_2006_B, C = FOCUS_2006_C), + cores = 1, quiet = TRUE) + fits["FOMC", ]
#> dataset +#> model B C +#> FOMC List,39 List,39 +#> attr(,"class") +#> [1] "mmkin"
fits[, "B"]
#> dataset +#> model B +#> SFO List,39 +#> FOMC List,39 +#> attr(,"class") +#> [1] "mmkin"
fits["SFO", "B"]
#> dataset +#> model B +#> SFO List,39 +#> attr(,"class") +#> [1] "mmkin"
+ head( + # This extracts an mkinfit object with lots of components + fits[["FOMC", "B"]] + )
#> $par +#> parent_0 log_alpha log_beta sigma +#> 99.666193 2.549849 5.050586 1.890202 +#> +#> $objective +#> [1] 28.58291 +#> +#> $convergence +#> [1] 0 +#> +#> $iterations +#> [1] 21 +#> +#> $evaluations +#> function gradient +#> 25 72 +#> +#> $message +#> [1] "both X-convergence and relative convergence (5)" +#>
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html b/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html new file mode 100644 index 00000000..fcdfcf72 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_DFOP_ref_A_to_B.html @@ -0,0 +1,212 @@ + + + + + + + + +Results of fitting the DFOP model to Datasets A to B of FOCUS (2006) — FOCUS_2006_DFOP_ref_A_to_B • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
FOCUS_2006_DFOP_ref_A_to_B
+ + +

Format

+ +

A data frame containing the following variables.

+
package

a factor giving the name of the software package

+
M0

The fitted initial concentration of the parent compound

+
f

The fitted f parameter

+
k1

The fitted k1 parameter

+
k2

The fitted k2 parameter

+
DT50

The resulting half-life of the parent compound

+
DT90

The resulting DT90 of the parent compound

+
dataset

The FOCUS dataset that was used

+ + + +

Source

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
data(FOCUS_2006_DFOP_ref_A_to_B)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html new file mode 100644 index 00000000..666a1123 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_FOMC_ref_A_to_F.html @@ -0,0 +1,211 @@ + + + + + + + + +Results of fitting the FOMC model to Datasets A to F of FOCUS (2006) — FOCUS_2006_FOMC_ref_A_to_F • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
FOCUS_2006_FOMC_ref_A_to_F
+ + +

Format

+ +

A data frame containing the following variables.

+
package

a factor giving the name of the software package

+
M0

The fitted initial concentration of the parent compound

+
alpha

The fitted alpha parameter

+
beta

The fitted beta parameter

+
DT50

The resulting half-life of the parent compound

+
DT90

The resulting DT90 of the parent compound

+
dataset

The FOCUS dataset that was used

+ + + +

Source

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
data(FOCUS_2006_FOMC_ref_A_to_F)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html new file mode 100644 index 00000000..b07abb0d --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_HS_ref_A_to_F.html @@ -0,0 +1,212 @@ + + + + + + + + +Results of fitting the HS model to Datasets A to F of FOCUS (2006) — FOCUS_2006_HS_ref_A_to_F • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
FOCUS_2006_HS_ref_A_to_F
+ + +

Format

+ +

A data frame containing the following variables.

+
package

a factor giving the name of the software package

+
M0

The fitted initial concentration of the parent compound

+
tb

The fitted tb parameter

+
k1

The fitted k1 parameter

+
k2

The fitted k2 parameter

+
DT50

The resulting half-life of the parent compound

+
DT90

The resulting DT90 of the parent compound

+
dataset

The FOCUS dataset that was used

+ + + +

Source

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
data(FOCUS_2006_HS_ref_A_to_F)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html b/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html new file mode 100644 index 00000000..1e3b91f6 --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_SFO_ref_A_to_F.html @@ -0,0 +1,210 @@ + + + + + + + + +Results of fitting the SFO model to Datasets A to F of FOCUS (2006) — FOCUS_2006_SFO_ref_A_to_F • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

A table with the fitted parameters and the resulting DT50 and DT90 values +generated with different software packages. Taken directly from FOCUS (2006). +The results from fitting the data with the Topfit software was removed, as +the initial concentration of the parent compound was fixed to a value of 100 +in this fit.

+
+ +
FOCUS_2006_SFO_ref_A_to_F
+ + +

Format

+ +

A data frame containing the following variables.

+
package

a factor giving the name of the software package

+
M0

The fitted initial concentration of the parent compound

+
k

The fitted first-order degradation rate constant

+
DT50

The resulting half-life of the parent compound

+
DT90

The resulting DT90 of the parent compound

+
dataset

The FOCUS dataset that was used

+ + + +

Source

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
data(FOCUS_2006_SFO_ref_A_to_F)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOCUS_2006_datasets.html b/docs/dev/reference/FOCUS_2006_datasets.html new file mode 100644 index 00000000..9836adac --- /dev/null +++ b/docs/dev/reference/FOCUS_2006_datasets.html @@ -0,0 +1,213 @@ + + + + + + + + +Datasets A to F from the FOCUS Kinetics report from 2006 — FOCUS_2006_datasets • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Data taken from FOCUS (2006), p. 258.

+
+ +
FOCUS_2006_A
+  FOCUS_2006_B
+  FOCUS_2006_C
+  FOCUS_2006_D
+  FOCUS_2006_E
+  FOCUS_2006_F
+ + +

Format

+ +

6 datasets with observations on the following variables.

+
name

a factor containing the name of the observed variable

+
time

a numeric vector containing time points

+
value

a numeric vector containing concentrations in percent of applied radioactivity

+ + + +

Source

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
FOCUS_2006_C
#> name time value +#> 1 parent 0 85.1 +#> 2 parent 1 57.9 +#> 3 parent 3 29.9 +#> 4 parent 7 14.6 +#> 5 parent 14 9.7 +#> 6 parent 28 6.6 +#> 7 parent 63 4.0 +#> 8 parent 91 3.9 +#> 9 parent 119 0.6
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/FOMC.solution-1.png b/docs/dev/reference/FOMC.solution-1.png new file mode 100644 index 00000000..aa41a253 Binary files /dev/null and b/docs/dev/reference/FOMC.solution-1.png differ diff --git a/docs/dev/reference/FOMC.solution.html b/docs/dev/reference/FOMC.solution.html new file mode 100644 index 00000000..8ed22157 --- /dev/null +++ b/docs/dev/reference/FOMC.solution.html @@ -0,0 +1,245 @@ + + + + + + + + +First-Order Multi-Compartment kinetics — FOMC.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing exponential decline from a defined starting value, with +a decreasing rate constant.

+
+ +
FOMC.solution(t, parent_0, alpha, beta)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

alpha

Shape parameter determined by coefficient of variation of rate +constant values.

beta

Location parameter.

+ +

Value

+ +

The value of the response variable at time t.

+

Details

+ +

The form given here differs slightly from the original reference by +Gustafson and Holden (1990). The parameter beta corresponds to 1/beta +in the original equation.

+

Note

+ +

The solution of the FOMC kinetic model reduces to the +SFO.solution for large values of alpha and +beta with \(k = \frac{\beta}{\alpha}\).

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

Gustafson DI and Holden LR (1990) Nonlinear pesticide dissipation in soil: +A new model based on spatial variability. Environmental Science and +Technology 24, 1032-1038

+

See also

+ + + +

Examples

+
+ plot(function(x) FOMC.solution(x, 100, 10, 2), 0, 2, ylim = c(0, 100))
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/HS.solution-1.png b/docs/dev/reference/HS.solution-1.png new file mode 100644 index 00000000..ae056d9b Binary files /dev/null and b/docs/dev/reference/HS.solution-1.png differ diff --git a/docs/dev/reference/HS.solution.html b/docs/dev/reference/HS.solution.html new file mode 100644 index 00000000..5053542a --- /dev/null +++ b/docs/dev/reference/HS.solution.html @@ -0,0 +1,237 @@ + + + + + + + + +Hockey-Stick kinetics — HS.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing two exponential decline functions with a break point +between them.

+
+ +
HS.solution(t, parent_0, k1, k2, tb)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k1

First kinetic constant.

k2

Second kinetic constant.

tb

Break point. Before this time, exponential decline according to +k1 is calculated, after this time, exponential decline proceeds +according to k2.

+ +

Value

+ +

The value of the response variable at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

See also

+ + + +

Examples

+
+ plot(function(x) HS.solution(x, 100, 2, 0.3, 0.5), 0, 2, ylim=c(0,100))
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/IORE.solution-1.png b/docs/dev/reference/IORE.solution-1.png new file mode 100644 index 00000000..00e28460 Binary files /dev/null and b/docs/dev/reference/IORE.solution-1.png differ diff --git a/docs/dev/reference/IORE.solution.html b/docs/dev/reference/IORE.solution.html new file mode 100644 index 00000000..9db7447c --- /dev/null +++ b/docs/dev/reference/IORE.solution.html @@ -0,0 +1,245 @@ + + + + + + + + +Indeterminate order rate equation kinetics — IORE.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing exponential decline from a defined starting value, with +a concentration dependent rate constant.

+
+ +
IORE.solution(t, parent_0, k__iore, N)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k__iore

Rate constant. Note that this depends on the concentration +units used.

N

Exponent describing the nonlinearity of the rate equation

+ +

Value

+ +

The value of the response variable at time t.

+

Note

+ +

The solution of the IORE kinetic model reduces to the +SFO.solution if N = 1. The parameters of the IORE model can +be transformed to equivalent parameters of the FOMC mode - see the NAFTA +guidance for details.

+

References

+ +

NAFTA Technical Working Group on Pesticides (not dated) Guidance +for Evaluating and Calculating Degradation Kinetics in Environmental Media

+

See also

+ + + +

Examples

+
+ plot(function(x) IORE.solution(x, 100, 0.2, 1.3), 0, 2, ylim = c(0, 100))
# \dontrun{ + fit.fomc <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) + fit.iore <- mkinfit("IORE", FOCUS_2006_C, quiet = TRUE) + fit.iore.deS <- mkinfit("IORE", FOCUS_2006_C, solution_type = "deSolve", quiet = TRUE) + + print(data.frame(fit.fomc$par, fit.iore$par, fit.iore.deS$par, + row.names = paste("model par", 1:4)))
#> fit.fomc.par fit.iore.par fit.iore.deS.par +#> model par 1 85.87489063 85.874890 85.874890 +#> model par 2 0.05192238 -4.826631 -4.826631 +#> model par 3 0.65096665 1.949403 1.949403 +#> model par 4 1.85744396 1.857444 1.857444
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
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_2015-1.png b/docs/dev/reference/NAFTA_SOP_2015-1.png new file mode 100644 index 00000000..9025f2bb Binary files /dev/null and b/docs/dev/reference/NAFTA_SOP_2015-1.png differ diff --git a/docs/dev/reference/NAFTA_SOP_2015.html b/docs/dev/reference/NAFTA_SOP_2015.html new file mode 100644 index 00000000..c7e20a45 --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_2015.html @@ -0,0 +1,240 @@ + + + + + + + + +Example datasets from the NAFTA SOP published 2015 — NAFTA_SOP_2015 • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Data taken from US EPA (2015), p. 19 and 23.

+
+ +
NAFTA_SOP_Appendix_B
+  NAFTA_SOP_Appendix_D
+ + +

Format

+ +

2 datasets with observations on the following variables.

+
name

a factor containing the name of the observed variable

+
time

a numeric vector containing time points

+
value

a numeric vector containing concentrations

+ + + +

Source

+ +

NAFTA (2011) Guidance for evaluating and calculating degradation kinetics + in environmental media. NAFTA Technical Working Group on Pesticides + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation + accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to + Calculate Representative Half-life Values and Characterizing Pesticide + Degradation + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+ +

Examples

+
nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
#> 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
print(nafta_evaluation)
#> Sums of squares: +#> SFO IORE DFOP +#> 1378.6832 615.7730 517.8836 +#> +#> Critical sum of squares for checking the SFO model: +#> [1] 717.4598 +#> +#> Parameters: +#> $SFO +#> Estimate Pr(>t) Lower Upper +#> parent_0 83.7558 1.80e-14 77.18268 90.3288 +#> k_parent_sink 0.0017 7.43e-05 0.00112 0.0026 +#> sigma 8.7518 1.22e-05 5.64278 11.8608 +#> +#> $IORE +#> Estimate Pr(>t) Lower Upper +#> parent_0 9.69e+01 NA 8.88e+01 1.05e+02 +#> k__iore_parent_sink 8.40e-14 NA 1.79e-18 3.94e-09 +#> N_parent 6.68e+00 NA 4.19e+00 9.17e+00 +#> sigma 5.85e+00 NA 3.76e+00 7.94e+00 +#> +#> $DFOP +#> Estimate Pr(>t) Lower Upper +#> parent_0 9.76e+01 1.94e-13 9.02e+01 1.05e+02 +#> k1 4.24e-02 5.92e-03 2.03e-02 8.88e-02 +#> k2 8.24e-04 6.48e-03 3.89e-04 1.75e-03 +#> g 2.88e-01 2.47e-05 1.95e-01 4.03e-01 +#> sigma 5.36e+00 2.22e-05 3.43e+00 7.30e+00 +#> +#> +#> DTx values: +#> DT50 DT90 DT50_rep +#> SFO 407 1350 407 +#> IORE 541 5190000 1560000 +#> DFOP 429 2380 841 +#> +#> Representative half-life: +#> [1] 841.41
plot(nafta_evaluation)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/NAFTA_SOP_Attachment-1.png b/docs/dev/reference/NAFTA_SOP_Attachment-1.png new file mode 100644 index 00000000..19da6da7 Binary files /dev/null and b/docs/dev/reference/NAFTA_SOP_Attachment-1.png differ diff --git a/docs/dev/reference/NAFTA_SOP_Attachment.html b/docs/dev/reference/NAFTA_SOP_Attachment.html new file mode 100644 index 00000000..7bc7817e --- /dev/null +++ b/docs/dev/reference/NAFTA_SOP_Attachment.html @@ -0,0 +1,234 @@ + + + + + + + + +Example datasets from Attachment 1 to the NAFTA SOP published 2015 — NAFTA_SOP_Attachment • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Data taken from from Attachment 1 of the SOP.

+
+ +
NAFTA_SOP_Attachment
+ + +

Format

+ +

A list (NAFTA_SOP_Attachment) containing 16 datasets suitable + for the evaluation with nafta

+

Source

+ +

NAFTA (2011) Guidance for evaluating and calculating degradation kinetics + in environmental media. NAFTA Technical Working Group on Pesticides + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation + accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to + Calculate Representative Half-life Values and Characterizing Pesticide + Degradation + https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+ +

Examples

+
nafta_att_p5a <- nafta(NAFTA_SOP_Attachment[["p5a"]], cores = 1)
#> 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
print(nafta_att_p5a)
#> Sums of squares: +#> SFO IORE DFOP +#> 465.21753 56.27506 32.06401 +#> +#> Critical sum of squares for checking the SFO model: +#> [1] 64.4304 +#> +#> Parameters: +#> $SFO +#> Estimate Pr(>t) Lower Upper +#> parent_0 95.8401 4.67e-21 92.245 99.4357 +#> k_parent_sink 0.0102 3.92e-12 0.009 0.0117 +#> sigma 4.8230 3.81e-06 3.214 6.4318 +#> +#> $IORE +#> Estimate Pr(>t) Lower Upper +#> parent_0 1.01e+02 NA 9.91e+01 1.02e+02 +#> k__iore_parent_sink 1.54e-05 NA 4.08e-06 5.84e-05 +#> N_parent 2.57e+00 NA 2.25e+00 2.89e+00 +#> sigma 1.68e+00 NA 1.12e+00 2.24e+00 +#> +#> $DFOP +#> Estimate Pr(>t) Lower Upper +#> parent_0 9.99e+01 1.41e-26 98.8116 101.0810 +#> k1 2.67e-02 5.05e-06 0.0243 0.0295 +#> k2 2.86e-12 5.00e-01 0.0000 Inf +#> g 6.47e-01 3.67e-06 0.6248 0.6677 +#> sigma 1.27e+00 8.91e-06 0.8395 1.6929 +#> +#> +#> DTx values: +#> DT50 DT90 DT50_rep +#> SFO 67.7 2.25e+02 6.77e+01 +#> IORE 58.2 1.07e+03 3.22e+02 +#> DFOP 55.5 4.42e+11 2.42e+11 +#> +#> Representative half-life: +#> [1] 321.51
plot(nafta_att_p5a)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/SFO.solution-1.png b/docs/dev/reference/SFO.solution-1.png new file mode 100644 index 00000000..b0b854bb Binary files /dev/null and b/docs/dev/reference/SFO.solution-1.png differ diff --git a/docs/dev/reference/SFO.solution.html b/docs/dev/reference/SFO.solution.html new file mode 100644 index 00000000..02b3cf22 --- /dev/null +++ b/docs/dev/reference/SFO.solution.html @@ -0,0 +1,225 @@ + + + + + + + + +Single First-Order kinetics — SFO.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing exponential decline from a defined starting value.

+
+ +
SFO.solution(t, parent_0, k)
+ +

Arguments

+ + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k

Kinetic rate constant.

+ +

Value

+ +

The value of the response variable at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

See also

+ + + +

Examples

+
+ plot(function(x) SFO.solution(x, 100, 3), 0, 2)
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/SFORB.solution-1.png b/docs/dev/reference/SFORB.solution-1.png new file mode 100644 index 00000000..cd58caec Binary files /dev/null and b/docs/dev/reference/SFORB.solution-1.png differ diff --git a/docs/dev/reference/SFORB.solution.html b/docs/dev/reference/SFORB.solution.html new file mode 100644 index 00000000..87d39b4e --- /dev/null +++ b/docs/dev/reference/SFORB.solution.html @@ -0,0 +1,243 @@ + + + + + + + + +Single First-Order Reversible Binding kinetics — SFORB.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing the solution of the differential equations describing +the kinetic model with first-order terms for a two-way transfer from a free +to a bound fraction, and a first-order degradation term for the free +fraction. The initial condition is a defined amount in the free fraction +and no substance in the bound fraction.

+
+ +
SFORB.solution(t, parent_0, k_12, k_21, k_1output)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

k_12

Kinetic constant describing transfer from free to bound.

k_21

Kinetic constant describing transfer from bound to free.

k_1output

Kinetic constant describing degradation of the free +fraction.

+ +

Value

+ +

The value of the response variable, which is the sum of free and +bound fractions at time t.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

See also

+ + + +

Examples

+
+ plot(function(x) SFORB.solution(x, 100, 0.5, 2, 3), 0, 2)
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/add_err-1.png b/docs/dev/reference/add_err-1.png new file mode 100644 index 00000000..88806d7b Binary files /dev/null and b/docs/dev/reference/add_err-1.png differ diff --git a/docs/dev/reference/add_err-2.png b/docs/dev/reference/add_err-2.png new file mode 100644 index 00000000..6a806c2d Binary files /dev/null and b/docs/dev/reference/add_err-2.png differ diff --git a/docs/dev/reference/add_err-3.png b/docs/dev/reference/add_err-3.png new file mode 100644 index 00000000..1919a566 Binary files /dev/null and b/docs/dev/reference/add_err-3.png differ diff --git a/docs/dev/reference/add_err.html b/docs/dev/reference/add_err.html new file mode 100644 index 00000000..a4317cd7 --- /dev/null +++ b/docs/dev/reference/add_err.html @@ -0,0 +1,287 @@ + + + + + + + + +Add normally distributed errors to simulated kinetic degradation data — add_err • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Normally distributed errors are added to data predicted for a specific +degradation model using mkinpredict. The variance of the error +may depend on the predicted value and is specified as a standard deviation.

+
+ +
add_err(
+  prediction,
+  sdfunc,
+  secondary = c("M1", "M2"),
+  n = 1000,
+  LOD = 0.1,
+  reps = 2,
+  digits = 1,
+  seed = NA
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
prediction

A prediction from a kinetic model as produced by +mkinpredict.

sdfunc

A function taking the predicted value as its only argument and +returning a standard deviation that should be used for generating the +random error terms for this value.

secondary

The names of state variables that should have an initial +value of zero

n

The number of datasets to be generated.

LOD

The limit of detection (LOD). Values that are below the LOD after +adding the random error will be set to NA.

reps

The number of replicates to be generated within the datasets.

digits

The number of digits to which the values will be rounded.

seed

The seed used for the generation of random numbers. If NA, the +seed is not set.

+ +

Value

+ +

A list of datasets compatible with mmkin, i.e. the +components of the list are datasets compatible with mkinfit.

+

References

+ +

Ranke J and Lehmann R (2015) To t-test or not to t-test, that is +the question. XV Symposium on Pesticide Chemistry 2-4 September 2015, +Piacenza, Italy +https://jrwb.de/posters/piacenza_2015.pdf

+ +

Examples

+
+# 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) + +# This is the prediction used for the "Type 2 datasets" on the Piacenza poster +# from 2015 +d_SFO_SFO <- mkinpredict(m_SFO_SFO, + c(k_parent = 0.1, f_parent_to_M1 = 0.5, + k_M1 = log(2)/1000), + c(parent = 100, M1 = 0), + sampling_times) + +# Add an error term with a constant (independent of the value) standard deviation +# of 10, and generate three datasets +d_SFO_SFO_err <- add_err(d_SFO_SFO, function(x) 10, n = 3, seed = 123456789 ) + +# Name the datasets for nicer plotting +names(d_SFO_SFO_err) <- paste("Dataset", 1:3) + +# Name the model in the list of models (with only one member in this case) for +# nicer plotting later on. Be quiet and use only one core not to offend CRAN +# checks +# \dontrun{ +f_SFO_SFO <- mmkin(list("SFO-SFO" = m_SFO_SFO), + d_SFO_SFO_err, cores = 1, + quiet = TRUE) + +plot(f_SFO_SFO)
+# We would like to inspect the fit for dataset 3 more closely +# Using double brackets makes the returned object an mkinfit object +# instead of a list of mkinfit objects, so plot.mkinfit is used +plot(f_SFO_SFO[[3]], show_residuals = TRUE)
+# If we use single brackets, we should give two indices (model and dataset), +# and plot.mmkin is used +plot(f_SFO_SFO[1, 3])
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/aw.html b/docs/dev/reference/aw.html new file mode 100644 index 00000000..267c3b0b --- /dev/null +++ b/docs/dev/reference/aw.html @@ -0,0 +1,221 @@ + + + + + + + + +Calculate Akaike weights for model averaging — aw • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Akaike weights are calculated based on the relative +expected Kullback-Leibler information as specified +by Burnham and Anderson (2004).

+
+ +
aw(object, ...)
+
+# S3 method for mkinfit
+aw(object, ...)
+
+# S3 method for mmkin
+aw(object, ...)
+ +

Arguments

+ + + + + + + + + + +
object

An mmkin column object, containing two or more +mkinfit models that have been fitted to the same data, +or an mkinfit object. In the latter case, further mkinfit +objects fitted to the same data should be specified +as dots arguments.

...

Not used in the method for mmkin column objects, +further mkinfit objects in the method for mkinfit objects.

+ +

References

+ +

Burnham KP and Anderson DR (2004) Multimodel +Inference: Understanding AIC and BIC in Model Selection. +Sociological Methods & Research 33(2) 261-304

+ +

Examples

+
# \dontrun{ +f_sfo <- mkinfit("SFO", FOCUS_2006_D, quiet = TRUE) +f_dfop <- mkinfit("DFOP", FOCUS_2006_D, quiet = TRUE) +aw_sfo_dfop <- aw(f_sfo, f_dfop) +sum(aw_sfo_dfop)
#> [1] 1
aw_sfo_dfop # SFO gets more weight as it has less parameters and a similar fit
#> [1] 0.5970258 0.4029742
f <- mmkin(c("SFO", "FOMC", "DFOP"), list("FOCUS D" = FOCUS_2006_D), cores = 1, quiet = TRUE) +aw(f)
#> [1] 0.4808722 0.1945539 0.3245740
sum(aw(f))
#> [1] 1
aw(f[c("SFO", "DFOP")])
#> [1] 0.5970258 0.4029742
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/confint.mkinfit.html b/docs/dev/reference/confint.mkinfit.html new file mode 100644 index 00000000..a03ecea8 --- /dev/null +++ b/docs/dev/reference/confint.mkinfit.html @@ -0,0 +1,419 @@ + + + + + + + + +Confidence intervals for parameters of mkinfit objects — confint.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The default method 'quadratic' is based on the quadratic approximation of +the curvature of the likelihood function at the maximum likelihood parameter +estimates. +The alternative method 'profile' is based on the profile likelihood for each +parameter. The 'profile' method uses two nested optimisations and can take a +very long time, even if parallelized by specifying 'cores' on unixoid +platforms. The speed of the method could likely be improved by using the +method of Venzon and Moolgavkar (1988).

+
+ +
# S3 method for mkinfit
+confint(
+  object,
+  parm,
+  level = 0.95,
+  alpha = 1 - level,
+  cutoff,
+  method = c("quadratic", "profile"),
+  transformed = TRUE,
+  backtransform = TRUE,
+  cores = parallel::detectCores(),
+  rel_tol = 0.01,
+  quiet = FALSE,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
object

An mkinfit object

parm

A vector of names of the parameters which are to be given +confidence intervals. If missing, all parameters are considered.

level

The confidence level required

alpha

The allowed error probability, overrides 'level' if specified.

cutoff

Possibility to specify an alternative cutoff for the difference +in the log-likelihoods at the confidence boundary. Specifying an explicit +cutoff value overrides arguments 'level' and 'alpha'

method

The 'quadratic' method approximates the likelihood function at +the optimised parameters using the second term of the Taylor expansion, +using a second derivative (hessian) contained in the object. +The 'profile' method searches the parameter space for the +cutoff of the confidence intervals by means of a likelihood ratio test.

transformed

If the quadratic approximation is used, should it be +applied to the likelihood based on the transformed parameters?

backtransform

If we approximate the likelihood in terms of the +transformed parameters, should we backtransform the parameters with +their confidence intervals?

cores

The number of cores to be used for multicore processing. +On Windows machines, cores > 1 is currently not supported.

rel_tol

If the method is 'profile', what should be the accuracy +of the lower and upper bounds, relative to the estimate obtained from +the quadratic method?

quiet

Should we suppress the message "Profiling the likelihood"

...

Not used

+ +

Value

+ +

A matrix with columns giving lower and upper confidence limits for +each parameter.

+

References

+ +

Bates DM and Watts GW (1988) Nonlinear regression analysis & its applications

+

Pawitan Y (2013) In all likelihood - Statistical modelling and +inference using likelihood. Clarendon Press, Oxford.

+

Venzon DJ and Moolgavkar SH (1988) A Method for Computing +Profile-Likelihood Based Confidence Intervals, Applied Statistics, 37, +87–94.

+ +

Examples

+
f <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE) +confint(f, method = "quadratic")
#> 2.5% 97.5% +#> parent_0 71.8242430 93.1600766 +#> k_parent_sink 0.2109541 0.4440528 +#> sigma 1.9778868 7.3681380
+# \dontrun{ +confint(f, method = "profile")
#> Profiling the likelihood
#> 2.5% 97.5% +#> parent_0 73.0641834 92.1392181 +#> k_parent_sink 0.2170293 0.4235348 +#> sigma 3.1307772 8.0628314
+# Set the number of cores for the profiling method for further examples +if (identical(Sys.getenv("NOT_CRAN"), "true")) { + n_cores <- parallel::detectCores() - 1 +} else { + n_cores <- 1 +} +if (Sys.getenv("TRAVIS") != "") n_cores = 1 +if (Sys.info()["sysname"] == "Windows") n_cores = 1 + +SFO_SFO <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), quiet = TRUE) +SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"), + use_of_ff = "max", quiet = TRUE) +f_d_1 <- mkinfit(SFO_SFO, subset(FOCUS_2006_D, value != 0), quiet = TRUE) +system.time(ci_profile <- confint(f_d_1, method = "profile", cores = 1, quiet = TRUE))
#> user system elapsed +#> 3.707 1.077 3.444
# Using more cores does not save much time here, as parent_0 takes up most of the time +# If we additionally exclude parent_0 (the confidence of which is often of +# minor interest), we get a nice performance improvement from about 50 +# seconds to about 12 seconds if we use at least four cores +system.time(ci_profile_no_parent_0 <- confint(f_d_1, method = "profile", + c("k_parent_sink", "k_parent_m1", "k_m1_sink", "sigma"), cores = n_cores))
#> Profiling the likelihood
#> Warning: scheduled cores 2, 1, 3 encountered errors in user code, all values of the jobs will be affected
#> Error in dimnames(x) <- dn: length of 'dimnames' [2] not equal to array extent
#> Timing stopped at: 0.011 0.026 0.207
ci_profile
#> 2.5% 97.5% +#> parent_0 96.456003640 1.027703e+02 +#> k_parent 0.090911032 1.071578e-01 +#> k_m1 0.003892605 6.702778e-03 +#> f_parent_to_m1 0.471328495 5.611550e-01 +#> sigma 2.535612399 3.985263e+00
ci_quadratic_transformed <- confint(f_d_1, method = "quadratic") +ci_quadratic_transformed
#> 2.5% 97.5% +#> parent_0 96.403839476 1.027931e+02 +#> k_parent 0.090823790 1.072543e-01 +#> k_m1 0.004012216 6.897547e-03 +#> f_parent_to_m1 0.469118713 5.595960e-01 +#> sigma 2.396089689 3.854918e+00
ci_quadratic_untransformed <- confint(f_d_1, method = "quadratic", transformed = FALSE) +ci_quadratic_untransformed
#> 2.5% 97.5% +#> parent_0 96.403839429 1.027931e+02 +#> k_parent 0.090491931 1.069035e-01 +#> k_m1 0.003835483 6.685819e-03 +#> f_parent_to_m1 0.469113364 5.598386e-01 +#> sigma 2.396089689 3.854918e+00
# Against the expectation based on Bates and Watts (1988), the confidence +# intervals based on the internal parameter transformation are less +# congruent with the likelihood based intervals. Note the superiority of the +# interval based on the untransformed fit for k_m1_sink +rel_diffs_transformed <- abs((ci_quadratic_transformed - ci_profile)/ci_profile) +rel_diffs_untransformed <- abs((ci_quadratic_untransformed - ci_profile)/ci_profile) +rel_diffs_transformed < rel_diffs_untransformed
#> 2.5% 97.5% +#> parent_0 TRUE TRUE +#> k_parent TRUE TRUE +#> k_m1 FALSE FALSE +#> f_parent_to_m1 TRUE FALSE +#> sigma FALSE TRUE
signif(rel_diffs_transformed, 3)
#> 2.5% 97.5% +#> parent_0 0.000541 0.000222 +#> k_parent 0.000960 0.000900 +#> k_m1 0.030700 0.029100 +#> f_parent_to_m1 0.004690 0.002780 +#> sigma 0.055000 0.032700
signif(rel_diffs_untransformed, 3)
#> 2.5% 97.5% +#> parent_0 0.000541 0.000222 +#> k_parent 0.004610 0.002370 +#> k_m1 0.014700 0.002530 +#> f_parent_to_m1 0.004700 0.002350 +#> sigma 0.055000 0.032700
+ +# Investigate a case with formation fractions +f_d_2 <- mkinfit(SFO_SFO.ff, subset(FOCUS_2006_D, value != 0), quiet = TRUE) +ci_profile_ff <- confint(f_d_2, method = "profile", cores = n_cores)
#> Profiling the likelihood
ci_profile_ff
#> 2.5% 97.5% +#> parent_0 96.456003640 1.027703e+02 +#> k_parent 0.090911032 1.071578e-01 +#> k_m1 0.003892605 6.702778e-03 +#> f_parent_to_m1 0.471328495 5.611550e-01 +#> sigma 2.535612399 3.985263e+00
ci_quadratic_transformed_ff <- confint(f_d_2, method = "quadratic") +ci_quadratic_transformed_ff
#> 2.5% 97.5% +#> parent_0 96.403839476 1.027931e+02 +#> k_parent 0.090823790 1.072543e-01 +#> k_m1 0.004012216 6.897547e-03 +#> f_parent_to_m1 0.469118713 5.595960e-01 +#> sigma 2.396089689 3.854918e+00
ci_quadratic_untransformed_ff <- confint(f_d_2, method = "quadratic", transformed = FALSE) +ci_quadratic_untransformed_ff
#> 2.5% 97.5% +#> parent_0 96.403839429 1.027931e+02 +#> k_parent 0.090491931 1.069035e-01 +#> k_m1 0.003835483 6.685819e-03 +#> f_parent_to_m1 0.469113364 5.598386e-01 +#> sigma 2.396089689 3.854918e+00
rel_diffs_transformed_ff <- abs((ci_quadratic_transformed_ff - ci_profile_ff)/ci_profile_ff) +rel_diffs_untransformed_ff <- abs((ci_quadratic_untransformed_ff - ci_profile_ff)/ci_profile_ff) +# While the confidence interval for the parent rate constant is closer to +# the profile based interval when using the internal parameter +# transformation, the interval for the metabolite rate constant is 'better +# without internal parameter transformation. +rel_diffs_transformed_ff < rel_diffs_untransformed_ff
#> 2.5% 97.5% +#> parent_0 TRUE TRUE +#> k_parent TRUE TRUE +#> k_m1 FALSE FALSE +#> f_parent_to_m1 TRUE FALSE +#> sigma FALSE TRUE
rel_diffs_transformed_ff
#> 2.5% 97.5% +#> parent_0 0.0005408078 0.0002217796 +#> k_parent 0.0009596417 0.0009003876 +#> k_m1 0.0307277372 0.0290579184 +#> f_parent_to_m1 0.0046884131 0.0027782558 +#> sigma 0.0550252516 0.0327066836
rel_diffs_untransformed_ff
#> 2.5% 97.5% +#> parent_0 0.0005408083 0.000221780 +#> k_parent 0.0046100096 0.002373023 +#> k_m1 0.0146746467 0.002530101 +#> f_parent_to_m1 0.0046997600 0.002346022 +#> sigma 0.0550252516 0.032706684
+# The profiling for the following fit does not finish in a reasonable time, +# therefore we use the quadratic approximation +m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), + M1 = mkinsub("SFO"), + M2 = mkinsub("SFO"), + use_of_ff = "max", quiet = TRUE) +DFOP_par_c <- synthetic_data_for_UBA_2014[[12]]$data +f_tc_2 <- mkinfit(m_synth_DFOP_par, DFOP_par_c, error_model = "tc", + error_model_algorithm = "direct", quiet = TRUE)
#> Warning: Optimisation did not converge: +#> iteration limit reached without convergence (10)
confint(f_tc_2, method = "quadratic")
#> 2.5% 97.5% +#> parent_0 95.654015524 105.79279749 +#> k_M1 0.037723773 0.04447598 +#> k_M2 0.008586438 0.01078076 +#> f_parent_to_M1 0.230403596 0.61953014 +#> f_parent_to_M2 0.162909765 0.38019017 +#> k1 0.275434628 0.33331386 +#> k2 0.018602188 0.02249211 +#> g 0.675149759 0.73520889 +#> sigma_low 0.251416929 0.84272023 +#> rsd_high 0.040371818 0.07666540
confint(f_tc_2, "parent_0", method = "quadratic")
#> 2.5% 97.5% +#> parent_0 95.65402 105.7928
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/create_deg_func.html b/docs/dev/reference/create_deg_func.html new file mode 100644 index 00000000..59984b8c --- /dev/null +++ b/docs/dev/reference/create_deg_func.html @@ -0,0 +1,225 @@ + + + + + + + + +Create degradation functions for known analytical solutions — create_deg_func • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Create degradation functions for known analytical solutions

+
+ +
create_deg_func(spec, use_of_ff = c("min", "max"))
+ +

Arguments

+ + + + + + + + + + +
spec

List of model specifications as contained in mkinmod objects

use_of_ff

Minimum or maximum use of formation fractions

+ +

Value

+ +

Degradation function to be attached to mkinmod objects

+ +

Examples

+
+SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
FOCUS_D <- subset(FOCUS_2006_D, value != 0) # to avoid warnings +fit_1 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE) +fit_2 <- mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE) +# \dontrun{ +if (require(rbenchmark)) + benchmark( + analytical = mkinfit(SFO_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE), + deSolve = mkinfit(SFO_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE), + replications = 2)
#> Loading required package: rbenchmark
#> test replications elapsed relative user.self sys.self user.child +#> 1 analytical 2 0.422 1.000 0.421 0 0 +#> 2 deSolve 2 0.722 1.711 0.721 0 0 +#> sys.child +#> 1 0 +#> 2 0
DFOP_SFO <- mkinmod( + parent = mkinsub("DFOP", "m1"), + m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
benchmark( + analytical = mkinfit(DFOP_SFO, FOCUS_D, solution_type = "analytical", quiet = TRUE), + deSolve = mkinfit(DFOP_SFO, FOCUS_D, solution_type = "deSolve", quiet = TRUE), + replications = 2)
#> test replications elapsed relative user.self sys.self user.child +#> 1 analytical 2 0.907 1.000 0.906 0 0 +#> 2 deSolve 2 1.659 1.829 1.658 0 0 +#> sys.child +#> 1 0 +#> 2 0
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/endpoints.html b/docs/dev/reference/endpoints.html new file mode 100644 index 00000000..5751df93 --- /dev/null +++ b/docs/dev/reference/endpoints.html @@ -0,0 +1,232 @@ + + + + + + + + +Function to calculate endpoints for further use from kinetic models fitted +with mkinfit — endpoints • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function calculates DT50 and DT90 values as well as formation fractions +from kinetic models fitted with mkinfit. If the SFORB model was specified +for one of the parents or metabolites, the Eigenvalues are returned. These +are equivalent to the rate constants of the DFOP model, but with the +advantage that the SFORB model can also be used for metabolites.

+
+ +
endpoints(fit)
+ +

Arguments

+ + + + + + +
fit

An object of class mkinfit or +nlme.mmkin

+ +

Value

+ +

A list with a matrix of dissipation times named distimes, +and, if applicable, a vector of formation fractions named ff +and, if the SFORB model was in use, a vector of eigenvalues +of these SFORB models, equivalent to DFOP rate constants

+

Note

+ +

The function is used internally by summary.mkinfit.

+ +

Examples

+
+ fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) + endpoints(fit)
#> $distimes +#> DT50 DT90 DT50back +#> parent 1.785233 15.1479 4.559973 +#>
# \dontrun{ + fit_2 <- mkinfit("SFORB", FOCUS_2006_C, quiet = TRUE) + endpoints(fit_2)
#> $ff +#> parent_free_sink +#> 1 +#> +#> $SFORB +#> parent_b1 parent_b2 +#> 0.4595574 0.0178488 +#> +#> $distimes +#> DT50 DT90 DT50_parent_b1 DT50_parent_b2 +#> parent 1.886925 21.25106 1.508293 38.83438 +#>
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/experimental_data_for_UBA-1.png b/docs/dev/reference/experimental_data_for_UBA-1.png new file mode 100644 index 00000000..b316a5db Binary files /dev/null and b/docs/dev/reference/experimental_data_for_UBA-1.png differ diff --git a/docs/dev/reference/experimental_data_for_UBA.html b/docs/dev/reference/experimental_data_for_UBA.html new file mode 100644 index 00000000..d49924c7 --- /dev/null +++ b/docs/dev/reference/experimental_data_for_UBA.html @@ -0,0 +1,300 @@ + + + + + + + + +Experimental datasets used for development and testing of error models — experimental_data_for_UBA_2019 • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The 12 datasets were extracted from active substance evaluation dossiers published + by EFSA. Kinetic evaluations shown for these datasets are intended to illustrate + and advance error model specifications. The fact that these data and some + results are shown here do not imply a license to use them in the context of + pesticide registrations, as the use of the data may be constrained by + data protection regulations.

+

Preprocessing of data was performed based on the recommendations of the FOCUS + kinetics workgroup (FOCUS, 2014) as described below.

+

Datasets 1 and 2 are from the Renewal Assessment Report (RAR) for imazamox + (France, 2015, p. 15). For setting values reported as zero, an LOQ of 0.1 + was assumed. Metabolite residues reported for day zero were added to the + parent compound residues.

+

Datasets 3 and 4 are from the Renewal Assessment Report (RAR) for isofetamid + (Belgium, 2014, p. 8) and show the data for two different radiolabels. For + dataset 4, the value given for the metabolite in the day zero sampling + in replicate B was added to the parent compound, following the respective + FOCUS recommendation.

+

Dataset 5 is from the Renewal Assessment Report (RAR) for ethofumesate + (Austria, 2015, p. 16).

+

Datasets 6 to 10 are from the Renewal Assessment Report (RAR) for glyphosate + (Germany, 2013a, pages 8, 28, 50, 51). For the initial sampling, + the residues given for the metabolite were added to the parent + value, following the recommendation of the FOCUS kinetics workgroup.

+

Dataset 11 is from the Renewal Assessment Report (RAR) for 2,4-D + (Germany, 2013b, p. 644). Values reported as zero were set to NA, with + the exception of the day three sampling of metabolite A2, which was set + to one half of the LOD reported to be 1% AR.

+

Dataset 12 is from the Renewal Assessment Report (RAR) for thifensulfuron-methyl + (United Kingdom, 2014, p. 81).

+
+ +
experimental_data_for_UBA_2019
+ + +

Format

+ +

A list containing twelve datasets as an R6 class defined by mkinds, + each containing, among others, the following components

+
title

The name of the dataset, e.g. Soil 1

+
data

A data frame with the data in the form expected by mkinfit

+ + + +

Source

+ + + +

Austria (2015). Ethofumesate Renewal Assessment Report Volume 3 Annex B.8 (AS)

+

Belgium (2014). Isofetamid (IKF-5411) Draft Assessment Report Volume 3 Annex B.8 (AS)

+

France (2015). Imazamox Draft Renewal Assessment Report Volume 3 Annex B.8 (AS)

+

FOCUS (2014) “Generic guidance for Estimating Persistence and + Degradation Kinetics from Environmental Fate Studies on Pesticides in EU + Registration” Report of the FOCUS Work Group on Degradation Kinetics, + Version 1.1, 18 December 2014 + http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

Germany (2013a). Renewal Assessment Report Glyphosate Volume 3 Annex B.8: Environmental Fate + and Behaviour

+

Germany (2013b). Renewal Assessment Report 2,4-D Volume 3 Annex B.8: Fate and behaviour in the + environment

+

Ranke (2019) Documentation of results obtained for the error model expertise + written for the German Umweltbundesamt.

+

United Kingdom (2014). Thifensulfuron-methyl - Annex B.8 (Volume 3) to the Report and Proposed + Decision of the United Kingdom made to the European Commission under Regulation (EC) No. + 1141/2010 for renewal of an active substance

+ +

Examples

+
# \dontrun{ + +# Model definitions +sfo_sfo <- mkinmod( + parent = mkinsub("SFO", to = "A1"), + A1 = mkinsub("SFO"), + use_of_ff = "max" +)
#> Successfully compiled differential equation model from auto-generated C code.
+dfop_sfo <- mkinmod( + parent = mkinsub("DFOP", to = "A1"), + A1 = mkinsub("SFO"), + use_of_ff = "max" +)
#> Successfully compiled differential equation model from auto-generated C code.
+sfo_sfo_sfo <- mkinmod( + parent = mkinsub("SFO", to = "A1"), + A1 = mkinsub("SFO", to = "A2"), + A2 = mkinsub("SFO"), + use_of_ff = "max" +)
#> Successfully compiled differential equation model from auto-generated C code.
+dfop_sfo_sfo <- mkinmod( + parent = mkinsub("DFOP", to = "A1"), + A1 = mkinsub("SFO", to = "A2"), + A2 = mkinsub("SFO"), + use_of_ff = "max" +)
#> Successfully compiled differential equation model from auto-generated C code.
d_1_2 <- lapply(experimental_data_for_UBA_2019[1:2], function(x) x$data) +names(d_1_2) <- paste("Soil", 1:2) + + +f_1_2_tc <- mmkin(list("DFOP-SFO-SFO" = dfop_sfo_sfo), d_1_2, error_model = "tc") + +plot(f_1_2_tc, resplot = "errmod")
+# }
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/get_deg_func.html b/docs/dev/reference/get_deg_func.html new file mode 100644 index 00000000..7500186b --- /dev/null +++ b/docs/dev/reference/get_deg_func.html @@ -0,0 +1,185 @@ + + + + + + + + +Retrieve a degradation function from the mmkin namespace — get_deg_func • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Retrieve a degradation function from the mmkin namespace

+
+ +
get_deg_func()
+ + +

Value

+ +

A function that was likely previously assigned from within +nlme.mmkin

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/ilr.html b/docs/dev/reference/ilr.html new file mode 100644 index 00000000..245880f2 --- /dev/null +++ b/docs/dev/reference/ilr.html @@ -0,0 +1,220 @@ + + + + + + + + +Function to perform isometric log-ratio transformation — ilr • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This implementation is a special case of the class of isometric log-ratio +transformations.

+
+ +
ilr(x)
+
+invilr(x)
+ +

Arguments

+ + + + + + +
x

A numeric vector. Naturally, the forward transformation is only +sensible for vectors with all elements being greater than zero.

+ +

Value

+ +

The result of the forward or backward transformation. The returned +components always sum to 1 for the case of the inverse log-ratio +transformation.

+

References

+ +

Peter Filzmoser, Karel Hron (2008) Outlier Detection for +Compositional Data Using Robust Methods. Math Geosci 40 233-248

+

See also

+ +

Another implementation can be found in R package +robCompositions.

+ +

Examples

+
+# 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: +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
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/index.html b/docs/dev/reference/index.html new file mode 100644 index 00000000..906bc2f8 --- /dev/null +++ b/docs/dev/reference/index.html @@ -0,0 +1,699 @@ + + + + + + + + +Function reference • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+

Main functions

+

Essential functionality

+
+

mkinmod()

+

Function to set up a kinetic model with one or more state variables

+

mkinfit()

+

Fit a kinetic model to data with one or more state variables

+

mmkin()

+

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

+

nafta() print(<nafta>)

+

Evaluate parent kinetics using the NAFTA guidance

+

Show results

+

Functions working with mkinfit objects

+
+

plot(<mkinfit>) plot_sep() plot_res() plot_err()

+

Plot the observed data and the fitted model of an mkinfit object

+

summary(<mkinfit>) print(<summary.mkinfit>)

+

Summary method for class "mkinfit"

+

parms()

+

Extract model parameters from mkinfit models

+

confint(<mkinfit>)

+

Confidence intervals for parameters of mkinfit objects

+

update(<mkinfit>)

+

Update an mkinfit model with different arguments

+

lrtest(<mkinfit>) lrtest(<mmkin>)

+

Likelihood ratio test for mkinfit models

+

loftest()

+

Lack-of-fit test for models fitted to data with replicates

+

mkinerrmin()

+

Calculate the minimum error to assume in order to pass the variance test

+

endpoints()

+

Function to calculate endpoints for further use from kinetic models fitted +with mkinfit

+

aw()

+

Calculate Akaike weights for model averaging

+

CAKE_export()

+

Export a list of datasets format to a CAKE study file

+

Work with mmkin objects

+

Functions working with aggregated results

+
+

`[`(<mmkin>)

+

Subsetting method for mmkin objects

+

plot(<mmkin>)

+

Plot model fits (observed and fitted) and the residuals for a row or column +of an mmkin object

+

AIC(<mmkin>) BIC(<mmkin>)

+

Calculate the AIC for a column of an mmkin object

+

Mixed models

+

Create and work with nonlinear mixed models

+
+

nlme(<mmkin>) print(<nlme.mmkin>) update(<nlme.mmkin>)

+

Create an nlme model for an mmkin row object

+

plot(<nlme.mmkin>)

+

Plot a fitted nonlinear mixed model obtained via an mmkin row object

+

nlme_function() mean_degparms() nlme_data()

+

Helper functions to create nlme models from mmkin row objects

+

saemix_model() saemix_data()

+

Create saemix models from mmkin row objects

+

get_deg_func()

+

Retrieve a degradation function from the mmkin namespace

+

Datasets and known results

+

+
+

FOCUS_2006_A FOCUS_2006_B FOCUS_2006_C FOCUS_2006_D FOCUS_2006_E FOCUS_2006_F

+

Datasets A to F from the FOCUS Kinetics report from 2006

+

FOCUS_2006_SFO_ref_A_to_F

+

Results of fitting the SFO model to Datasets A to F of FOCUS (2006)

+

FOCUS_2006_FOMC_ref_A_to_F

+

Results of fitting the FOMC model to Datasets A to F of FOCUS (2006)

+

FOCUS_2006_HS_ref_A_to_F

+

Results of fitting the HS model to Datasets A to F of FOCUS (2006)

+

FOCUS_2006_DFOP_ref_A_to_B

+

Results of fitting the DFOP model to Datasets A to B of FOCUS (2006)

+

NAFTA_SOP_Appendix_B NAFTA_SOP_Appendix_D

+

Example datasets from the NAFTA SOP published 2015

+

NAFTA_SOP_Attachment

+

Example datasets from Attachment 1 to the NAFTA SOP published 2015

+

mccall81_245T

+

Datasets on aerobic soil metabolism of 2,4,5-T in six soils

+

schaefer07_complex_case

+

Metabolism data set used for checking the software quality of KinGUI

+

synthetic_data_for_UBA_2014

+

Synthetic datasets for one parent compound with two metabolites

+

experimental_data_for_UBA_2019

+

Experimental datasets used for development and testing of error models

+

test_data_from_UBA_2014

+

Three experimental datasets from two water sediment systems and one soil

+

mkinds

+

A dataset class for mkin

+

print(<mkinds>)

+

Print mkinds objects

+

NAFTA guidance

+

+
+

nafta() print(<nafta>)

+

Evaluate parent kinetics using the NAFTA guidance

+

plot(<nafta>)

+

Plot the results of the three models used in the NAFTA scheme.

+

Helper functions mainly used internally

+

+
+

mkinsub()

+

Function to set up a kinetic submodel for one state variable

+

max_twa_parent() max_twa_sfo() max_twa_fomc() max_twa_dfop() max_twa_hs()

+

Function to calculate maximum time weighted average concentrations from +kinetic models fitted with mkinfit

+

mkinpredict()

+

Produce predictions from a kinetic model using specific parameters

+

mkin_wide_to_long()

+

Convert a dataframe with observations over time into long format

+

mkin_long_to_wide()

+

Convert a dataframe from long to wide format

+

print(<mkinmod>)

+

Print mkinmod objects

+

transform_odeparms() backtransform_odeparms()

+

Functions to transform and backtransform kinetic parameters for fitting

+

ilr() invilr()

+

Function to perform isometric log-ratio transformation

+

sigma_twocomp()

+

Two-component error model

+

logLik(<mkinfit>)

+

Calculated the log-likelihood of a fitted mkinfit object

+

residuals(<mkinfit>)

+

Extract residuals from an mkinfit model

+

nobs(<mkinfit>)

+

Number of observations on which an mkinfit object was fitted

+

mkinresplot()

+

Function to plot residuals stored in an mkin object

+

mkinparplot()

+

Function to plot the confidence intervals obtained using mkinfit

+

mkinerrplot()

+

Function to plot squared residuals and the error model for an mkin object

+

create_deg_func()

+

Create degradation functions for known analytical solutions

+

Analytical solutions

+

Parent only model solutions

+
+

SFO.solution()

+

Single First-Order kinetics

+

FOMC.solution()

+

First-Order Multi-Compartment kinetics

+

DFOP.solution()

+

Double First-Order in Parallel kinetics

+

SFORB.solution()

+

Single First-Order Reversible Binding kinetics

+

HS.solution()

+

Hockey-Stick kinetics

+

IORE.solution()

+

Indeterminate order rate equation kinetics

+

logistic.solution()

+

Logistic kinetics

+

Generate synthetic datasets

+

+
+

add_err()

+

Add normally distributed errors to simulated kinetic degradation data

+

Deprecated functions

+

Functions that have been superseded

+
+

mkinplot()

+

Plot the observed data and the fitted model of an mkinfit object

+
+ + +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/loftest-1.png b/docs/dev/reference/loftest-1.png new file mode 100644 index 00000000..3d20f41e Binary files /dev/null and b/docs/dev/reference/loftest-1.png differ diff --git a/docs/dev/reference/loftest-2.png b/docs/dev/reference/loftest-2.png new file mode 100644 index 00000000..be8bf815 Binary files /dev/null and b/docs/dev/reference/loftest-2.png differ diff --git a/docs/dev/reference/loftest-3.png b/docs/dev/reference/loftest-3.png new file mode 100644 index 00000000..cb55838c Binary files /dev/null and b/docs/dev/reference/loftest-3.png differ diff --git a/docs/dev/reference/loftest-4.png b/docs/dev/reference/loftest-4.png new file mode 100644 index 00000000..e2b8ac5c Binary files /dev/null and b/docs/dev/reference/loftest-4.png differ diff --git a/docs/dev/reference/loftest-5.png b/docs/dev/reference/loftest-5.png new file mode 100644 index 00000000..a4d9fd48 Binary files /dev/null and b/docs/dev/reference/loftest-5.png differ diff --git a/docs/dev/reference/loftest.html b/docs/dev/reference/loftest.html new file mode 100644 index 00000000..b93b3aa3 --- /dev/null +++ b/docs/dev/reference/loftest.html @@ -0,0 +1,349 @@ + + + + + + + + +Lack-of-fit test for models fitted to data with replicates — loftest • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This is a generic function with a method currently only defined for mkinfit +objects. It fits an anova model to the data contained in the object and +compares the likelihoods using the likelihood ratio test +lrtest.default from the lmtest package.

+
+ +
loftest(object, ...)
+
+# S3 method for mkinfit
+loftest(object, ...)
+ +

Arguments

+ + + + + + + + + + +
object

A model object with a defined loftest method

...

Not used

+ +

Details

+ +

The anova model is interpreted as the simplest form of an mkinfit model, +assuming only a constant variance about the means, but not enforcing any +structure of the means, so we have one model parameter for every mean +of replicate samples.

+

See also

+ +

lrtest

+ +

Examples

+
# \dontrun{ +test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent") +sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE) +plot_res(sfo_fit) # We see a clear pattern in the residuals
loftest(sfo_fit) # We have a clear lack of fit
#> Likelihood ratio test +#> +#> Model 1: ANOVA with error model const +#> Model 2: SFO with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 10 -40.710 +#> 2 3 -63.954 -7 46.487 7.027e-08 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# +# We try a different model (the one that was used to generate the data) +dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE) +plot_res(dfop_fit) # We don't see systematic deviations, but heteroscedastic residuals
# therefore we should consider adapting the error model, although we have +loftest(dfop_fit) # no lack of fit
#> Likelihood ratio test +#> +#> Model 1: ANOVA with error model const +#> Model 2: DFOP with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 10 -40.710 +#> 2 5 -42.453 -5 3.485 0.6257
# +# This is the anova model used internally for the comparison +test_data_anova <- test_data +test_data_anova$time <- as.factor(test_data_anova$time) +anova_fit <- lm(value ~ time, data = test_data_anova) +summary(anova_fit)
#> +#> Call: +#> lm(formula = value ~ time, data = test_data_anova) +#> +#> Residuals: +#> Min 1Q Median 3Q Max +#> -6.1000 -0.5625 0.0000 0.5625 6.1000 +#> +#> Coefficients: +#> Estimate Std. Error t value Pr(>|t|) +#> (Intercept) 103.150 2.323 44.409 7.44e-12 *** +#> time1 -19.950 3.285 -6.073 0.000185 *** +#> time3 -50.800 3.285 -15.465 8.65e-08 *** +#> time7 -68.500 3.285 -20.854 6.28e-09 *** +#> time14 -79.750 3.285 -24.278 1.63e-09 *** +#> time28 -86.000 3.285 -26.181 8.35e-10 *** +#> time60 -94.900 3.285 -28.891 3.48e-10 *** +#> time90 -98.500 3.285 -29.986 2.49e-10 *** +#> time120 -100.450 3.285 -30.580 2.09e-10 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 +#> +#> Residual standard error: 3.285 on 9 degrees of freedom +#> Multiple R-squared: 0.9953, Adjusted R-squared: 0.9912 +#> F-statistic: 240.5 on 8 and 9 DF, p-value: 1.417e-09 +#>
logLik(anova_fit) # We get the same likelihood and degrees of freedom
#> 'log Lik.' -40.71015 (df=10)
# +test_data_2 <- synthetic_data_for_UBA_2014[[12]]$data +m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), + M1 = list(type = "SFO", to = "M2"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
sfo_lin_fit <- mkinfit(m_synth_SFO_lin, test_data_2, quiet = TRUE) +plot_res(sfo_lin_fit) # not a good model, we try parallel formation
loftest(sfo_lin_fit)
#> Likelihood ratio test +#> +#> Model 1: ANOVA with error model const +#> Model 2: m_synth_SFO_lin with error model const and fixed parameter(s) M1_0, M2_0 +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 28 -93.606 +#> 2 7 -171.927 -21 156.64 < 2.2e-16 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# +m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2")), + M1 = list(type = "SFO"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
sfo_par_fit <- mkinfit(m_synth_SFO_par, test_data_2, quiet = TRUE) +plot_res(sfo_par_fit) # much better for metabolites
loftest(sfo_par_fit)
#> Likelihood ratio test +#> +#> Model 1: ANOVA with error model const +#> Model 2: m_synth_SFO_par with error model const and fixed parameter(s) M1_0, M2_0 +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 28 -93.606 +#> 2 7 -156.331 -21 125.45 < 2.2e-16 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# +m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2")), + M1 = list(type = "SFO"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
dfop_par_fit <- mkinfit(m_synth_DFOP_par, test_data_2, quiet = TRUE) +plot_res(dfop_par_fit) # No visual lack of fit
loftest(dfop_par_fit) # no lack of fit found by the test
#> Likelihood ratio test +#> +#> Model 1: ANOVA with error model const +#> Model 2: m_synth_DFOP_par with error model const and fixed parameter(s) M1_0, M2_0 +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 28 -93.606 +#> 2 9 -102.763 -19 18.313 0.5016
# +# The anova model used for comparison in the case of transformation products +test_data_anova_2 <- dfop_par_fit$data +test_data_anova_2$variable <- as.factor(test_data_anova_2$variable) +test_data_anova_2$time <- as.factor(test_data_anova_2$time) +anova_fit_2 <- lm(observed ~ time:variable - 1, data = test_data_anova_2) +summary(anova_fit_2)
#> +#> Call: +#> lm(formula = observed ~ time:variable - 1, data = test_data_anova_2) +#> +#> Residuals: +#> Min 1Q Median 3Q Max +#> -6.1000 -0.5875 0.0000 0.5875 6.1000 +#> +#> Coefficients: (2 not defined because of singularities) +#> Estimate Std. Error t value Pr(>|t|) +#> time0:variableparent 103.150 1.573 65.562 < 2e-16 *** +#> time1:variableparent 83.200 1.573 52.882 < 2e-16 *** +#> time3:variableparent 52.350 1.573 33.274 < 2e-16 *** +#> time7:variableparent 34.650 1.573 22.024 < 2e-16 *** +#> time14:variableparent 23.400 1.573 14.873 6.35e-14 *** +#> time28:variableparent 17.150 1.573 10.901 5.47e-11 *** +#> time60:variableparent 8.250 1.573 5.244 1.99e-05 *** +#> time90:variableparent 4.650 1.573 2.956 0.006717 ** +#> time120:variableparent 2.700 1.573 1.716 0.098507 . +#> time0:variableM1 NA NA NA NA +#> time1:variableM1 11.850 1.573 7.532 6.93e-08 *** +#> time3:variableM1 22.700 1.573 14.428 1.26e-13 *** +#> time7:variableM1 33.050 1.573 21.007 < 2e-16 *** +#> time14:variableM1 31.250 1.573 19.863 < 2e-16 *** +#> time28:variableM1 18.900 1.573 12.013 7.02e-12 *** +#> time60:variableM1 7.550 1.573 4.799 6.28e-05 *** +#> time90:variableM1 3.850 1.573 2.447 0.021772 * +#> time120:variableM1 2.050 1.573 1.303 0.204454 +#> time0:variableM2 NA NA NA NA +#> time1:variableM2 6.700 1.573 4.259 0.000254 *** +#> time3:variableM2 16.750 1.573 10.646 8.93e-11 *** +#> time7:variableM2 25.800 1.573 16.399 6.89e-15 *** +#> time14:variableM2 28.600 1.573 18.178 6.35e-16 *** +#> time28:variableM2 25.400 1.573 16.144 9.85e-15 *** +#> time60:variableM2 21.600 1.573 13.729 3.81e-13 *** +#> time90:variableM2 17.800 1.573 11.314 2.51e-11 *** +#> time120:variableM2 14.100 1.573 8.962 2.79e-09 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 +#> +#> Residual standard error: 2.225 on 25 degrees of freedom +#> Multiple R-squared: 0.9979, Adjusted R-squared: 0.9957 +#> F-statistic: 469.2 on 25 and 25 DF, p-value: < 2.2e-16 +#>
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/logLik.mkinfit.html b/docs/dev/reference/logLik.mkinfit.html new file mode 100644 index 00000000..840a4821 --- /dev/null +++ b/docs/dev/reference/logLik.mkinfit.html @@ -0,0 +1,229 @@ + + + + + + + + +Calculated the log-likelihood of a fitted mkinfit object — logLik.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function returns the product of the likelihood densities of each +observed value, as calculated as part of the fitting procedure using +dnorm, i.e. assuming normal distribution, and with the means +predicted by the degradation model, and the standard deviations predicted by +the error model.

+
+ +
# S3 method for mkinfit
+logLik(object, ...)
+ +

Arguments

+ + + + + + + + + + +
object

An object of class mkinfit.

...

For compatibility with the generic method

+ +

Value

+ +

An object of class logLik with the number of estimated +parameters (degradation model parameters plus variance model parameters) +as attribute.

+

Details

+ +

The total number of estimated parameters returned with the value of the +likelihood is calculated as the sum of fitted degradation model parameters +and the fitted error model parameters.

+

See also

+ +

Compare the AIC of columns of mmkin objects using +AIC.mmkin.

+ +

Examples

+
+ # \dontrun{ + sfo_sfo <- mkinmod( + parent = mkinsub("SFO", to = "m1"), + m1 = mkinsub("SFO") + )
#> Successfully compiled differential equation model from auto-generated C code.
d_t <- FOCUS_2006_D + f_nw <- mkinfit(sfo_sfo, d_t, quiet = TRUE) # no weighting (weights are unity)
#> Warning: Observations with value of zero were removed from the data
f_obs <- mkinfit(sfo_sfo, d_t, error_model = "obs", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
f_tc <- mkinfit(sfo_sfo, d_t, error_model = "tc", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
AIC(f_nw, f_obs, f_tc)
#> df AIC +#> f_nw 5 204.4486 +#> f_obs 6 205.8727 +#> f_tc 6 141.9656
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/logistic.solution-1.png b/docs/dev/reference/logistic.solution-1.png new file mode 100644 index 00000000..fd11d0c0 Binary files /dev/null and b/docs/dev/reference/logistic.solution-1.png differ diff --git a/docs/dev/reference/logistic.solution-2.png b/docs/dev/reference/logistic.solution-2.png new file mode 100644 index 00000000..78a31f93 Binary files /dev/null and b/docs/dev/reference/logistic.solution-2.png differ diff --git a/docs/dev/reference/logistic.solution.html b/docs/dev/reference/logistic.solution.html new file mode 100644 index 00000000..4804fc73 --- /dev/null +++ b/docs/dev/reference/logistic.solution.html @@ -0,0 +1,275 @@ + + + + + + + + +Logistic kinetics — logistic.solution • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing exponential decline from a defined starting value, with +an increasing rate constant, supposedly caused by microbial growth

+
+ +
logistic.solution(t, parent_0, kmax, k0, r)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
t

Time.

parent_0

Starting value for the response variable at time zero.

kmax

Maximum rate constant.

k0

Minimum rate constant effective at time zero.

r

Growth rate of the increase in the rate constant.

+ +

Value

+ +

The value of the response variable at time t.

+

Note

+ +

The solution of the logistic model reduces to the +SFO.solution if k0 is equal to kmax.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics +FOCUS (2014) “Generic guidance for Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +Version 1.1, 18 December 2014 +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

See also

+ +

Other parent solutions: +DFOP.solution(), +FOMC.solution(), +HS.solution(), +IORE.solution(), +SFO.solution(), +SFORB.solution()

+ +

Examples

+
+ # Reproduce the plot on page 57 of FOCUS (2014) + plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.2), + from = 0, to = 100, ylim = c(0, 100), + xlab = "Time", ylab = "Residue")
plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.4), + from = 0, to = 100, add = TRUE, lty = 2, col = 2)
plot(function(x) logistic.solution(x, 100, 0.08, 0.0001, 0.8), + from = 0, to = 100, add = TRUE, lty = 3, col = 3)
plot(function(x) logistic.solution(x, 100, 0.08, 0.001, 0.2), + from = 0, to = 100, add = TRUE, lty = 4, col = 4)
plot(function(x) logistic.solution(x, 100, 0.08, 0.08, 0.2), + from = 0, to = 100, add = TRUE, lty = 5, col = 5)
legend("topright", inset = 0.05, + legend = paste0("k0 = ", c(0.0001, 0.0001, 0.0001, 0.001, 0.08), + ", r = ", c(0.2, 0.4, 0.8, 0.2, 0.2)), + lty = 1:5, col = 1:5)
+ # Fit with synthetic data + logistic <- mkinmod(parent = mkinsub("logistic")) + + sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) + parms_logistic <- c(kmax = 0.08, k0 = 0.0001, r = 0.2) + d_logistic <- mkinpredict(logistic, + parms_logistic, c(parent = 100), + sampling_times) + d_2_1 <- add_err(d_logistic, + sdfunc = function(x) sigma_twocomp(x, 0.5, 0.07), + n = 1, reps = 2, digits = 5, LOD = 0.1, seed = 123456)[[1]] + + m <- mkinfit("logistic", d_2_1, quiet = TRUE) + plot_sep(m)
summary(m)$bpar
#> Estimate se_notrans t value Pr(>t) Lower +#> parent_0 1.057896e+02 1.9023449649 55.610120 3.768361e-16 1.016451e+02 +#> kmax 6.398190e-02 0.0143201029 4.467978 3.841828e-04 3.929235e-02 +#> k0 1.612775e-04 0.0005866813 0.274898 3.940351e-01 5.846685e-08 +#> r 2.263946e-01 0.1718110773 1.317695 1.061044e-01 4.335843e-02 +#> sigma 5.332935e+00 0.9145907310 5.830952 4.036926e-05 3.340213e+00 +#> Upper +#> parent_0 109.9341588 +#> kmax 0.1041853 +#> k0 0.4448750 +#> r 1.1821121 +#> sigma 7.3256566
endpoints(m)$distimes
#> DT50 DT90 DT50_k0 DT50_kmax +#> parent 36.86533 62.41511 4297.854 10.83349
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/lrtest.mkinfit.html b/docs/dev/reference/lrtest.mkinfit.html new file mode 100644 index 00000000..712cfcfb --- /dev/null +++ b/docs/dev/reference/lrtest.mkinfit.html @@ -0,0 +1,265 @@ + + + + + + + + +Likelihood ratio test for mkinfit models — lrtest.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Compare two mkinfit models based on their likelihood. If two fitted +mkinfit objects are given as arguments, it is checked if they have been +fitted to the same data. It is the responsibility of the user to make sure +that the models are nested, i.e. one of them has less degrees of freedom +and can be expressed by fixing the parameters of the other.

+
+ +
# S3 method for mkinfit
+lrtest(object, object_2 = NULL, ...)
+
+# S3 method for mmkin
+lrtest(object, ...)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

An mkinfit object, or an mmkin column +object containing two fits to the same data.

object_2

Optionally, another mkinfit object fitted to the same data.

...

Argument to mkinfit, passed to +update.mkinfit for creating the alternative fitted object.

+ +

Details

+ +

Alternatively, an argument to mkinfit can be given which is then passed +to update.mkinfit to obtain the alternative model.

+

The comparison is then made by the lrtest.default +method from the lmtest package. The model with the higher number of fitted +parameters (alternative hypothesis) is listed first, then the model with the +lower number of fitted parameters (null hypothesis).

+ +

Examples

+
# \dontrun{ +test_data <- subset(synthetic_data_for_UBA_2014[[12]]$data, name == "parent") +sfo_fit <- mkinfit("SFO", test_data, quiet = TRUE) +dfop_fit <- mkinfit("DFOP", test_data, quiet = TRUE) +lrtest(dfop_fit, sfo_fit)
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: SFO with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 3 -63.954 -2 43.002 4.594e-10 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lrtest(sfo_fit, dfop_fit)
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: SFO with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 3 -63.954 -2 43.002 4.594e-10 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
+# The following two examples are commented out as they fail during +# generation of the static help pages by pkgdown +#lrtest(dfop_fit, error_model = "tc") +#lrtest(dfop_fit, fixed_parms = c(k2 = 0)) + +# However, this equivalent syntax also works for static help pages +lrtest(dfop_fit, update(dfop_fit, error_model = "tc"))
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model tc +#> Model 2: DFOP with error model const +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 6 -34.587 +#> 2 5 -42.453 -1 15.731 7.302e-05 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
lrtest(dfop_fit, update(dfop_fit, fixed_parms = c(k2 = 0)))
#> Likelihood ratio test +#> +#> Model 1: DFOP with error model const +#> Model 2: DFOP with error model const and fixed parameter(s) k2 +#> #Df LogLik Df Chisq Pr(>Chisq) +#> 1 5 -42.453 +#> 2 4 -57.340 -1 29.776 4.851e-08 *** +#> --- +#> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/max_twa_parent.html b/docs/dev/reference/max_twa_parent.html new file mode 100644 index 00000000..77166d00 --- /dev/null +++ b/docs/dev/reference/max_twa_parent.html @@ -0,0 +1,270 @@ + + + + + + + + +Function to calculate maximum time weighted average concentrations from +kinetic models fitted with mkinfit — max_twa_parent • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

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

+
+ +
max_twa_parent(fit, windows)
+
+max_twa_sfo(M0 = 1, k, t)
+
+max_twa_fomc(M0 = 1, alpha, beta, t)
+
+max_twa_dfop(M0 = 1, k1, k2, g, t)
+
+max_twa_hs(M0 = 1, k1, k2, tb, t)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
fit

An object of class mkinfit.

windows

The width of the time windows for which the TWAs should be +calculated.

M0

The initial concentration for which the maximum time weighted +average over the decline curve should be calculated. The default is to use +a value of 1, which means that a relative maximum time weighted average +factor (f_twa) is calculated.

k

The rate constant in the case of SFO kinetics.

t

The width of the time window.

alpha

Parameter of the FOMC model.

beta

Parameter of the FOMC model.

k1

The first rate constant of the DFOP or the HS kinetics.

k2

The second rate constant of the DFOP or the HS kinetics.

g

Parameter of the DFOP model.

tb

Parameter of the HS model.

+ +

Value

+ +

For max_twa_parent, a numeric vector, named using the +windows argument. For the other functions, a numeric vector of +length one (also known as 'a number').

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
+ fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) + max_twa_parent(fit, c(7, 21))
#> 7 21 +#> 34.71343 18.22124
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mccall81_245T.html b/docs/dev/reference/mccall81_245T.html new file mode 100644 index 00000000..dc0dfbf8 --- /dev/null +++ b/docs/dev/reference/mccall81_245T.html @@ -0,0 +1,245 @@ + + + + + + + + +Datasets on aerobic soil metabolism of 2,4,5-T in six soils — mccall81_245T • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Time course of 2,4,5-trichlorophenoxyacetic acid, and the corresponding + 2,4,5-trichlorophenol and 2,4,5-trichloroanisole as recovered in diethylether + extracts.

+
+ +
mccall81_245T
+ + +

Format

+ +

A dataframe containing the following variables.

+
name

the name of the compound observed. Note that T245 is used as + an acronym for 2,4,5-T. T245 is a legitimate object name + in R, which is necessary for specifying models using + mkinmod.

+
time

a numeric vector containing sampling times in days after + treatment

+
value

a numeric vector containing concentrations in percent of applied radioactivity

+
soil

a factor containing the name of the soil

+ + + +

Source

+ +

McCall P, Vrona SA, Kelley SS (1981) Fate of uniformly carbon-14 ring labelled 2,4,5-Trichlorophenoxyacetic acid and 2,4-dichlorophenoxyacetic acid. J Agric Chem 29, 100-107 + http://dx.doi.org/10.1021/jf00103a026

+ +

Examples

+
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.
# \dontrun{ + fit.1 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(fit.1)$bpar
#> Estimate se_notrans t value Pr(>t) +#> T245_0 1.038550e+02 2.184707509 47.537272 4.472189e-18 +#> k_T245 4.337042e-02 0.001898397 22.845818 2.276912e-13 +#> k_phenol 4.050581e-01 0.298699410 1.356073 9.756993e-02 +#> k_anisole 6.678742e-03 0.000802144 8.326114 2.623179e-07 +#> f_T245_to_phenol 6.227599e-01 0.398534147 1.562626 6.949418e-02 +#> f_phenol_to_anisole 1.000000e+00 0.671844135 1.488440 7.867793e-02 +#> sigma 2.514628e+00 0.490755933 5.123989 6.233163e-05 +#> Lower Upper +#> T245_0 99.246061427 1.084640e+02 +#> k_T245 0.039631621 4.746194e-02 +#> k_phenol 0.218013878 7.525762e-01 +#> k_anisole 0.005370739 8.305299e-03 +#> f_T245_to_phenol 0.547559082 6.924813e-01 +#> f_phenol_to_anisole 0.000000000 1.000000e+00 +#> sigma 1.706607296 3.322649e+00
endpoints(fit.1)
#> $ff +#> T245_phenol T245_sink phenol_anisole phenol_sink +#> 6.227599e-01 3.772401e-01 1.000000e+00 1.005127e-10 +#> +#> $distimes +#> DT50 DT90 +#> T245 15.982025 53.09114 +#> phenol 1.711229 5.68458 +#> anisole 103.784092 344.76329 +#>
# k_phenol_sink is really small, therefore fix it to zero + fit.2 <- mkinfit(SFO_SFO_SFO, subset(mccall81_245T, soil == "Commerce"), + parms.ini = c(k_phenol_sink = 0), + fixed_parms = "k_phenol_sink", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
#> Warning: Initial parameter(s) k_phenol_sink not used in the model
#> Error in data.frame(value = c(state.ini.fixed, parms.fixed)): row names contain missing values
summary(fit.2)$bpar
#> Error in summary(fit.2): object 'fit.2' not found
endpoints(fit.1)
#> $ff +#> T245_phenol T245_sink phenol_anisole phenol_sink +#> 6.227599e-01 3.772401e-01 1.000000e+00 1.005127e-10 +#> +#> $distimes +#> DT50 DT90 +#> T245 15.982025 53.09114 +#> phenol 1.711229 5.68458 +#> anisole 103.784092 344.76329 +#>
plot_sep(fit.2)
#> Error in identical(fit$err_mod, "const"): object 'fit.2' not found
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkin_long_to_wide.html b/docs/dev/reference/mkin_long_to_wide.html new file mode 100644 index 00000000..143eb12a --- /dev/null +++ b/docs/dev/reference/mkin_long_to_wide.html @@ -0,0 +1,233 @@ + + + + + + + + +Convert a dataframe from long to wide format — mkin_long_to_wide • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function takes a dataframe in the long form, i.e. with a row for each +observed value, and converts it into a dataframe with one independent +variable and several dependent variables as columns.

+
+ +
mkin_long_to_wide(long_data, time = "time", outtime = "time")
+ +

Arguments

+ + + + + + + + + + + + + + +
long_data

The dataframe must contain one variable called "time" with +the time values specified by the time argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".

time

The name of the time variable in the long input data.

outtime

The name of the time variable in the wide output data.

+ +

Value

+ +

Dataframe in wide format.

+ +

Examples

+
+mkin_long_to_wide(FOCUS_2006_D)
#> time parent m1 +#> 1 0 99.46 0.00 +#> 2 0 102.04 0.00 +#> 3 1 93.50 4.84 +#> 4 1 92.50 5.64 +#> 5 3 63.23 12.91 +#> 6 3 68.99 12.96 +#> 7 7 52.32 22.97 +#> 8 7 55.13 24.47 +#> 9 14 27.27 41.69 +#> 10 14 26.64 33.21 +#> 11 21 11.50 44.37 +#> 12 21 11.64 46.44 +#> 13 35 2.85 41.22 +#> 14 35 2.91 37.95 +#> 15 50 0.69 41.19 +#> 16 50 0.63 40.01 +#> 17 75 0.05 40.09 +#> 18 75 0.06 33.85 +#> 19 100 NA 31.04 +#> 20 100 NA 33.13 +#> 21 120 NA 25.15 +#> 22 120 NA 33.31
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkin_wide_to_long.html b/docs/dev/reference/mkin_wide_to_long.html new file mode 100644 index 00000000..14419558 --- /dev/null +++ b/docs/dev/reference/mkin_wide_to_long.html @@ -0,0 +1,213 @@ + + + + + + + + +Convert a dataframe with observations over time into long format — mkin_wide_to_long • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function simply takes a dataframe with one independent variable and +several dependent variable and converts it into the long form as required by +mkinfit.

+
+ +
mkin_wide_to_long(wide_data, time = "t")
+ +

Arguments

+ + + + + + + + + + +
wide_data

The dataframe must contain one variable with the time +values specified by the time argument and usually more than one +column of observed values.

time

The name of the time variable.

+ +

Value

+ +

Dataframe in long format as needed for mkinfit.

+ +

Examples

+
+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 +#> 2 x 2 4 +#> 3 x 3 7 +#> 4 y 1 3 +#> 5 y 2 4 +#> 6 y 3 5
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinds.html b/docs/dev/reference/mkinds.html new file mode 100644 index 00000000..5c7d9490 --- /dev/null +++ b/docs/dev/reference/mkinds.html @@ -0,0 +1,253 @@ + + + + + + + + +A dataset class for mkin — mkinds • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

At the moment this dataset class is hardly used in mkin. For example, +mkinfit does not take mkinds datasets as argument, but works with dataframes +such as the on contained in the data field of mkinds objects. Some datasets +provided by this package come as mkinds objects nevertheless.

+
+ + + +

See also

+ +

The S3 printing method print.mkinds

+

Public fields

+ +

+
title

A full title for the dataset

+ +
sampling_times

The sampling times

+ +
time_unit

The time unit

+ +
observed

Names of the observed variables

+ +
unit

The unit of the observations

+ +
replicates

The maximum number of replicates per sampling time

+ +
data

A data frame with at least the columns name, time +and value in order to be compatible with mkinfit

+ +

+

Methods

+ + +

Public methods

+ + +


+

Method new()

+

Create a new mkinds object

Usage

+

mkinds$new(title = "", data, time_unit = NA, unit = NA)

+ +

Arguments

+

+
title

The dataset title

+ +
data

The data

+ +
time_unit

The time unit

+ +
unit

The unit of the observations

+ +

+


+

Method clone()

+

The objects of this class are cloneable with this method.

Usage

+

mkinds$clone(deep = FALSE)

+ +

Arguments

+

+
deep

Whether to make a deep clone.

+ +

+ + + +

Examples

+
+mds <- mkinds$new("FOCUS A", FOCUS_2006_A) +print(mds)
#> <mkinds> with $title: FOCUS A +#> Observed compounds $observed: parent +#> Sampling times $sampling_times: 0, 3, 7, 14, 30, 62, 90, 118 +#> With a maximum of 1 replicates
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinerrmin.html b/docs/dev/reference/mkinerrmin.html new file mode 100644 index 00000000..9f58dfaa --- /dev/null +++ b/docs/dev/reference/mkinerrmin.html @@ -0,0 +1,233 @@ + + + + + + + + +Calculate the minimum error to assume in order to pass the variance test — mkinerrmin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function finds the smallest relative error still resulting in passing +the chi-squared test as defined in the FOCUS kinetics report from 2006.

+
+ +
mkinerrmin(fit, alpha = 0.05)
+ +

Arguments

+ + + + + + + + + + +
fit

an object of class mkinfit.

alpha

The confidence level chosen for the chi-squared test.

+ +

Value

+ +

A dataframe with the following components:

+
err.min

The +relative error, expressed as a fraction.

n.optim

The number of +optimised parameters attributed to the data series.

df

The number of +remaining degrees of freedom for the chi2 error level calculations. Note +that mean values are used for the chi2 statistic and therefore every time +point with observed values in the series only counts one time.

The +dataframe has one row for the total dataset and one further row for each +observed state variable in the model. + +

Details

+ +

This function is used internally by summary.mkinfit.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in EU +Registration” Report of the FOCUS Work Group on Degradation Kinetics, EC +Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
+SFO_SFO = mkinmod(parent = mkinsub("SFO", to = "m1"), + m1 = mkinsub("SFO"), + use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+fit_FOCUS_D = mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
round(mkinerrmin(fit_FOCUS_D), 4)
#> err.min n.optim df +#> All data 0.0640 4 15 +#> parent 0.0646 2 7 +#> m1 0.0469 2 8
# \dontrun{ + fit_FOCUS_E = mkinfit(SFO_SFO, FOCUS_2006_E, quiet = TRUE) + round(mkinerrmin(fit_FOCUS_E), 4)
#> err.min n.optim df +#> All data 0.1544 4 13 +#> parent 0.1659 2 7 +#> m1 0.1095 2 6
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinerrplot-1.png b/docs/dev/reference/mkinerrplot-1.png new file mode 100644 index 00000000..c5d3495f Binary files /dev/null and b/docs/dev/reference/mkinerrplot-1.png differ diff --git a/docs/dev/reference/mkinerrplot.html b/docs/dev/reference/mkinerrplot.html new file mode 100644 index 00000000..940a6861 --- /dev/null +++ b/docs/dev/reference/mkinerrplot.html @@ -0,0 +1,272 @@ + + + + + + + + +Function to plot squared residuals and the error model for an mkin object — mkinerrplot • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function plots the squared residuals for the specified subset of the +observed variables from an mkinfit object. In addition, one or more dashed +line(s) show the fitted error model. A combined plot of the fitted model +and this error model plot can be obtained with plot.mkinfit +using the argument show_errplot = TRUE.

+
+ +
mkinerrplot(
+  object,
+  obs_vars = names(object$mkinmod$map),
+  xlim = c(0, 1.1 * max(object$data$predicted)),
+  xlab = "Predicted",
+  ylab = "Squared residual",
+  maxy = "auto",
+  legend = TRUE,
+  lpos = "topright",
+  col_obs = "auto",
+  pch_obs = "auto",
+  frame = TRUE,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
object

A fit represented in an mkinfit object.

obs_vars

A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model

xlim

plot range in x direction.

xlab

Label for the x axis.

ylab

Label for the y axis.

maxy

Maximum value of the residuals. This is used for the scaling of +the y axis and defaults to "auto".

legend

Should a legend be plotted?

lpos

Where should the legend be placed? Default is "topright". Will +be passed on to legend.

col_obs

Colors for the observed variables.

pch_obs

Symbols to be used for the observed variables.

frame

Should a frame be drawn around the plots?

...

further arguments passed to plot.

+ +

Value

+ +

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+

See also

+ +

mkinplot, for a way to plot the data and the fitted +lines of the mkinfit object.

+ +

Examples

+
+# \dontrun{ +model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(model, FOCUS_2006_D, error_model = "tc", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
mkinerrplot(fit)
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinfit.html b/docs/dev/reference/mkinfit.html new file mode 100644 index 00000000..49e896fc --- /dev/null +++ b/docs/dev/reference/mkinfit.html @@ -0,0 +1,1054 @@ + + + + + + + + +Fit a kinetic model to data with one or more state variables — mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function maximises the likelihood of the observed data using the Port +algorithm stats::nlminb(), and the specified initial or fixed +parameters and starting values. In each step of the optimisation, the +kinetic model is solved using the function mkinpredict(), except +if an analytical solution is implemented, in which case the model is solved +using the degradation function in the mkinmod object. The +parameters of the selected error model are fitted simultaneously with the +degradation model parameters, as both of them are arguments of the +likelihood function.

+
+ +
mkinfit(
+  mkinmod,
+  observed,
+  parms.ini = "auto",
+  state.ini = "auto",
+  err.ini = "auto",
+  fixed_parms = NULL,
+  fixed_initials = names(mkinmod$diffs)[-1],
+  from_max_mean = FALSE,
+  solution_type = c("auto", "analytical", "eigen", "deSolve"),
+  method.ode = "lsoda",
+  use_compiled = "auto",
+  control = list(eval.max = 300, iter.max = 200),
+  transform_rates = TRUE,
+  transform_fractions = TRUE,
+  quiet = FALSE,
+  atol = 1e-08,
+  rtol = 1e-10,
+  error_model = c("const", "obs", "tc"),
+  error_model_algorithm = c("auto", "d_3", "direct", "twostep", "threestep",
+    "fourstep", "IRLS", "OLS"),
+  reweight.tol = 1e-08,
+  reweight.max.iter = 10,
+  trace_parms = FALSE,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
mkinmod

A list of class mkinmod, containing the kinetic +model to be fitted to the data, or one of the shorthand names ("SFO", +"FOMC", "DFOP", "HS", "SFORB", "IORE"). If a shorthand name is given, a +parent only degradation model is generated for the variable with the +highest value in observed.

observed

A dataframe with the observed data. The first column called +"name" must contain the name of the observed variable for each data point. +The second column must contain the times of observation, named "time". +The third column must be named "value" and contain the observed values. +Zero values in the "value" column will be removed, with a warning, in +order to avoid problems with fitting the two-component error model. This +is not expected to be a problem, because in general, values of zero are +not observed in degradation data, because there is a lower limit of +detection.

parms.ini

A named vector of initial values for the parameters, +including parameters to be optimised and potentially also fixed parameters +as indicated by fixed_parms. If set to "auto", initial values for +rate constants are set to default values. Using parameter names that are +not in the model gives an error.

+

It is possible to only specify a subset of the parameters that the model +needs. You can use the parameter lists "bparms.ode" from a previously +fitted model, which contains the differential equation parameters from +this model. This works nicely if the models are nested. An example is +given below.

state.ini

A named vector of initial values for the state variables of +the model. In case the observed variables are represented by more than one +model variable, the names will differ from the names of the observed +variables (see map component of mkinmod). The default +is to set the initial value of the first model variable to the mean of the +time zero values for the variable with the maximum observed value, and all +others to 0. If this variable has no time zero observations, its initial +value is set to 100.

err.ini

A named vector of initial values for the error model +parameters to be optimised. If set to "auto", initial values are set to +default values. Otherwise, inital values for all error model parameters +must be given.

fixed_parms

The names of parameters that should not be optimised but +rather kept at the values specified in parms.ini. Alternatively, +a named numeric vector of parameters to be fixed, regardless of the values +in parms.ini.

fixed_initials

The names of model variables for which the initial +state at time 0 should be excluded from the optimisation. Defaults to all +state variables except for the first one.

from_max_mean

If this is set to TRUE, and the model has only one +observed variable, then data before the time of the maximum observed value +(after averaging for each sampling time) are discarded, and this time is +subtracted from all remaining time values, so the time of the maximum +observed mean value is the new time zero.

solution_type

If set to "eigen", the solution of the system of +differential equations is based on the spectral decomposition of the +coefficient matrix in cases that this is possible. If set to "deSolve", a +numerical ode solver from package deSolve is used. If +set to "analytical", an analytical solution of the model is used. This is +only implemented for relatively simple degradation models. The default is +"auto", which uses "analytical" if possible, otherwise "deSolve" if a +compiler is present, and "eigen" if no compiler is present and the model +can be expressed using eigenvalues and eigenvectors.

method.ode

The solution method passed via mkinpredict() +to deSolve::ode() in case the solution type is "deSolve". The default +"lsoda" is performant, but sometimes fails to converge.

use_compiled

If set to FALSE, no compiled version of the +mkinmod model is used in the calls to mkinpredict() even if a compiled +version is present.

control

A list of control arguments passed to stats::nlminb().

transform_rates

Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model. If FALSE, zero is used as +a lower bound for the rates in the optimisation.

transform_fractions

Boolean specifying if formation fractions +constants should be transformed in the model specification used in the +fitting for better compliance with the assumption of normal distribution +of the estimator. The default (TRUE) is 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 ilr() transformation.

quiet

Suppress printing out the current value of the negative +log-likelihood after each improvement?

atol

Absolute error tolerance, passed to deSolve::ode(). Default +is 1e-8, which is lower than the default in the deSolve::lsoda() +function which is used per default.

rtol

Absolute error tolerance, passed to deSolve::ode(). Default +is 1e-10, much lower than in deSolve::lsoda().

error_model

If the error model is "const", a constant standard +deviation is assumed.

+

If the error model is "obs", each observed variable is assumed to have its +own variance.

+

If the error model is "tc" (two-component error model), a two component +error model similar to the one described by Rocke and Lorenzato (1995) is +used for setting up the likelihood function. Note that this model +deviates from the model by Rocke and Lorenzato, as their model implies +that the errors follow a lognormal distribution for large values, not a +normal distribution as assumed by this method.

error_model_algorithm

If "auto", the selected algorithm depends on +the error model. If the error model is "const", unweighted nonlinear +least squares fitting ("OLS") is selected. If the error model is "obs", or +"tc", the "d_3" algorithm is selected.

+

The algorithm "d_3" will directly minimize the negative log-likelihood +and independently also use the three step algorithm described below. +The fit with the higher likelihood is returned.

+

The algorithm "direct" will directly minimize the negative log-likelihood.

+

The algorithm "twostep" will minimize the negative log-likelihood after an +initial unweighted least squares optimisation step.

+

The algorithm "threestep" starts with unweighted least squares, then +optimizes only the error model using the degradation model parameters +found, and then minimizes the negative log-likelihood with free +degradation and error model parameters.

+

The algorithm "fourstep" starts with unweighted least squares, then +optimizes only the error model using the degradation model parameters +found, then optimizes the degradation model again with fixed error model +parameters, and finally minimizes the negative log-likelihood with free +degradation and error model parameters.

+

The algorithm "IRLS" (Iteratively Reweighted Least Squares) starts with +unweighted least squares, and then iterates optimization of the error +model parameters and subsequent optimization of the degradation model +using those error model parameters, until the error model parameters +converge.

reweight.tol

Tolerance for the convergence criterion calculated from +the error model parameters in IRLS fits.

reweight.max.iter

Maximum number of iterations in IRLS fits.

trace_parms

Should a trace of the parameter values be listed?

...

Further arguments that will be passed on to +deSolve::ode().

+ +

Value

+ +

A list with "mkinfit" in the class attribute.

+

Details

+ +

Per default, parameters in the kinetic models are internally transformed in +order to better satisfy the assumption of a normal distribution of their +estimators.

+

Note

+ +

When using the "IORE" submodel for metabolites, fitting with +"transform_rates = TRUE" (the default) often leads to failures of the +numerical ODE solver. In this situation it may help to switch off the +internal rate transformation.

+

References

+ +

Rocke DM and Lorenzato S (1995) A two-component model +for measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+

Ranke J and Meinecke S (2019) Error Models for the Kinetic Evaluation of Chemical +Degradation Data. Environments 6(12) 124 +doi:10.3390/environments6120124.

+

See also

+ +

summary.mkinfit, plot.mkinfit, parms and lrtest.

+

Comparisons of models fitted to the same data can be made using +AIC by virtue of the method logLik.mkinfit.

+

Fitting of several models to several datasets in a single call to +mmkin.

+ +

Examples

+
+# Use shorthand notation for parent only degradation +fit <- mkinfit("FOMC", FOCUS_2006_C, quiet = TRUE) +summary(fit)
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 05:54:13 2020 +#> Date of summary: Wed May 27 05:54:13 2020 +#> +#> Equations: +#> d_parent/dt = - (alpha/beta) * 1/((time/beta) + 1) * parent +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 222 model solutions performed in 0.043 s +#> +#> Error model: Constant variance +#> +#> Error model algorithm: OLS +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 85.1 state +#> alpha 1.0 deparm +#> beta 10.0 deparm +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 85.100000 -Inf Inf +#> log_alpha 0.000000 -Inf Inf +#> log_beta 2.302585 -Inf Inf +#> +#> Fixed parameter values: +#> None +#> +#> Results: +#> +#> AIC BIC logLik +#> 44.68652 45.47542 -18.34326 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 85.87000 1.8070 81.23000 90.5200 +#> log_alpha 0.05192 0.1353 -0.29580 0.3996 +#> log_beta 0.65100 0.2287 0.06315 1.2390 +#> sigma 1.85700 0.4378 0.73200 2.9830 +#> +#> Parameter correlation: +#> parent_0 log_alpha log_beta sigma +#> parent_0 1.000e+00 -1.565e-01 -3.142e-01 4.770e-08 +#> log_alpha -1.565e-01 1.000e+00 9.564e-01 9.974e-08 +#> log_beta -3.142e-01 9.564e-01 1.000e+00 8.468e-08 +#> sigma 4.770e-08 9.974e-08 8.468e-08 1.000e+00 +#> +#> 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 85.870 47.530 3.893e-08 81.2300 90.520 +#> alpha 1.053 7.393 3.562e-04 0.7439 1.491 +#> beta 1.917 4.373 3.601e-03 1.0650 3.451 +#> sigma 1.857 4.243 4.074e-03 0.7320 2.983 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 6.657 3 6 +#> parent 6.657 3 6 +#> +#> Estimated disappearance times: +#> DT50 DT90 DT50back +#> parent 1.785 15.15 4.56 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 85.1 85.875 -0.7749 +#> 1 parent 57.9 55.191 2.7091 +#> 3 parent 29.9 31.845 -1.9452 +#> 7 parent 14.6 17.012 -2.4124 +#> 14 parent 9.7 9.241 0.4590 +#> 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
+# 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)))
#> Warning: Observations with value of zero were removed from the data
#> user system elapsed +#> 0.414 0.000 0.418
parms(fit)
#> parent_0 k_parent k_m1 f_parent_to_m1 sigma +#> 99.598481046 0.098697740 0.005260651 0.514475962 3.125503875
#> $ff +#> parent_m1 parent_sink +#> 0.514476 0.485524 +#> +#> $distimes +#> DT50 DT90 +#> parent 7.022929 23.32966 +#> m1 131.760724 437.69965 +#>
# \dontrun{ +# deSolve is slower when no C compiler (gcc) was available during model generation +print(system.time(fit.deSolve <- mkinfit(SFO_SFO, FOCUS_2006_D, + solution_type = "deSolve")))
#> Warning: Observations with value of zero were removed from the data
#> Ordinary least squares optimisation
#> Sum of squared residuals at call 1: 15156.12 +#> Sum of squared residuals at call 2: 15156.12 +#> Sum of squared residuals at call 6: 8243.645 +#> Sum of squared residuals at call 12: 6290.712 +#> Sum of squared residuals at call 13: 6290.683 +#> Sum of squared residuals at call 15: 6290.452 +#> Sum of squared residuals at call 18: 1700.749 +#> Sum of squared residuals at call 20: 1700.611 +#> Sum of squared residuals at call 24: 1190.923 +#> Sum of squared residuals at call 26: 1190.922 +#> Sum of squared residuals at call 29: 1017.417 +#> Sum of squared residuals at call 31: 1017.417 +#> Sum of squared residuals at call 33: 1017.416 +#> Sum of squared residuals at call 34: 644.0472 +#> Sum of squared residuals at call 36: 644.047 +#> Sum of squared residuals at call 38: 644.047 +#> Sum of squared residuals at call 39: 590.5025 +#> Sum of squared residuals at call 41: 590.5022 +#> Sum of squared residuals at call 43: 590.5016 +#> Sum of squared residuals at call 44: 543.2196 +#> Sum of squared residuals at call 45: 543.2193 +#> Sum of squared residuals at call 46: 543.2192 +#> Sum of squared residuals at call 50: 391.348 +#> Sum of squared residuals at call 51: 391.3479 +#> Sum of squared residuals at call 56: 386.479 +#> Sum of squared residuals at call 58: 386.479 +#> Sum of squared residuals at call 60: 386.4779 +#> Sum of squared residuals at call 61: 384.0686 +#> Sum of squared residuals at call 63: 384.0686 +#> Sum of squared residuals at call 66: 382.7813 +#> Sum of squared residuals at call 68: 382.7813 +#> Sum of squared residuals at call 70: 382.7813 +#> Sum of squared residuals at call 71: 378.9273 +#> Sum of squared residuals at call 73: 378.9273 +#> Sum of squared residuals at call 75: 378.9272 +#> Sum of squared residuals at call 76: 377.4847 +#> Sum of squared residuals at call 78: 377.4846 +#> Sum of squared residuals at call 81: 375.9738 +#> Sum of squared residuals at call 83: 375.9738 +#> Sum of squared residuals at call 86: 375.3387 +#> Sum of squared residuals at call 88: 375.3387 +#> Sum of squared residuals at call 91: 374.5774 +#> Sum of squared residuals at call 93: 374.5774 +#> Sum of squared residuals at call 95: 374.5774 +#> Sum of squared residuals at call 96: 373.5438 +#> Sum of squared residuals at call 100: 373.5438 +#> Sum of squared residuals at call 102: 373.265 +#> Sum of squared residuals at call 104: 373.265 +#> Sum of squared residuals at call 107: 372.6825 +#> Sum of squared residuals at call 111: 372.6825 +#> Sum of squared residuals at call 114: 372.6356 +#> Sum of squared residuals at call 116: 372.6356 +#> Sum of squared residuals at call 119: 372.6199 +#> Sum of squared residuals at call 121: 372.6199 +#> Sum of squared residuals at call 123: 372.6199 +#> Sum of squared residuals at call 124: 372.5881 +#> Sum of squared residuals at call 126: 372.5881 +#> Sum of squared residuals at call 129: 372.5418 +#> Sum of squared residuals at call 130: 372.4866 +#> Sum of squared residuals at call 131: 372.2242 +#> Sum of squared residuals at call 132: 371.5237 +#> Sum of squared residuals at call 134: 371.5237 +#> Sum of squared residuals at call 137: 371.292 +#> Sum of squared residuals at call 139: 371.292 +#> Sum of squared residuals at call 143: 371.2256 +#> Sum of squared residuals at call 144: 371.2256 +#> Sum of squared residuals at call 146: 371.2256 +#> Sum of squared residuals at call 149: 371.2194 +#> Sum of squared residuals at call 150: 371.2147 +#> Sum of squared residuals at call 153: 371.2147 +#> Sum of squared residuals at call 155: 371.2137 +#> Sum of squared residuals at call 156: 371.2137 +#> Sum of squared residuals at call 157: 371.2137 +#> Sum of squared residuals at call 160: 371.2134 +#> Sum of squared residuals at call 164: 371.2134 +#> Sum of squared residuals at call 165: 371.2134 +#> Sum of squared residuals at call 167: 371.2134 +#> Negative log-likelihood at call 177: 97.22429
#> Optimisation successfully terminated.
#> user system elapsed +#> 0.371 0.001 0.370
parms(fit.deSolve)
#> parent_0 k_parent k_m1 f_parent_to_m1 sigma +#> 99.598480300 0.098697739 0.005260651 0.514475968 3.125503874
endpoints(fit.deSolve)
#> $ff +#> parent_m1 parent_sink +#> 0.514476 0.485524 +#> +#> $distimes +#> DT50 DT90 +#> parent 7.022929 23.32966 +#> m1 131.760721 437.69964 +#>
# } + +# Use stepwise fitting, using optimised parameters from parent only fit, FOMC +# \dontrun{ +FOMC_SFO <- mkinmod( + parent = mkinsub("FOMC", "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 +fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
# Use starting parameters from parent only FOMC fit +fit.FOMC = mkinfit("FOMC", FOCUS_2006_D, quiet = TRUE) +fit.FOMC_SFO <- mkinfit(FOMC_SFO, FOCUS_2006_D, quiet = TRUE, + parms.ini = fit.FOMC$bparms.ode)
#> Warning: Observations with value of zero were removed from the data
+# Use stepwise fitting, using optimised parameters from parent only fit, SFORB +SFORB_SFO <- mkinmod( + parent = list(type = "SFORB", to = "m1", sink = TRUE), + m1 = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults +fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit.SFORB_SFO.deSolve <- mkinfit(SFORB_SFO, FOCUS_2006_D, solution_type = "deSolve", + quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
# Use starting parameters from parent only SFORB fit (not really needed in this case) +fit.SFORB = mkinfit("SFORB", FOCUS_2006_D, quiet = TRUE) +fit.SFORB_SFO <- mkinfit(SFORB_SFO, FOCUS_2006_D, parms.ini = fit.SFORB$bparms.ode, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
#> Warning: Initial parameter(s) k_parent_free_sink not used in the model
# } + +# \dontrun{ +# Weighted fits, including IRLS (error_model = "obs") +SFO_SFO.ff <- mkinmod(parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
f.noweight <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.noweight)
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 05:54:19 2020 +#> Date of summary: Wed May 27 05:54:19 2020 +#> +#> Equations: +#> d_parent/dt = - k_parent * parent +#> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 421 model solutions performed in 0.126 s +#> +#> Error model: Constant variance +#> +#> Error model algorithm: OLS +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 100.7500 state +#> k_parent 0.1000 deparm +#> k_m1 0.1001 deparm +#> f_parent_to_m1 0.5000 deparm +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 100.750000 -Inf Inf +#> log_k_parent -2.302585 -Inf Inf +#> log_k_m1 -2.301586 -Inf Inf +#> f_parent_ilr_1 0.000000 -Inf Inf +#> +#> Fixed parameter values: +#> value type +#> m1_0 0 state +#> +#> Results: +#> +#> AIC BIC logLik +#> 204.4486 212.6365 -97.22429 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 99.60000 1.57000 96.40000 102.8000 +#> log_k_parent -2.31600 0.04087 -2.39900 -2.2330 +#> log_k_m1 -5.24800 0.13320 -5.51800 -4.9770 +#> f_parent_ilr_1 0.04096 0.06312 -0.08746 0.1694 +#> sigma 3.12600 0.35850 2.39600 3.8550 +#> +#> Parameter correlation: +#> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 sigma +#> parent_0 1.000e+00 5.174e-01 -1.688e-01 -5.471e-01 -3.190e-07 +#> log_k_parent 5.174e-01 1.000e+00 -3.263e-01 -5.426e-01 3.168e-07 +#> log_k_m1 -1.688e-01 -3.263e-01 1.000e+00 7.478e-01 -1.406e-07 +#> f_parent_ilr_1 -5.471e-01 -5.426e-01 7.478e-01 1.000e+00 -1.587e-10 +#> sigma -3.190e-07 3.168e-07 -1.406e-07 -1.587e-10 1.000e+00 +#> +#> 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 99.600000 63.430 2.298e-36 96.400000 1.028e+02 +#> k_parent 0.098700 24.470 4.955e-23 0.090820 1.073e-01 +#> k_m1 0.005261 7.510 6.165e-09 0.004012 6.898e-03 +#> f_parent_to_m1 0.514500 23.070 3.104e-22 0.469100 5.596e-01 +#> sigma 3.126000 8.718 2.235e-10 2.396000 3.855e+00 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 6.398 4 15 +#> parent 6.459 2 7 +#> m1 4.690 2 8 +#> +#> Resulting formation fractions: +#> ff +#> parent_m1 0.5145 +#> parent_sink 0.4855 +#> +#> Estimated disappearance times: +#> DT50 DT90 +#> parent 7.023 23.33 +#> m1 131.761 437.70 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 99.46 99.59848 -1.385e-01 +#> 0 parent 102.04 99.59848 2.442e+00 +#> 1 parent 93.50 90.23787 3.262e+00 +#> 1 parent 92.50 90.23787 2.262e+00 +#> 3 parent 63.23 74.07319 -1.084e+01 +#> 3 parent 68.99 74.07319 -5.083e+00 +#> 7 parent 52.32 49.91206 2.408e+00 +#> 7 parent 55.13 49.91206 5.218e+00 +#> 14 parent 27.27 25.01257 2.257e+00 +#> 14 parent 26.64 25.01257 1.627e+00 +#> 21 parent 11.50 12.53462 -1.035e+00 +#> 21 parent 11.64 12.53462 -8.946e-01 +#> 35 parent 2.85 3.14787 -2.979e-01 +#> 35 parent 2.91 3.14787 -2.379e-01 +#> 50 parent 0.69 0.71624 -2.624e-02 +#> 50 parent 0.63 0.71624 -8.624e-02 +#> 75 parent 0.05 0.06074 -1.074e-02 +#> 75 parent 0.06 0.06074 -7.381e-04 +#> 1 m1 4.84 4.80296 3.704e-02 +#> 1 m1 5.64 4.80296 8.370e-01 +#> 3 m1 12.91 13.02400 -1.140e-01 +#> 3 m1 12.96 13.02400 -6.400e-02 +#> 7 m1 22.97 25.04476 -2.075e+00 +#> 7 m1 24.47 25.04476 -5.748e-01 +#> 14 m1 41.69 36.69002 5.000e+00 +#> 14 m1 33.21 36.69002 -3.480e+00 +#> 21 m1 44.37 41.65310 2.717e+00 +#> 21 m1 46.44 41.65310 4.787e+00 +#> 35 m1 41.22 43.31312 -2.093e+00 +#> 35 m1 37.95 43.31312 -5.363e+00 +#> 50 m1 41.19 41.21831 -2.831e-02 +#> 50 m1 40.01 41.21831 -1.208e+00 +#> 75 m1 40.09 36.44703 3.643e+00 +#> 75 m1 33.85 36.44703 -2.597e+00 +#> 100 m1 31.04 31.98163 -9.416e-01 +#> 100 m1 33.13 31.98163 1.148e+00 +#> 120 m1 25.15 28.78984 -3.640e+00 +#> 120 m1 33.31 28.78984 4.520e+00
f.obs <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "obs", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.obs)
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 05:54:19 2020 +#> Date of summary: Wed May 27 05:54:19 2020 +#> +#> Equations: +#> d_parent/dt = - k_parent * parent +#> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 978 model solutions performed in 0.33 s +#> +#> Error model: Variance unique to each observed variable +#> +#> Error model algorithm: d_3 +#> Direct fitting and three-step fitting yield approximately the same likelihood +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 100.7500 state +#> k_parent 0.1000 deparm +#> k_m1 0.1001 deparm +#> f_parent_to_m1 0.5000 deparm +#> sigma_parent 3.0000 error +#> sigma_m1 3.0000 error +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 100.750000 -Inf Inf +#> log_k_parent -2.302585 -Inf Inf +#> log_k_m1 -2.301586 -Inf Inf +#> f_parent_ilr_1 0.000000 -Inf Inf +#> sigma_parent 3.000000 0 Inf +#> sigma_m1 3.000000 0 Inf +#> +#> Fixed parameter values: +#> value type +#> m1_0 0 state +#> +#> Results: +#> +#> AIC BIC logLik +#> 205.8727 215.6982 -96.93634 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 99.65000 1.70200 96.19000 103.1000 +#> log_k_parent -2.31300 0.04376 -2.40200 -2.2240 +#> log_k_m1 -5.25000 0.12430 -5.50400 -4.9970 +#> f_parent_ilr_1 0.03861 0.06171 -0.08708 0.1643 +#> sigma_parent 3.40100 0.56820 2.24400 4.5590 +#> sigma_m1 2.85500 0.45240 1.93400 3.7770 +#> +#> Parameter correlation: +#> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 sigma_parent +#> parent_0 1.00000 0.51078 -0.19133 -0.59997 0.035670 +#> log_k_parent 0.51078 1.00000 -0.37458 -0.59239 0.069833 +#> log_k_m1 -0.19133 -0.37458 1.00000 0.74398 -0.026158 +#> f_parent_ilr_1 -0.59997 -0.59239 0.74398 1.00000 -0.041369 +#> sigma_parent 0.03567 0.06983 -0.02616 -0.04137 1.000000 +#> sigma_m1 -0.03385 -0.06627 0.02482 0.03926 -0.004628 +#> sigma_m1 +#> parent_0 -0.033847 +#> log_k_parent -0.066265 +#> log_k_m1 0.024823 +#> f_parent_ilr_1 0.039256 +#> sigma_parent -0.004628 +#> sigma_m1 1.000000 +#> +#> 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 99.650000 58.560 2.004e-34 96.190000 1.031e+02 +#> k_parent 0.098970 22.850 1.099e-21 0.090530 1.082e-01 +#> k_m1 0.005245 8.046 1.732e-09 0.004072 6.756e-03 +#> f_parent_to_m1 0.513600 23.560 4.352e-22 0.469300 5.578e-01 +#> sigma_parent 3.401000 5.985 5.662e-07 2.244000 4.559e+00 +#> sigma_m1 2.855000 6.311 2.215e-07 1.934000 3.777e+00 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 6.398 4 15 +#> parent 6.464 2 7 +#> m1 4.682 2 8 +#> +#> Resulting formation fractions: +#> ff +#> parent_m1 0.5136 +#> parent_sink 0.4864 +#> +#> Estimated disappearance times: +#> DT50 DT90 +#> parent 7.003 23.26 +#> m1 132.154 439.01 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 99.46 99.65417 -1.942e-01 +#> 0 parent 102.04 99.65417 2.386e+00 +#> 1 parent 93.50 90.26332 3.237e+00 +#> 1 parent 92.50 90.26332 2.237e+00 +#> 3 parent 63.23 74.05306 -1.082e+01 +#> 3 parent 68.99 74.05306 -5.063e+00 +#> 7 parent 52.32 49.84325 2.477e+00 +#> 7 parent 55.13 49.84325 5.287e+00 +#> 14 parent 27.27 24.92971 2.340e+00 +#> 14 parent 26.64 24.92971 1.710e+00 +#> 21 parent 11.50 12.46890 -9.689e-01 +#> 21 parent 11.64 12.46890 -8.289e-01 +#> 35 parent 2.85 3.11925 -2.692e-01 +#> 35 parent 2.91 3.11925 -2.092e-01 +#> 50 parent 0.69 0.70679 -1.679e-02 +#> 50 parent 0.63 0.70679 -7.679e-02 +#> 75 parent 0.05 0.05952 -9.523e-03 +#> 75 parent 0.06 0.05952 4.772e-04 +#> 1 m1 4.84 4.81075 2.925e-02 +#> 1 m1 5.64 4.81075 8.292e-01 +#> 3 m1 12.91 13.04196 -1.320e-01 +#> 3 m1 12.96 13.04196 -8.196e-02 +#> 7 m1 22.97 25.06847 -2.098e+00 +#> 7 m1 24.47 25.06847 -5.985e-01 +#> 14 m1 41.69 36.70308 4.987e+00 +#> 14 m1 33.21 36.70308 -3.493e+00 +#> 21 m1 44.37 41.65115 2.719e+00 +#> 21 m1 46.44 41.65115 4.789e+00 +#> 35 m1 41.22 43.29465 -2.075e+00 +#> 35 m1 37.95 43.29465 -5.345e+00 +#> 50 m1 41.19 41.19948 -9.479e-03 +#> 50 m1 40.01 41.19948 -1.189e+00 +#> 75 m1 40.09 36.44035 3.650e+00 +#> 75 m1 33.85 36.44035 -2.590e+00 +#> 100 m1 31.04 31.98773 -9.477e-01 +#> 100 m1 33.13 31.98773 1.142e+00 +#> 120 m1 25.15 28.80429 -3.654e+00 +#> 120 m1 33.31 28.80429 4.506e+00
f.tc <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, error_model = "tc", quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
summary(f.tc)
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 05:54:20 2020 +#> Date of summary: Wed May 27 05:54:20 2020 +#> +#> Equations: +#> d_parent/dt = - k_parent * parent +#> d_m1/dt = + f_parent_to_m1 * k_parent * parent - k_m1 * m1 +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 2088 model solutions performed in 0.714 s +#> +#> Error model: Two-component variance function +#> +#> Error model algorithm: d_3 +#> Direct fitting and three-step fitting yield approximately the same likelihood +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 100.7500 state +#> k_parent 0.1000 deparm +#> k_m1 0.1001 deparm +#> f_parent_to_m1 0.5000 deparm +#> sigma_low 0.1000 error +#> rsd_high 0.1000 error +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 100.750000 -Inf Inf +#> log_k_parent -2.302585 -Inf Inf +#> log_k_m1 -2.301586 -Inf Inf +#> f_parent_ilr_1 0.000000 -Inf Inf +#> sigma_low 0.100000 0 Inf +#> rsd_high 0.100000 0 Inf +#> +#> Fixed parameter values: +#> value type +#> m1_0 0 state +#> +#> Results: +#> +#> AIC BIC logLik +#> 141.9656 151.7911 -64.98278 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 100.70000 2.621000 95.400000 106.10000 +#> log_k_parent -2.29700 0.008862 -2.315000 -2.27900 +#> log_k_m1 -5.26600 0.091310 -5.452000 -5.08000 +#> f_parent_ilr_1 0.02374 0.055300 -0.088900 0.13640 +#> sigma_low 0.00305 0.004829 -0.006786 0.01289 +#> rsd_high 0.07928 0.009418 0.060100 0.09847 +#> +#> Parameter correlation: +#> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 sigma_low rsd_high +#> parent_0 1.00000 0.67644 -0.10215 -0.76822 0.14294 -0.08783 +#> log_k_parent 0.67644 1.00000 -0.15102 -0.59491 0.34611 -0.08125 +#> log_k_m1 -0.10215 -0.15102 1.00000 0.51808 -0.05236 0.01240 +#> f_parent_ilr_1 -0.76822 -0.59491 0.51808 1.00000 -0.13900 0.03248 +#> sigma_low 0.14294 0.34611 -0.05236 -0.13900 1.00000 -0.16546 +#> rsd_high -0.08783 -0.08125 0.01240 0.03248 -0.16546 1.00000 +#> +#> 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 1.007e+02 38.4300 1.180e-28 95.400000 1.061e+02 +#> k_parent 1.006e-01 112.8000 1.718e-43 0.098760 1.024e-01 +#> k_m1 5.167e-03 10.9500 1.171e-12 0.004290 6.223e-03 +#> f_parent_to_m1 5.084e-01 26.0100 2.146e-23 0.468600 5.481e-01 +#> sigma_low 3.050e-03 0.6314 2.661e-01 -0.006786 1.289e-02 +#> rsd_high 7.928e-02 8.4170 6.418e-10 0.060100 9.847e-02 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 6.475 4 15 +#> parent 6.573 2 7 +#> m1 4.671 2 8 +#> +#> Resulting formation fractions: +#> ff +#> parent_m1 0.5084 +#> parent_sink 0.4916 +#> +#> Estimated disappearance times: +#> DT50 DT90 +#> parent 6.893 22.9 +#> m1 134.156 445.7 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 99.46 100.73434 -1.274340 +#> 0 parent 102.04 100.73434 1.305660 +#> 1 parent 93.50 91.09751 2.402486 +#> 1 parent 92.50 91.09751 1.402486 +#> 3 parent 63.23 74.50141 -11.271410 +#> 3 parent 68.99 74.50141 -5.511410 +#> 7 parent 52.32 49.82880 2.491200 +#> 7 parent 55.13 49.82880 5.301200 +#> 14 parent 27.27 24.64809 2.621908 +#> 14 parent 26.64 24.64809 1.991908 +#> 21 parent 11.50 12.19232 -0.692315 +#> 21 parent 11.64 12.19232 -0.552315 +#> 35 parent 2.85 2.98327 -0.133266 +#> 35 parent 2.91 2.98327 -0.073266 +#> 50 parent 0.69 0.66013 0.029874 +#> 50 parent 0.63 0.66013 -0.030126 +#> 75 parent 0.05 0.05344 -0.003438 +#> 75 parent 0.06 0.05344 0.006562 +#> 1 m1 4.84 4.88645 -0.046451 +#> 1 m1 5.64 4.88645 0.753549 +#> 3 m1 12.91 13.22867 -0.318669 +#> 3 m1 12.96 13.22867 -0.268669 +#> 7 m1 22.97 25.36417 -2.394166 +#> 7 m1 24.47 25.36417 -0.894166 +#> 14 m1 41.69 37.00974 4.680263 +#> 14 m1 33.21 37.00974 -3.799737 +#> 21 m1 44.37 41.90133 2.468669 +#> 21 m1 46.44 41.90133 4.538669 +#> 35 m1 41.22 43.45691 -2.236913 +#> 35 m1 37.95 43.45691 -5.506913 +#> 50 m1 41.19 41.34199 -0.151985 +#> 50 m1 40.01 41.34199 -1.331985 +#> 75 m1 40.09 36.61471 3.475295 +#> 75 m1 33.85 36.61471 -2.764705 +#> 100 m1 31.04 32.20082 -1.160823 +#> 100 m1 33.13 32.20082 0.929177 +#> 120 m1 25.15 29.04130 -3.891304 +#> 120 m1 33.31 29.04130 4.268696
# } + + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinmod.html b/docs/dev/reference/mkinmod.html new file mode 100644 index 00000000..80a72b2b --- /dev/null +++ b/docs/dev/reference/mkinmod.html @@ -0,0 +1,320 @@ + + + + + + + + +Function to set up a kinetic model with one or more state variables — mkinmod • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The function usually takes several expressions, each assigning a compound +name to a list, specifying the kinetic model type and reaction or transfer +to other observed compartments. Instead of specifying several expressions, a +list of lists can be given in the speclist argument.

+
+ +
mkinmod(
+  ...,
+  use_of_ff = "max",
+  speclist = NULL,
+  quiet = FALSE,
+  verbose = FALSE
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
...

For each observed variable, a list has to be specified as an +argument, containing at least a component type, specifying the type +of kinetics to use for the variable. Currently, single first order +kinetics "SFO", indeterminate order rate equation kinetics "IORE", or +single first order with reversible binding "SFORB" are implemented for all +variables, while "FOMC", "DFOP" and "HS" can additionally be chosen for +the first variable which is assumed to be the source compartment. +Additionally, each component of the list can include a character vector +to, specifying names of variables to which a transfer is to be +assumed in the model. If the argument use_of_ff is set to "min" +(default) and the model for the compartment is "SFO" or "SFORB", an +additional component of the list can be "sink=FALSE" effectively fixing +the flux to sink to zero.

use_of_ff

Specification of the use of formation fractions in the +model equations and, if applicable, the coefficient matrix. If "min", a +minimum use of formation fractions is made in order to avoid fitting the +product of formation fractions and rate constants. If "max", formation +fractions are always used.

speclist

The specification of the observed variables and their +submodel types and pathways can be given as a single list using this +argument. Default is NULL.

quiet

Should messages be suppressed?

verbose

If TRUE, passed to cfunction if +applicable to give detailed information about the C function being built.

+ +

Value

+ +

A list of class mkinmod for use with mkinfit, +containing, among others,

+
diffs

A vector of string representations of differential equations, one for +each modelling variable.

+
map

A list containing named character vectors for each observed variable, +specifying the modelling variables by which it is represented.

+
use_of_ff

The content of use_of_ff is passed on in this list component.

+
deg_func

If generated, a function containing the solution of the degradation +model.

+
coefmat

The coefficient matrix, if the system of differential equations can be +represented by one.

+
cf

If generated, a compiled function calculating the derivatives as +returned by cfunction.

+ +

Details

+ +

For the definition of model types and their parameters, the equations given +in the FOCUS and NAFTA guidance documents are used.

+

Note

+ +

The IORE submodel is not well tested for metabolites. When using this +model for metabolites, you may want to read the second note in the help +page to mkinfit.

+

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+

NAFTA Technical Working Group on Pesticides (not dated) Guidance for +Evaluating and Calculating Degradation Kinetics in Environmental Media

+ +

Examples

+
+# Specify the SFO model (this is not needed any more, as we can now mkinfit("SFO", ...) +SFO <- mkinmod(parent = mkinsub("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.
+# \dontrun{ +# The above model used to be specified like this, before the advent of mkinsub() +SFO_SFO <- mkinmod( + parent = list(type = "SFO", to = "m1"), + m1 = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
+# Show details of creating the C function +SFO_SFO <- mkinmod( + parent = mkinsub("SFO", "m1"), + m1 = mkinsub("SFO"), verbose = TRUE)
#> Compilation argument: +#> /usr/lib/R/bin/R CMD SHLIB file1bc3f55ac46.c 2> file1bc3f55ac46.c.err.txt +#> Program source: +#> 1: #include <R.h> +#> 2: +#> 3: +#> 4: static double parms [3]; +#> 5: #define k_parent parms[0] +#> 6: #define f_parent_to_m1 parms[1] +#> 7: #define k_m1 parms[2] +#> 8: +#> 9: void initpar(void (* odeparms)(int *, double *)) { +#> 10: int N = 3; +#> 11: odeparms(&N, parms); +#> 12: } +#> 13: +#> 14: +#> 15: void func ( int * n, double * t, double * y, double * f, double * rpar, int * ipar ) { +#> 16: +#> 17: f[0] = - k_parent * y[0]; +#> 18: f[1] = + f_parent_to_m1 * k_parent * y[0] - k_m1 * y[1]; +#> 19: }
#> Successfully compiled differential equation model from auto-generated C code.
+# If we have several parallel metabolites +# (compare tests/testthat/test_synthetic_data_for_UBA_2014.R) +m_synth_DFOP_par <- mkinmod(parent = mkinsub("DFOP", c("M1", "M2")), + M1 = mkinsub("SFO"), + M2 = mkinsub("SFO"), + use_of_ff = "max", quiet = TRUE) + +fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par, + synthetic_data_for_UBA_2014[[12]]$data, + quiet = TRUE) +# }
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinparplot-1.png b/docs/dev/reference/mkinparplot-1.png new file mode 100644 index 00000000..31800c09 Binary files /dev/null and b/docs/dev/reference/mkinparplot-1.png differ diff --git a/docs/dev/reference/mkinparplot.html b/docs/dev/reference/mkinparplot.html new file mode 100644 index 00000000..790f5e7e --- /dev/null +++ b/docs/dev/reference/mkinparplot.html @@ -0,0 +1,203 @@ + + + + + + + + +Function to plot the confidence intervals obtained using mkinfit — mkinparplot • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function plots the confidence intervals for the parameters fitted using +mkinfit.

+
+ +
mkinparplot(object)
+ +

Arguments

+ + + + + + +
object

A fit represented in an mkinfit object.

+ +

Value

+ +

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+ +

Examples

+
+# \dontrun{ +model <- mkinmod( + T245 = mkinsub("SFO", to = c("phenol"), sink = FALSE), + phenol = mkinsub("SFO", to = c("anisole")), + anisole = mkinsub("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)
#> Warning: Observations with value of zero were removed from the data
mkinparplot(fit)
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinplot.html b/docs/dev/reference/mkinplot.html new file mode 100644 index 00000000..b36bcfc2 --- /dev/null +++ b/docs/dev/reference/mkinplot.html @@ -0,0 +1,198 @@ + + + + + + + + +Plot the observed data and the fitted model of an mkinfit object — mkinplot • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Deprecated function. It now only calls the plot method +plot.mkinfit.

+
+ +
mkinplot(fit, ...)
+ +

Arguments

+ + + + + + + + + + +
fit

an object of class mkinfit.

...

further arguments passed to plot.mkinfit.

+ +

Value

+ +

The function is called for its side effect.

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinpredict.html b/docs/dev/reference/mkinpredict.html new file mode 100644 index 00000000..6d83e56f --- /dev/null +++ b/docs/dev/reference/mkinpredict.html @@ -0,0 +1,447 @@ + + + + + + + + +Produce predictions from a kinetic model using specific parameters — mkinpredict • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function produces a time series for all the observed variables in a +kinetic model as specified by mkinmod, using a specific set of +kinetic parameters and initial values for the state variables.

+
+ +
mkinpredict(
+  x,
+  odeparms,
+  odeini,
+  outtimes = seq(0, 120, by = 0.1),
+  solution_type = "deSolve",
+  use_compiled = "auto",
+  method.ode = "lsoda",
+  atol = 1e-08,
+  rtol = 1e-10,
+  map_output = TRUE,
+  ...
+)
+
+# S3 method for mkinmod
+mkinpredict(
+  x,
+  odeparms = c(k_parent_sink = 0.1),
+  odeini = c(parent = 100),
+  outtimes = seq(0, 120, by = 0.1),
+  solution_type = "deSolve",
+  use_compiled = "auto",
+  method.ode = "lsoda",
+  atol = 1e-08,
+  rtol = 1e-10,
+  map_output = TRUE,
+  ...
+)
+
+# S3 method for mkinfit
+mkinpredict(
+  x,
+  odeparms = x$bparms.ode,
+  odeini = x$bparms.state,
+  outtimes = seq(0, 120, by = 0.1),
+  solution_type = "deSolve",
+  use_compiled = "auto",
+  method.ode = "lsoda",
+  atol = 1e-08,
+  rtol = 1e-10,
+  map_output = TRUE,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

A kinetic model as produced by mkinmod, or a kinetic +fit as fitted by mkinfit. In the latter case, the fitted +parameters are used for the prediction.

odeparms

A numeric vector specifying the parameters used in the +kinetic model, which is generally defined as a set of ordinary +differential equations.

odeini

A numeric vector containing the initial values of the state +variables of the model. Note that the state variables can differ from the +observed variables, for example in the case of the SFORB model.

outtimes

A numeric vector specifying the time points for which model +predictions should be generated.

solution_type

The method that should be used for producing the +predictions. This should generally be "analytical" if there is only one +observed variable, and usually "deSolve" in the case of several observed +variables. The third possibility "eigen" is faster but not applicable to +some models e.g. using FOMC for the parent compound.

use_compiled

If set to FALSE, no compiled version of the +mkinmod model is used, even if is present.

method.ode

The solution method passed via mkinpredict +to ode in case the solution type is "deSolve". The default +"lsoda" is performant, but sometimes fails to converge.

atol

Absolute error tolerance, passed to ode. Default +is 1e-8, lower than in lsoda.

rtol

Absolute error tolerance, passed to ode. Default +is 1e-10, much lower than in lsoda.

map_output

Boolean to specify if the output should list values for +the observed variables (default) or for all state variables (if set to +FALSE). Setting this to FALSE has no effect for analytical solutions, +as these always return mapped output.

...

Further arguments passed to the ode solver in case such a +solver is used.

+ +

Value

+ +

A matrix with the numeric solution in wide format

+ +

Examples

+
+SFO <- mkinmod(degradinol = mkinsub("SFO")) +# Compare solution types +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")
#> time degradinol +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108997 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "deSolve")
#> time degradinol +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108996 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "deSolve", use_compiled = FALSE)
#> time degradinol +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108996 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "eigen")
#> time degradinol +#> 0 0 100.0000000 +#> 1 1 74.0818221 +#> 2 2 54.8811636 +#> 3 3 40.6569660 +#> 4 4 30.1194212 +#> 5 5 22.3130160 +#> 6 6 16.5298888 +#> 7 7 12.2456428 +#> 8 8 9.0717953 +#> 9 9 6.7205513 +#> 10 10 4.9787068 +#> 11 11 3.6883167 +#> 12 12 2.7323722 +#> 13 13 2.0241911 +#> 14 14 1.4995577 +#> 15 15 1.1108997 +#> 16 16 0.8229747 +#> 17 17 0.6096747 +#> 18 18 0.4516581 +#> 19 19 0.3345965 +#> 20 20 0.2478752
+# Compare integration methods to analytical solution +mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + solution_type = "analytical")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "lsoda")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "ode45")[21,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), 0:20, + method = "rk4")[21,]
#> time degradinol +#> 20.0000000 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 = 0.3), c(degradinol = 100), + seq(0, 20, by = 0.1))[201,]
#> time degradinol +#> 20.0000000 0.2478752
mkinpredict(SFO, c(k_degradinol = 0.3), c(degradinol = 100), + seq(0, 20, by = 0.01))[2001,]
#> time degradinol +#> 20.0000000 0.2478752
+# Comparison of the performance of solution types +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.
if(require(rbenchmark)) { + benchmark(replications = 10, order = "relative", columns = c("test", "relative", "elapsed"), + eigen = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "eigen")[201,], + deSolve_compiled = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "deSolve")[201,], + deSolve = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "deSolve", use_compiled = FALSE)[201,], + analytical = mkinpredict(SFO_SFO, + c(k_parent = 0.15, f_parent_to_m1 = 0.5, k_m1 = 0.01), + c(parent = 100, m1 = 0), seq(0, 20, by = 0.1), + solution_type = "analytical", use_compiled = FALSE)[201,]) +}
#> test relative elapsed +#> 2 deSolve_compiled 1.0 0.005 +#> 4 analytical 1.0 0.005 +#> 1 eigen 4.0 0.020 +#> 3 deSolve 45.6 0.228
+# \dontrun{ + # Predict from a fitted model + f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE) + f <- mkinfit(SFO_SFO, FOCUS_2006_C, quiet = TRUE, solution_type = "deSolve") + head(mkinpredict(f))
#> time parent m1 +#> 0 0.0 82.49216 0.000000 +#> 0.1 0.1 80.00562 1.236198 +#> 0.2 0.2 77.59404 2.422818 +#> 0.3 0.3 75.25514 3.561476 +#> 0.4 0.4 72.98675 4.653740 +#> 0.5 0.5 70.78673 5.701130
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinresplot-1.png b/docs/dev/reference/mkinresplot-1.png new file mode 100644 index 00000000..bb9657b4 Binary files /dev/null and b/docs/dev/reference/mkinresplot-1.png differ diff --git a/docs/dev/reference/mkinresplot.html b/docs/dev/reference/mkinresplot.html new file mode 100644 index 00000000..11e0914e --- /dev/null +++ b/docs/dev/reference/mkinresplot.html @@ -0,0 +1,275 @@ + + + + + + + + +Function to plot residuals stored in an mkin object — mkinresplot • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

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 using the +argument show_residuals = TRUE.

+
+ +
mkinresplot(
+  object,
+  obs_vars = names(object$mkinmod$map),
+  xlim = c(0, 1.1 * max(object$data$time)),
+  standardized = FALSE,
+  xlab = "Time",
+  ylab = ifelse(standardized, "Standardized residual", "Residual"),
+  maxabs = "auto",
+  legend = TRUE,
+  lpos = "topright",
+  col_obs = "auto",
+  pch_obs = "auto",
+  frame = TRUE,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
object

A fit represented in an mkinfit object.

obs_vars

A character vector of names of the observed variables for +which residuals should be plotted. Defaults to all observed variables in +the model

xlim

plot range in x direction.

standardized

Should the residuals be standardized by dividing by the +standard deviation given by the error model of the fit?

xlab

Label for the x axis.

ylab

Label for the y axis.

maxabs

Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".

legend

Should a legend be plotted?

lpos

Where should the legend be placed? Default is "topright". Will +be passed on to legend.

col_obs

Colors for the observed variables.

pch_obs

Symbols to be used for the observed variables.

frame

Should a frame be drawn around the plots?

...

further arguments passed to plot.

+ +

Value

+ +

Nothing is returned by this function, as it is called for its side +effect, namely to produce a plot.

+

See also

+ +

mkinplot, for a way to plot the data and the fitted +lines of the mkinfit object, and plot_res for a function +combining the plot of the fit and the residual plot.

+ +

Examples

+
+model <- mkinmod(parent = mkinsub("SFO", "m1"), m1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
fit <- mkinfit(model, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
mkinresplot(fit, "m1")
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mkinsub.html b/docs/dev/reference/mkinsub.html new file mode 100644 index 00000000..dc4faf0d --- /dev/null +++ b/docs/dev/reference/mkinsub.html @@ -0,0 +1,228 @@ + + + + + + + + +Function to set up a kinetic submodel for one state variable — mkinsub • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This is a convenience function to set up the lists used as arguments for +mkinmod.

+
+ +
mkinsub(submodel, to = NULL, sink = TRUE, full_name = NA)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + +
submodel

Character vector of length one to specify the submodel type. +See mkinmod for the list of allowed submodel names.

to

Vector of the names of the state variable to which a +transformation shall be included in the model.

sink

Should a pathway to sink be included in the model in addition to +the pathways to other state variables?

full_name

An optional name to be used e.g. for plotting fits +performed with the model. You can use non-ASCII characters here, but then +your R code will not be portable, i.e. may produce unintended plot +results on other operating systems or system configurations.

+ +

Value

+ +

A list for use with mkinmod.

+ +

Examples

+
+# 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.
+# 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.
+# \dontrun{ + # 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.
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/mmkin-1.png b/docs/dev/reference/mmkin-1.png new file mode 100644 index 00000000..135d5446 Binary files /dev/null and b/docs/dev/reference/mmkin-1.png differ diff --git a/docs/dev/reference/mmkin-2.png b/docs/dev/reference/mmkin-2.png new file mode 100644 index 00000000..40109afc Binary files /dev/null and b/docs/dev/reference/mmkin-2.png differ diff --git a/docs/dev/reference/mmkin-3.png b/docs/dev/reference/mmkin-3.png new file mode 100644 index 00000000..e80448ab Binary files /dev/null and b/docs/dev/reference/mmkin-3.png differ diff --git a/docs/dev/reference/mmkin-4.png b/docs/dev/reference/mmkin-4.png new file mode 100644 index 00000000..02976ced Binary files /dev/null and b/docs/dev/reference/mmkin-4.png differ diff --git a/docs/dev/reference/mmkin-5.png b/docs/dev/reference/mmkin-5.png new file mode 100644 index 00000000..4c771bc9 Binary files /dev/null and b/docs/dev/reference/mmkin-5.png differ diff --git a/docs/dev/reference/mmkin.html b/docs/dev/reference/mmkin.html new file mode 100644 index 00000000..1b5c1592 --- /dev/null +++ b/docs/dev/reference/mmkin.html @@ -0,0 +1,271 @@ + + + + + + + + +Fit one or more kinetic models with one or more state variables to one or +more datasets — mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function calls mkinfit on all combinations of models and +datasets specified in its first two arguments.

+
+ +
mmkin(
+  models = c("SFO", "FOMC", "DFOP"),
+  datasets,
+  cores = detectCores(),
+  cluster = NULL,
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
models

Either a character vector of shorthand names like +c("SFO", "FOMC", "DFOP", "HS", "SFORB"), or an optionally named +list of mkinmod objects.

datasets

An optionally named list of datasets suitable as observed +data for mkinfit.

cores

The number of cores to be used for multicore processing. This +is only used when the cluster argument is NULL. On Windows +machines, cores > 1 is not supported, you need to use the cluster +argument to use multiple logical processors. Per default, all cores +detected by parallel::detectCores() are used.

cluster

A cluster as returned by makeCluster to be used +for parallel execution.

...

Further arguments that will be passed to mkinfit.

+ +

Value

+ +

A two-dimensional array of mkinfit +objects that can be indexed using the model names for the first index (row index) +and the dataset names for the second index (column index).

+

See also

+ +

[.mmkin for subsetting, plot.mmkin for +plotting.

+ +

Examples

+
+# \dontrun{ +m_synth_SFO_lin <- mkinmod(parent = mkinsub("SFO", "M1"), + M1 = mkinsub("SFO", "M2"), + M2 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+m_synth_FOMC_lin <- mkinmod(parent = mkinsub("FOMC", "M1"), + M1 = mkinsub("SFO", "M2"), + M2 = mkinsub("SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+models <- list(SFO_lin = m_synth_SFO_lin, FOMC_lin = m_synth_FOMC_lin) +datasets <- lapply(synthetic_data_for_UBA_2014[1:3], function(x) x$data) +names(datasets) <- paste("Dataset", 1:3) + +time_default <- system.time(fits.0 <- mmkin(models, datasets, quiet = TRUE)) +time_1 <- system.time(fits.4 <- mmkin(models, datasets, cores = 1, quiet = TRUE))
#> Warning: Optimisation did not converge: +#> false convergence (8)
+time_default
#> user system elapsed +#> 4.516 0.456 1.976
time_1
#> user system elapsed +#> 5.957 0.001 5.961
+endpoints(fits.0[["SFO_lin", 2]])
#> $ff +#> parent_M1 parent_sink M1_M2 M1_sink +#> 0.7340479 0.2659521 0.7505687 0.2494313 +#> +#> $distimes +#> DT50 DT90 +#> parent 0.8777688 2.915885 +#> M1 2.3257457 7.725960 +#> M2 33.7200848 112.015697 +#>
+# plot.mkinfit handles rows or columns of mmkin result objects +plot(fits.0[1, ])
plot(fits.0[1, ], obs_var = c("M1", "M2"))
plot(fits.0[, 1])
# Use double brackets to extract a single mkinfit object, which will be plotted +# by plot.mkinfit and can be plotted using plot_sep +plot(fits.0[[1, 1]], sep_obs = TRUE, show_residuals = TRUE, show_errmin = TRUE)
plot_sep(fits.0[[1, 1]]) +# Plotting with mmkin (single brackets, extracting an mmkin object) does not +# allow to plot the observed variables separately +plot(fits.0[1, 1])
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/nafta-1.png b/docs/dev/reference/nafta-1.png new file mode 100644 index 00000000..9025f2bb Binary files /dev/null and b/docs/dev/reference/nafta-1.png differ diff --git a/docs/dev/reference/nafta.html b/docs/dev/reference/nafta.html new file mode 100644 index 00000000..fe802c1b --- /dev/null +++ b/docs/dev/reference/nafta.html @@ -0,0 +1,283 @@ + + + + + + + + +Evaluate parent kinetics using the NAFTA guidance — nafta • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The function fits the SFO, IORE and DFOP models using mmkin +and returns an object of class nafta that has methods for printing +and plotting.

+

Print nafta objects. The results for the three models are printed in the +order of increasing model complexity, i.e. SFO, then IORE, and finally DFOP.

+
+ +
nafta(ds, title = NA, quiet = FALSE, ...)
+
+# S3 method for nafta
+print(x, quiet = TRUE, digits = 3, ...)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
ds

A dataframe that must contain one variable called "time" with the +time values specified by the time argument, one column called +"name" with the grouping of the observed values, and finally one column of +observed values called "value".

title

Optional title of the dataset

quiet

Should the evaluation text be shown?

...

Further arguments passed to mmkin (not for the +printing method).

x

An nafta object.

digits

Number of digits to be used for printing parameters and +dissipation times.

+ +

Source

+ +

NAFTA (2011) Guidance for evaluating and calculating degradation +kinetics in environmental media. NAFTA Technical Working Group on +Pesticides +https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/guidance-evaluating-and-calculating-degradation +accessed 2019-02-22

+

US EPA (2015) Standard Operating Procedure for Using the NAFTA Guidance to +Calculate Representative Half-life Values and Characterizing Pesticide +Degradation +https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance

+

Value

+ +

An list of class nafta. The list element named "mmkin" is the +mmkin object containing the fits of the three models. The +list element named "title" contains the title of the dataset used. The +list element "data" contains the dataset used in the fits.

+ +

Examples

+
+ nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D, cores = 1)
#> 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
print(nafta_evaluation)
#> Sums of squares: +#> SFO IORE DFOP +#> 1378.6832 615.7730 517.8836 +#> +#> Critical sum of squares for checking the SFO model: +#> [1] 717.4598 +#> +#> Parameters: +#> $SFO +#> Estimate Pr(>t) Lower Upper +#> parent_0 83.7558 1.80e-14 77.18268 90.3288 +#> k_parent_sink 0.0017 7.43e-05 0.00112 0.0026 +#> sigma 8.7518 1.22e-05 5.64278 11.8608 +#> +#> $IORE +#> Estimate Pr(>t) Lower Upper +#> parent_0 9.69e+01 NA 8.88e+01 1.05e+02 +#> k__iore_parent_sink 8.40e-14 NA 1.79e-18 3.94e-09 +#> N_parent 6.68e+00 NA 4.19e+00 9.17e+00 +#> sigma 5.85e+00 NA 3.76e+00 7.94e+00 +#> +#> $DFOP +#> Estimate Pr(>t) Lower Upper +#> parent_0 9.76e+01 1.94e-13 9.02e+01 1.05e+02 +#> k1 4.24e-02 5.92e-03 2.03e-02 8.88e-02 +#> k2 8.24e-04 6.48e-03 3.89e-04 1.75e-03 +#> g 2.88e-01 2.47e-05 1.95e-01 4.03e-01 +#> sigma 5.36e+00 2.22e-05 3.43e+00 7.30e+00 +#> +#> +#> DTx values: +#> DT50 DT90 DT50_rep +#> SFO 407 1350 407 +#> IORE 541 5190000 1560000 +#> DFOP 429 2380 841 +#> +#> Representative half-life: +#> [1] 841.41
plot(nafta_evaluation)
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/nlme-1.png b/docs/dev/reference/nlme-1.png new file mode 100644 index 00000000..bc04dea8 Binary files /dev/null and b/docs/dev/reference/nlme-1.png differ diff --git a/docs/dev/reference/nlme.html b/docs/dev/reference/nlme.html new file mode 100644 index 00000000..8c64fb47 --- /dev/null +++ b/docs/dev/reference/nlme.html @@ -0,0 +1,281 @@ + + + + + + + + +Helper functions to create nlme models from mmkin row objects — nlme_function • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

These functions facilitate setting up a nonlinear mixed effects model for +an mmkin row object. An mmkin row object is essentially a list of mkinfit +objects that have been obtained by fitting the same model to a list of +datasets. They are used internally by the nlme.mmkin() method.

+
+ +
nlme_function(object)
+
+mean_degparms(object, random = FALSE)
+
+nlme_data(object)
+ +

Arguments

+ + + + + + + + + + +
object

An mmkin row object containing several fits of the same model to different datasets

random

Should a list with fixed and random effects be returned?

+ +

Value

+ +

A function that can be used with nlme

+

If random is FALSE (default), a named vector containing mean values +of the fitted degradation model parameters. If random is TRUE, a list with +fixed and random effects, in the format required by the start argument of +nlme for the case of a single grouping variable ds.

+

A groupedData object

+

See also

+ + + +

Examples

+
sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) +m_SFO <- mkinmod(parent = mkinsub("SFO")) +d_SFO_1 <- mkinpredict(m_SFO, + c(k_parent = 0.1), + c(parent = 98), sampling_times) +d_SFO_1_long <- mkin_wide_to_long(d_SFO_1, time = "time") +d_SFO_2 <- mkinpredict(m_SFO, + c(k_parent = 0.05), + c(parent = 102), sampling_times) +d_SFO_2_long <- mkin_wide_to_long(d_SFO_2, time = "time") +d_SFO_3 <- mkinpredict(m_SFO, + c(k_parent = 0.02), + c(parent = 103), sampling_times) +d_SFO_3_long <- mkin_wide_to_long(d_SFO_3, time = "time") + +d1 <- add_err(d_SFO_1, function(value) 3, n = 1) +d2 <- add_err(d_SFO_2, function(value) 2, n = 1) +d3 <- add_err(d_SFO_3, function(value) 4, n = 1) +ds <- c(d1 = d1, d2 = d2, d3 = d3) + +f <- mmkin("SFO", ds, cores = 1, quiet = TRUE) +mean_dp <- mean_degparms(f) +grouped_data <- nlme_data(f) +nlme_f <- nlme_function(f) +# These assignments are necessary for these objects to be +# visible to nlme and augPred when evaluation is done by +# pkgdown to generated the html docs. +assign("nlme_f", nlme_f, globalenv()) +assign("grouped_data", grouped_data, globalenv()) + +library(nlme) +m_nlme <- nlme(value ~ nlme_f(name, time, parent_0, log_k_parent_sink), + data = grouped_data, + fixed = parent_0 + log_k_parent_sink ~ 1, + random = pdDiag(parent_0 + log_k_parent_sink ~ 1), + start = mean_dp) +summary(m_nlme)
#> Nonlinear mixed-effects model fit by maximum likelihood +#> Model: value ~ nlme_f(name, time, parent_0, log_k_parent_sink) +#> Data: grouped_data +#> AIC BIC logLik +#> 252.7798 262.1358 -121.3899 +#> +#> Random effects: +#> Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1) +#> Level: ds +#> Structure: Diagonal +#> parent_0 log_k_parent_sink Residual +#> StdDev: 0.004139378 0.6800778 2.489396 +#> +#> Fixed effects: parent_0 + log_k_parent_sink ~ 1 +#> Value Std.Error DF t-value p-value +#> parent_0 101.74884 0.6456057 44 157.60213 0 +#> log_k_parent_sink -3.05575 0.4015812 44 -7.60929 0 +#> Correlation: +#> prnt_0 +#> log_k_parent_sink 0.026 +#> +#> Standardized Within-Group Residuals: +#> Min Q1 Med Q3 Max +#> -2.13168782 -0.68780415 0.08282907 0.85913228 2.95298904 +#> +#> Number of Observations: 48 +#> Number of Groups: 3
plot(augPred(m_nlme, level = 0:1), layout = c(3, 1))
# augPred does not seem to work on fits with more than one state +# variable + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/nlme.mmkin-1.png b/docs/dev/reference/nlme.mmkin-1.png new file mode 100644 index 00000000..67f279da Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-1.png differ diff --git a/docs/dev/reference/nlme.mmkin-2.png b/docs/dev/reference/nlme.mmkin-2.png new file mode 100644 index 00000000..16a5d7bd Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-2.png differ diff --git a/docs/dev/reference/nlme.mmkin-3.png b/docs/dev/reference/nlme.mmkin-3.png new file mode 100644 index 00000000..73426834 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-3.png differ diff --git a/docs/dev/reference/nlme.mmkin-4.png b/docs/dev/reference/nlme.mmkin-4.png new file mode 100644 index 00000000..9b46b425 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-4.png differ diff --git a/docs/dev/reference/nlme.mmkin-5.png b/docs/dev/reference/nlme.mmkin-5.png new file mode 100644 index 00000000..3398dd4a Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-5.png differ diff --git a/docs/dev/reference/nlme.mmkin-6.png b/docs/dev/reference/nlme.mmkin-6.png new file mode 100644 index 00000000..7b663991 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-6.png differ diff --git a/docs/dev/reference/nlme.mmkin-7.png b/docs/dev/reference/nlme.mmkin-7.png new file mode 100644 index 00000000..d2c38a63 Binary files /dev/null and b/docs/dev/reference/nlme.mmkin-7.png differ diff --git a/docs/dev/reference/nlme.mmkin.html b/docs/dev/reference/nlme.mmkin.html new file mode 100644 index 00000000..a6716c0f --- /dev/null +++ b/docs/dev/reference/nlme.mmkin.html @@ -0,0 +1,463 @@ + + + + + + + + +Create an nlme model for an mmkin row object — nlme.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This functions sets up a nonlinear mixed effects model for an mmkin row +object. An mmkin row object is essentially a list of mkinfit objects that +have been obtained by fitting the same model to a list of datasets.

+
+ +
# S3 method for mmkin
+nlme(
+  model,
+  data = sys.frame(sys.parent()),
+  fixed,
+  random = fixed,
+  groups,
+  start,
+  correlation = NULL,
+  weights = NULL,
+  subset,
+  method = c("ML", "REML"),
+  na.action = na.fail,
+  naPattern,
+  control = list(),
+  verbose = FALSE
+)
+
+# S3 method for nlme.mmkin
+print(x, ...)
+
+# S3 method for nlme.mmkin
+update(object, ...)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
model

An mmkin row object.

data

Ignored, data are taken from the mmkin model

fixed

Ignored, all degradation parameters fitted in the +mmkin model are used as fixed parameters

random

If not specified, all fixed effects are complemented +with uncorrelated random effects

groups

See the documentation of nlme

start

If not specified, mean values of the fitted degradation +parameters taken from the mmkin object are used

correlation

See the documentation of nlme

weights

passed to nlme

subset

passed to nlme

method

passed to nlme

na.action

passed to nlme

naPattern

passed to nlme

control

passed to nlme

verbose

passed to nlme

x

An nlme.mmkin object to print

...

Update specifications passed to update.nlme

object

An nlme.mmkin object to update

+ +

Value

+ +

Upon success, a fitted nlme.mmkin object, which is an nlme object +with additional elements

+

See also

+ + + +

Examples

+
ds <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) subset(x$data[c("name", "time", "value")], name == "parent")) +f <- mmkin("SFO", ds, quiet = TRUE, cores = 1) +library(nlme) +endpoints(f[[1]])
#> $distimes +#> DT50 DT90 +#> parent 11.96183 39.73634 +#>
f_nlme <- nlme(f) +print(f_nlme)
#> Nonlinear mixed-effects model fit by maximum likelihood +#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_parent_sink) +#> Data: "Not shown" +#> Log-likelihood: -307.5269 +#> Fixed: list(parent_0 ~ 1, log_k_parent_sink ~ 1) +#> parent_0 log_k_parent_sink +#> 85.540979 -3.229602 +#> +#> Random effects: +#> Formula: list(parent_0 ~ 1, log_k_parent_sink ~ 1) +#> Level: ds +#> Structure: Diagonal +#> parent_0 log_k_parent_sink Residual +#> StdDev: 1.308245 1.288586 6.304923 +#> +#> Number of Observations: 90 +#> Number of Groups: 5
endpoints(f_nlme)
#> $distimes +#> DT50 DT90 +#> parent 17.51556 58.18543 +#>
# \dontrun{ + f_nlme_2 <- nlme(f, start = c(parent_0 = 100, log_k_parent_sink = 0.1)) + update(f_nlme_2, random = parent_0 ~ 1)
#> Nonlinear mixed-effects model fit by maximum likelihood +#> Model: value ~ (mkin::get_deg_func())(name, time, parent_0, log_k_parent_sink) +#> Data: "Not shown" +#> Log-likelihood: -404.3729 +#> Fixed: list(parent_0 ~ 1, log_k_parent_sink ~ 1) +#> parent_0 log_k_parent_sink +#> 75.933480 -3.555983 +#> +#> Random effects: +#> Formula: parent_0 ~ 1 | ds +#> parent_0 Residual +#> StdDev: 0.002416802 21.63027 +#> +#> Number of Observations: 90 +#> Number of Groups: 5
# Test on some real data + ds_2 <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) x$data[c("name", "time", "value")]) + m_sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"), + A1 = mkinsub("SFO"), use_of_ff = "min", quiet = TRUE) + m_sfo_sfo_ff <- mkinmod(parent = mkinsub("SFO", "A1"), + A1 = mkinsub("SFO"), use_of_ff = "max", quiet = TRUE) + m_fomc_sfo <- mkinmod(parent = mkinsub("FOMC", "A1"), + A1 = mkinsub("SFO"), quiet = TRUE) + m_dfop_sfo <- mkinmod(parent = mkinsub("DFOP", "A1"), + A1 = mkinsub("SFO"), quiet = TRUE) + + f_2 <- mmkin(list("SFO-SFO" = m_sfo_sfo, + "SFO-SFO-ff" = m_sfo_sfo_ff, + "FOMC-SFO" = m_fomc_sfo, + "DFOP-SFO" = m_dfop_sfo), + ds_2, quiet = TRUE) + plot(f_2["SFO-SFO", 3:4]) # Separate fits for datasets 3 and 4
+ f_nlme_sfo_sfo <- nlme(f_2["SFO-SFO", ]) + # plot(f_nlme_sfo_sfo) # not feasible with pkgdown figures + plot(f_nlme_sfo_sfo, 3:4) # Global mixed model: Fits for datasets 3 and 4
+ # With formation fractions + f_nlme_sfo_sfo_ff <- nlme(f_2["SFO-SFO-ff", ]) + plot(f_nlme_sfo_sfo_ff, 3:4) # chi2 different due to different df attribution
+ # For more parameters, we need to increase pnlsMaxIter and the tolerance + # to get convergence + f_nlme_fomc_sfo <- nlme(f_2["FOMC-SFO", ], + control = list(pnlsMaxIter = 100, tolerance = 1e-4), verbose = TRUE)
#> +#> **Iteration 1 +#> LME step: Loglik: -394.1603, nlminb iterations: 2 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 +#> -0.2079863 0.8563823 1.7454253 1.0917707 1.2756955 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 643.8814 +#> fixed effects: 94.17379 -5.473189 -0.6970234 -0.202509 2.103883 +#> iterations: 100 +#> Convergence crit. (must all become <= tolerance = 0.0001): +#> fixed reStruct +#> 0.7959873 0.1447512 +#> +#> **Iteration 2 +#> LME step: Loglik: -396.3824, nlminb iterations: 7 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 +#> -1.712406e-01 -2.278541e-05 1.842120e+00 1.073975e+00 1.322924e+00 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 643.8025 +#> fixed effects: 94.17385 -5.473491 -0.6970406 -0.2025139 2.103871 +#> iterations: 100 +#> Convergence crit. (must all become <= tolerance = 0.0001): +#> fixed reStruct +#> 5.51758e-05 1.26861e-03 +#> +#> **Iteration 3 +#> LME step: Loglik: -396.3825, nlminb iterations: 7 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 +#> -0.1712500923 -0.0001515734 1.8420972550 1.0739796967 1.3229177241 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 643.7941 +#> fixed effects: 94.17386 -5.473523 -0.6970424 -0.2025146 2.103869 +#> iterations: 100 +#> Convergence crit. (must all become <= tolerance = 0.0001): +#> fixed reStruct +#> 5.792621e-06 1.335434e-04 +#> +#> **Iteration 4 +#> LME step: Loglik: -396.3825, nlminb iterations: 7 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 +#> -0.1712517206 -0.0001651603 1.8420950864 1.0739800294 1.3229173529 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 643.7949 +#> fixed effects: 94.17386 -5.473521 -0.6970423 -0.2025145 2.10387 +#> iterations: 100 +#> Convergence crit. (must all become <= tolerance = 0.0001): +#> fixed reStruct +#> 4.025781e-07 9.628656e-06
f_nlme_dfop_sfo <- nlme(f_2["DFOP-SFO", ], + control = list(pnlsMaxIter = 120, tolerance = 5e-4), verbose = TRUE)
#> +#> **Iteration 1 +#> LME step: Loglik: -404.9583, nlminb iterations: 1 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 ds6 +#> -0.4114357 0.9798641 1.6990035 0.7293314 0.3354323 1.7113047 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 630.3642 +#> fixed effects: 93.82269 -5.455991 -0.6788957 -1.862196 -4.199671 0.0553284 +#> iterations: 120 +#> Convergence crit. (must all become <= tolerance = 0.0005): +#> fixed reStruct +#> 0.7879730 0.5822574 +#> +#> **Iteration 2 +#> LME step: Loglik: -407.7755, nlminb iterations: 11 +#> reStruct parameters: +#> ds1 ds2 ds3 ds4 ds5 ds6 +#> -0.371224105 0.003056163 1.789939431 0.724671132 0.301602942 1.754200482 +#> Beginning PNLS step: .. completed fit_nlme() step. +#> PNLS step: RSS = 630.364 +#> fixed effects: 93.82269 -5.455991 -0.6788958 -1.862196 -4.199671 0.05532834 +#> iterations: 120 +#> Convergence crit. (must all become <= tolerance = 0.0005): +#> fixed reStruct +#> 9.814652e-07 1.059239e-05
plot(f_2["FOMC-SFO", 3:4])
plot(f_nlme_fomc_sfo, 3:4)
+ plot(f_2["DFOP-SFO", 3:4])
plot(f_nlme_dfop_sfo, 3:4)
+ anova(f_nlme_dfop_sfo, f_nlme_fomc_sfo, f_nlme_sfo_sfo)
#> Model df AIC BIC logLik Test L.Ratio p-value +#> f_nlme_dfop_sfo 1 13 843.8547 884.6201 -408.9274 +#> f_nlme_fomc_sfo 2 11 818.5151 853.0089 -398.2576 1 vs 2 21.33957 <.0001 +#> f_nlme_sfo_sfo 3 9 1085.1821 1113.4043 -533.5910 2 vs 3 270.66697 <.0001
anova(f_nlme_dfop_sfo, f_nlme_sfo_sfo) # if we ignore FOMC
#> Model df AIC BIC logLik Test L.Ratio p-value +#> f_nlme_dfop_sfo 1 13 843.8547 884.6201 -408.9274 +#> f_nlme_sfo_sfo 2 9 1085.1821 1113.4043 -533.5910 1 vs 2 249.3274 <.0001
+ endpoints(f_nlme_sfo_sfo)
#> $ff +#> parent_sink parent_A1 A1_sink +#> 0.5912432 0.4087568 1.0000000 +#> +#> $distimes +#> DT50 DT90 +#> parent 19.13518 63.5657 +#> A1 66.02155 219.3189 +#>
endpoints(f_nlme_dfop_sfo)
#> $ff +#> parent_A1 parent_sink +#> 0.2768574 0.7231426 +#> +#> $distimes +#> DT50 DT90 DT50_k1 DT50_k2 +#> parent 11.07091 104.6320 4.462384 46.20825 +#> A1 162.30518 539.1661 NA NA +#>
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/nobs.mkinfit.html b/docs/dev/reference/nobs.mkinfit.html new file mode 100644 index 00000000..06575d54 --- /dev/null +++ b/docs/dev/reference/nobs.mkinfit.html @@ -0,0 +1,197 @@ + + + + + + + + +Number of observations on which an mkinfit object was fitted — nobs.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Number of observations on which an mkinfit object was fitted

+
+ +
# S3 method for mkinfit
+nobs(object, ...)
+ +

Arguments

+ + + + + + + + + + +
object

An mkinfit object

...

For compatibility with the generic method

+ +

Value

+ +

The number of rows in the data included in the mkinfit object

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/parms.html b/docs/dev/reference/parms.html new file mode 100644 index 00000000..6a46dad0 --- /dev/null +++ b/docs/dev/reference/parms.html @@ -0,0 +1,292 @@ + + + + + + + + +Extract model parameters from mkinfit models — parms • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function always returns degradation model parameters as well as error +model parameters, in order to avoid working with a fitted model without +considering the error structure that was assumed for the fit.

+
+ +
parms(object, ...)
+
+# S3 method for mkinfit
+parms(object, transformed = FALSE, ...)
+
+# S3 method for mmkin
+parms(object, transformed = FALSE, ...)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

A fitted model object. Methods are implemented for +mkinfit() objects and for mmkin() objects.

...

Not used

transformed

Should the parameters be returned +as used internally during the optimisation?

+ +

Value

+ +

For mkinfit objects, a numeric vector of fitted model parameters. +For mmkin row objects, a matrix with the parameters with a +row for each dataset. If the mmkin object has more than one row, a list of +such matrices is returned.

+ +

Examples

+
# mkinfit objects +fit <- mkinfit("SFO", FOCUS_2006_C, quiet = TRUE) +parms(fit)
#> parent_0 k_parent_sink sigma +#> 82.4921598 0.3060633 4.6730124
parms(fit, transformed = TRUE)
#> parent_0 log_k_parent_sink sigma +#> 82.492160 -1.183963 4.673012
+# mmkin objects +ds <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) subset(x$data[c("name", "time", "value")])) +names(ds) <- paste("Dataset", 6:10) +# \dontrun{ +fits <- mmkin(c("SFO", "FOMC", "DFOP"), ds, quiet = TRUE, cores = 1) +parms(fits["SFO", ])
#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450 +#> k_parent_sink 0.05794659 0.009647805 0.2102974 0.1232258 0.00720421 +#> sigma 5.15274487 7.040168584 3.6769645 6.4669234 6.50457673
parms(fits[, 2])
#> $SFO +#> Dataset 7 +#> parent_0 82.666781678 +#> k_parent_sink 0.009647805 +#> sigma 7.040168584 +#> +#> $FOMC +#> Dataset 7 +#> parent_0 92.6837649 +#> alpha 0.4967832 +#> beta 14.1451255 +#> sigma 1.9167519 +#> +#> $DFOP +#> Dataset 7 +#> parent_0 91.058971503 +#> k1 0.044946770 +#> k2 0.002868336 +#> g 0.526942415 +#> sigma 2.221302196 +#>
parms(fits)
#> $SFO +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 88.52275400 82.666781678 86.8547308 91.7779306 82.14809450 +#> k_parent_sink 0.05794659 0.009647805 0.2102974 0.1232258 0.00720421 +#> sigma 5.15274487 7.040168584 3.6769645 6.4669234 6.50457673 +#> +#> $FOMC +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 95.558575 92.6837649 90.719787 98.383939 94.8481458 +#> alpha 1.338667 0.4967832 1.639099 1.074460 0.2805272 +#> beta 13.033315 14.1451255 5.007077 4.397126 6.9052224 +#> sigma 1.847671 1.9167519 1.066063 3.146056 1.6222778 +#> +#> $DFOP +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 96.55213663 91.058971503 90.34509469 98.14858850 94.311323409 +#> k1 0.21954589 0.044946770 0.41232289 0.31697588 0.080663853 +#> k2 0.02957934 0.002868336 0.07581767 0.03260384 0.003425417 +#> g 0.44845068 0.526942415 0.66091965 0.65322767 0.342652880 +#> sigma 1.35690468 2.221302196 1.34169076 2.87159846 1.942067831 +#>
parms(fits, transformed = TRUE)
#> $SFO +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 88.522754 82.666782 86.854731 91.777931 82.148094 +#> log_k_parent_sink -2.848234 -4.641025 -1.559232 -2.093737 -4.933090 +#> sigma 5.152745 7.040169 3.676964 6.466923 6.504577 +#> +#> $FOMC +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 95.5585751 92.6837649 90.7197870 98.38393896 94.848146 +#> log_alpha 0.2916741 -0.6996015 0.4941466 0.07181817 -1.271085 +#> log_beta 2.5675088 2.6493701 1.6108523 1.48095106 1.932278 +#> sigma 1.8476712 1.9167519 1.0660627 3.14605557 1.622278 +#> +#> $DFOP +#> Dataset 6 Dataset 7 Dataset 8 Dataset 9 Dataset 10 +#> parent_0 96.5521366 91.05897150 90.3450947 98.1485885 94.311323 +#> log_k1 -1.5161940 -3.10227638 -0.8859485 -1.1489296 -2.517465 +#> log_k2 -3.5206791 -5.85402317 -2.5794240 -3.4233253 -5.676532 +#> g_ilr -0.1463234 0.07627854 0.4719196 0.4477805 -0.460676 +#> sigma 1.3569047 2.22130220 1.3416908 2.8715985 1.942068 +#>
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/plot.mkinfit-1.png b/docs/dev/reference/plot.mkinfit-1.png new file mode 100644 index 00000000..c6a415d7 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-1.png differ diff --git a/docs/dev/reference/plot.mkinfit-2.png b/docs/dev/reference/plot.mkinfit-2.png new file mode 100644 index 00000000..5dd3731e Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-2.png differ diff --git a/docs/dev/reference/plot.mkinfit-3.png b/docs/dev/reference/plot.mkinfit-3.png new file mode 100644 index 00000000..59cf8f8d Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-3.png differ diff --git a/docs/dev/reference/plot.mkinfit-4.png b/docs/dev/reference/plot.mkinfit-4.png new file mode 100644 index 00000000..d9867952 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-4.png differ diff --git a/docs/dev/reference/plot.mkinfit-5.png b/docs/dev/reference/plot.mkinfit-5.png new file mode 100644 index 00000000..1109c8df Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-5.png differ diff --git a/docs/dev/reference/plot.mkinfit-6.png b/docs/dev/reference/plot.mkinfit-6.png new file mode 100644 index 00000000..230c90e9 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-6.png differ diff --git a/docs/dev/reference/plot.mkinfit-7.png b/docs/dev/reference/plot.mkinfit-7.png new file mode 100644 index 00000000..b23427b5 Binary files /dev/null and b/docs/dev/reference/plot.mkinfit-7.png differ diff --git a/docs/dev/reference/plot.mkinfit.html b/docs/dev/reference/plot.mkinfit.html new file mode 100644 index 00000000..b9331f1a --- /dev/null +++ b/docs/dev/reference/plot.mkinfit.html @@ -0,0 +1,379 @@ + + + + + + + + +Plot the observed data and the fitted model of an mkinfit object — plot.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Solves the differential equations with the optimised and fixed parameters +from a previous successful call to mkinfit and plots the +observed data together with the solution of the fitted model.

+
+ +
# S3 method for mkinfit
+plot(
+  x,
+  fit = x,
+  obs_vars = names(fit$mkinmod$map),
+  xlab = "Time",
+  ylab = "Observed",
+  xlim = range(fit$data$time),
+  ylim = "default",
+  col_obs = 1:length(obs_vars),
+  pch_obs = col_obs,
+  lty_obs = rep(1, length(obs_vars)),
+  add = FALSE,
+  legend = !add,
+  show_residuals = FALSE,
+  show_errplot = FALSE,
+  maxabs = "auto",
+  sep_obs = FALSE,
+  rel.height.middle = 0.9,
+  row_layout = FALSE,
+  lpos = "topright",
+  inset = c(0.05, 0.05),
+  show_errmin = FALSE,
+  errmin_digits = 3,
+  frame = TRUE,
+  ...
+)
+
+plot_sep(
+  fit,
+  show_errmin = TRUE,
+  show_residuals = ifelse(identical(fit$err_mod, "const"), TRUE, "standardized"),
+  ...
+)
+
+plot_res(
+  fit,
+  sep_obs = FALSE,
+  show_errmin = sep_obs,
+  standardized = ifelse(identical(fit$err_mod, "const"), FALSE, TRUE),
+  ...
+)
+
+plot_err(fit, sep_obs = FALSE, show_errmin = sep_obs, ...)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

Alias for fit introduced for compatibility with the generic S3 +method.

fit

An object of class mkinfit.

obs_vars

A character vector of names of the observed variables for +which the data and the model should be plotted. Defauls to all observed +variables in the model.

xlab

Label for the x axis.

ylab

Label for the y axis.

xlim

Plot range in x direction.

ylim

Plot range in y direction.

col_obs

Colors used for plotting the observed data and the +corresponding model prediction lines.

pch_obs

Symbols to be used for plotting the data.

lty_obs

Line types to be used for the model predictions.

add

Should the plot be added to an existing plot?

legend

Should a legend be added to the plot?

show_residuals

Should residuals be shown? If only one plot of the +fits is shown, the residual plot is in the lower third of the plot. +Otherwise, i.e. if "sep_obs" is given, the residual plots will be located +to the right of the plots of the fitted curves. If this is set to +'standardized', a plot of the residuals divided by the standard deviation +given by the fitted error model will be shown.

show_errplot

Should squared residuals and the error model be shown? +If only one plot of the fits is shown, this plot is in the lower third of +the plot. Otherwise, i.e. if "sep_obs" is given, the residual plots will +be located to the right of the plots of the fitted curves.

maxabs

Maximum absolute value of the residuals. This is used for the +scaling of the y axis and defaults to "auto".

sep_obs

Should the observed variables be shown in separate subplots? +If yes, residual plots requested by "show_residuals" will be shown next +to, not below the plot of the fits.

rel.height.middle

The relative height of the middle plot, if more +than two rows of plots are shown.

row_layout

Should we use a row layout where the residual plot or the +error model plot is shown to the right?

lpos

Position(s) of the legend(s). Passed to legend as +the first argument. If not length one, this should be of the same length +as the obs_var argument.

inset

Passed to legend if applicable.

show_errmin

Should the FOCUS chi2 error value be shown in the upper +margin of the plot?

errmin_digits

The number of significant digits for rounding the FOCUS +chi2 error percentage.

frame

Should a frame be drawn around the plots?

...

Further arguments passed to plot.

standardized

When calling 'plot_res', should the residuals be +standardized in the residual plot?

+ +

Value

+ +

The function is called for its side effect.

+

Details

+ +

If the current plot device is a tikz device, then +latex is being used for the formatting of the chi2 error level, if +show_errmin = TRUE.

+ +

Examples

+
+# One parent compound, one metabolite, both single first order, path from +# parent to sink included +# \dontrun{ +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)
#> Warning: Observations with value of zero were removed from the data
fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE, error_model = "tc")
#> Warning: Observations with value of zero were removed from the data
plot(fit)
plot_res(fit)
plot_res(fit, standardized = FALSE)
plot_err(fit)
+# Show the observed variables separately, with residuals +plot(fit, sep_obs = TRUE, show_residuals = TRUE, lpos = c("topright", "bottomright"), + show_errmin = TRUE)
+# The same can be obtained with less typing, using the convenience function plot_sep +plot_sep(fit, lpos = c("topright", "bottomright"))
+# Show the observed variables separately, with the error model +plot(fit, sep_obs = TRUE, show_errplot = TRUE, lpos = c("topright", "bottomright"), + show_errmin = TRUE)
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/plot.mmkin-1.png b/docs/dev/reference/plot.mmkin-1.png new file mode 100644 index 00000000..8cf969c9 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-1.png differ diff --git a/docs/dev/reference/plot.mmkin-2.png b/docs/dev/reference/plot.mmkin-2.png new file mode 100644 index 00000000..45d67b55 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-2.png differ diff --git a/docs/dev/reference/plot.mmkin-3.png b/docs/dev/reference/plot.mmkin-3.png new file mode 100644 index 00000000..c58b371a Binary files /dev/null and b/docs/dev/reference/plot.mmkin-3.png differ diff --git a/docs/dev/reference/plot.mmkin-4.png b/docs/dev/reference/plot.mmkin-4.png new file mode 100644 index 00000000..47cd7eec Binary files /dev/null and b/docs/dev/reference/plot.mmkin-4.png differ diff --git a/docs/dev/reference/plot.mmkin-5.png b/docs/dev/reference/plot.mmkin-5.png new file mode 100644 index 00000000..44037bb4 Binary files /dev/null and b/docs/dev/reference/plot.mmkin-5.png differ diff --git a/docs/dev/reference/plot.mmkin.html b/docs/dev/reference/plot.mmkin.html new file mode 100644 index 00000000..ca1ec266 --- /dev/null +++ b/docs/dev/reference/plot.mmkin.html @@ -0,0 +1,287 @@ + + + + + + + + +Plot model fits (observed and fitted) and the residuals for a row or column +of an mmkin object — plot.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

When x is a row selected from an mmkin object ([.mmkin), the +same model fitted for at least one dataset is shown. When it is a column, +the fit of at least one model to the same dataset is shown.

+
+ +
# S3 method for mmkin
+plot(
+  x,
+  main = "auto",
+  legends = 1,
+  resplot = c("time", "errmod"),
+  standardized = FALSE,
+  show_errmin = TRUE,
+  errmin_var = "All data",
+  errmin_digits = 3,
+  cex = 0.7,
+  rel.height.middle = 0.9,
+  ymax = "auto",
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

An object of class mmkin, with either one row or one +column.

main

The main title placed on the outer margin of the plot.

legends

An index for the fits for which legends should be shown.

resplot

Should the residuals plotted against time, using +mkinresplot, or as squared residuals against predicted +values, with the error model, using mkinerrplot.

standardized

Should the residuals be standardized? This option +is passed to mkinresplot, it only takes effect if +resplot = "time".

show_errmin

Should the chi2 error level be shown on top of the plots +to the left?

errmin_var

The variable for which the FOCUS chi2 error value should +be shown.

errmin_digits

The number of significant digits for rounding the FOCUS +chi2 error percentage.

cex

Passed to the plot functions and mtext.

rel.height.middle

The relative height of the middle plot, if more +than two rows of plots are shown.

ymax

Maximum y axis value for plot.mkinfit.

...

Further arguments passed to plot.mkinfit and +mkinresplot.

+ +

Value

+ +

The function is called for its side effect.

+

Details

+ +

If the current plot device is a tikz device, then +latex is being used for the formatting of the chi2 error level.

+ +

Examples

+
+ # \dontrun{ + # Only use one core not to offend CRAN checks + fits <- mmkin(c("FOMC", "HS"), + list("FOCUS B" = FOCUS_2006_B, "FOCUS C" = FOCUS_2006_C), # named list for titles + cores = 1, quiet = TRUE, error_model = "tc")
#> Warning: Optimisation did not converge: +#> iteration limit reached without convergence (10)
plot(fits[, "FOCUS C"])
plot(fits["FOMC", ])
plot(fits["FOMC", ], show_errmin = FALSE)
+ # We can also plot a single fit, if we like the way plot.mmkin works, but then the plot + # height should be smaller than the plot width (this is not possible for the html pages + # generated by pkgdown, as far as I know). + plot(fits["FOMC", "FOCUS C"]) # same as plot(fits[1, 2])
+ # Show the error models + plot(fits["FOMC", ], resplot = "errmod")
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/plot.nafta.html b/docs/dev/reference/plot.nafta.html new file mode 100644 index 00000000..dab84955 --- /dev/null +++ b/docs/dev/reference/plot.nafta.html @@ -0,0 +1,210 @@ + + + + + + + + +Plot the results of the three models used in the NAFTA scheme. — plot.nafta • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The plots are ordered with increasing complexity of the model in this +function (SFO, then IORE, then DFOP).

+
+ +
# S3 method for nafta
+plot(x, legend = FALSE, main = "auto", ...)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + +
x

An object of class nafta.

legend

Should a legend be added?

main

Possibility to override the main title of the plot.

...

Further arguments passed to plot.mmkin.

+ +

Value

+ +

The function is called for its side effect.

+

Details

+ +

Calls plot.mmkin.

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/plot.nlme.mmkin-1.png b/docs/dev/reference/plot.nlme.mmkin-1.png new file mode 100644 index 00000000..fe2ef7d3 Binary files /dev/null and b/docs/dev/reference/plot.nlme.mmkin-1.png differ diff --git a/docs/dev/reference/plot.nlme.mmkin-2.png b/docs/dev/reference/plot.nlme.mmkin-2.png new file mode 100644 index 00000000..c82d0271 Binary files /dev/null and b/docs/dev/reference/plot.nlme.mmkin-2.png differ diff --git a/docs/dev/reference/plot.nlme.mmkin.html b/docs/dev/reference/plot.nlme.mmkin.html new file mode 100644 index 00000000..fd40b975 --- /dev/null +++ b/docs/dev/reference/plot.nlme.mmkin.html @@ -0,0 +1,275 @@ + + + + + + + + +Plot a fitted nonlinear mixed model obtained via an mmkin row object — plot.nlme.mmkin • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Plot a fitted nonlinear mixed model obtained via an mmkin row object

+
+ +
# S3 method for nlme.mmkin
+plot(
+  x,
+  i = 1:ncol(x$mmkin_orig),
+  main = "auto",
+  legends = 1,
+  resplot = c("time", "errmod"),
+  standardized = FALSE,
+  show_errmin = TRUE,
+  errmin_var = "All data",
+  errmin_digits = 3,
+  cex = 0.7,
+  rel.height.middle = 0.9,
+  ymax = "auto",
+  ...
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
x

An object of class nlme.mmkin

i

A numeric index to select datasets for which to plot the nlme fit, +in case plots get too large

main

The main title placed on the outer margin of the plot.

legends

An index for the fits for which legends should be shown.

resplot

Should the residuals plotted against time, using +mkinresplot, or as squared residuals against predicted +values, with the error model, using mkinerrplot.

standardized

Should the residuals be standardized? This option +is passed to mkinresplot, it only takes effect if +resplot = "time".

show_errmin

Should the chi2 error level be shown on top of the plots +to the left?

errmin_var

The variable for which the FOCUS chi2 error value should +be shown.

errmin_digits

The number of significant digits for rounding the FOCUS +chi2 error percentage.

cex

Passed to the plot functions and mtext.

rel.height.middle

The relative height of the middle plot, if more +than two rows of plots are shown.

ymax

Maximum y axis value for plot.mkinfit.

...

Further arguments passed to plot.mkinfit and +mkinresplot.

+ +

Value

+ +

The function is called for its side effect.

+ +

Examples

+
ds <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) subset(x$data[c("name", "time", "value")], name == "parent")) +f <- mmkin("SFO", ds, quiet = TRUE, cores = 1) +#plot(f) # too many panels for pkgdown +plot(f[, 3:4])
library(nlme) +f_nlme <- nlme(f) + +#plot(f_nlme) # too many panels for pkgdown +plot(f_nlme, 3:4)
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/print.mkinds.html b/docs/dev/reference/print.mkinds.html new file mode 100644 index 00000000..0539c7da --- /dev/null +++ b/docs/dev/reference/print.mkinds.html @@ -0,0 +1,194 @@ + + + + + + + + +Print mkinds objects — print.mkinds • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Print mkinds objects

+
+ +
# S3 method for mkinds
+print(x, ...)
+ +

Arguments

+ + + + + + + + + + +
x

An mkinds object.

...

Not used.

+ + +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/print.mkinmod.html b/docs/dev/reference/print.mkinmod.html new file mode 100644 index 00000000..fd0f624a --- /dev/null +++ b/docs/dev/reference/print.mkinmod.html @@ -0,0 +1,217 @@ + + + + + + + + +Print mkinmod objects — print.mkinmod • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Print mkinmod objects in a way that the user finds his way to get to its +components.

+
+ +
# S3 method for mkinmod
+print(x, ...)
+ +

Arguments

+ + + + + + + + + + +
x

An mkinmod object.

...

Not used.

+ + +

Examples

+
+ m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), + M1 = list(type = "SFO", to = "M2"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+ print(m_synth_SFO_lin)
#> <mkinmod> model generated with +#> Use of formation fractions $use_of_ff: max +#> Specification $spec: +#> $parent +#> $type: SFO; $to: M1; $sink: TRUE +#> $M1 +#> $type: SFO; $to: M2; $sink: TRUE +#> $M2 +#> $type: SFO; $sink: TRUE +#> Coefficient matrix $coefmat available +#> Compiled model $cf available +#> Differential equations: +#> d_parent/dt = - k_parent * parent +#> d_M1/dt = + f_parent_to_M1 * k_parent * parent - k_M1 * M1 +#> d_M2/dt = + f_M1_to_M2 * k_M1 * M1 - k_M2 * M2
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/reexports.html b/docs/dev/reference/reexports.html new file mode 100644 index 00000000..fe27de4b --- /dev/null +++ b/docs/dev/reference/reexports.html @@ -0,0 +1,190 @@ + + + + + + + + +Objects exported from other packages — reexports • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

These objects are imported from other packages. Follow the links +below to see their documentation.

+ +
lmtest

lrtest

+ + +
+ + + + +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/residuals.mkinfit.html b/docs/dev/reference/residuals.mkinfit.html new file mode 100644 index 00000000..89552630 --- /dev/null +++ b/docs/dev/reference/residuals.mkinfit.html @@ -0,0 +1,204 @@ + + + + + + + + +Extract residuals from an mkinfit model — residuals.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Extract residuals from an mkinfit model

+
+ +
# S3 method for mkinfit
+residuals(object, standardized = FALSE, ...)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

A mkinfit object

standardized

Should the residuals be standardized by dividing by the +standard deviation obtained from the fitted error model?

...

Not used

+ + +

Examples

+
f <- mkinfit("DFOP", FOCUS_2006_C, quiet = TRUE) +residuals(f)
#> [1] 0.09726306 -0.13912135 -0.15351176 0.73388319 -0.08657030 -0.93204730 +#> [7] -0.03269102 1.45347805 -0.88423710
residuals(f, standardized = TRUE)
#> [1] 0.13969820 -0.19981894 -0.22048777 1.05407086 -0.12434027 -1.33869248 +#> [7] -0.04695387 2.08761953 -1.27002305
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/saemix-1.png b/docs/dev/reference/saemix-1.png new file mode 100644 index 00000000..0d79300d Binary files /dev/null and b/docs/dev/reference/saemix-1.png differ diff --git a/docs/dev/reference/saemix-2.png b/docs/dev/reference/saemix-2.png new file mode 100644 index 00000000..04de70b5 Binary files /dev/null and b/docs/dev/reference/saemix-2.png differ diff --git a/docs/dev/reference/saemix.html b/docs/dev/reference/saemix.html new file mode 100644 index 00000000..ad16a81b --- /dev/null +++ b/docs/dev/reference/saemix.html @@ -0,0 +1,446 @@ + + + + + + + + +Create saemix models from mmkin row objects — saemix_model • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function sets up a nonlinear mixed effects model for an mmkin row +object for use with the saemix package. An mmkin row object is essentially a +list of mkinfit objects that have been obtained by fitting the same model to +a list of datasets.

+
+ +
saemix_model(object, cores = parallel::detectCores())
+
+saemix_data(object, ...)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

An mmkin row object containing several fits of the same model to different datasets

cores

The number of cores to be used for multicore processing. +On Windows machines, cores > 1 is currently not supported.

...

Further parameters passed to saemix::saemixData

+ +

Value

+ +

An saemix::SaemixModel object.

+

An saemix::SaemixData object.

+

Details

+ +

Starting values for the fixed effects (population mean parameters, argument psi0 of +saemix::saemixModel() are the mean values of the parameters found using +mmkin. Starting variances of the random effects (argument omega.init) are the +variances of the deviations of the parameters from these mean values.

+ +

Examples

+
ds <- lapply(experimental_data_for_UBA_2019[6:10], + function(x) subset(x$data[c("name", "time", "value")])) +names(ds) <- paste("Dataset", 6:10) +sfo_sfo <- mkinmod(parent = mkinsub("SFO", "A1"), + A1 = mkinsub("SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# \dontrun{ +f_mmkin <- mmkin(list("SFO-SFO" = sfo_sfo), ds, quiet = TRUE) +library(saemix)
#> Package saemix, version 3.1.9000 +#> please direct bugs, questions and feedback to emmanuelle.comets@inserm.fr
m_saemix <- saemix_model(f_mmkin)
#> +#> +#> The following SaemixModel object was successfully created: +#> +#> Nonlinear mixed-effects model +#> Model function: Mixed model generated from mmkin object Model type: structural +#> function (psi, id, xidep) +#> { +#> uid <- unique(id) +#> res_list <- parallel::mclapply(uid, function(i) { +#> transparms_optim <- psi[i, ] +#> names(transparms_optim) <- names(degparms_optim) +#> odeini_optim <- transparms_optim[odeini_optim_parm_names] +#> names(odeini_optim) <- gsub("_0$", "", odeini_optim_parm_names) +#> odeini <- c(odeini_optim, odeini_fixed)[names(mkin_model$diffs)] +#> ode_transparms_optim_names <- setdiff(names(transparms_optim), +#> odeini_optim_parm_names) +#> odeparms_optim <- backtransform_odeparms(transparms_optim[ode_transparms_optim_names], +#> mkin_model, transform_rates = object[[1]]$transform_rates, +#> transform_fractions = object[[1]]$transform_fractions) +#> odeparms <- c(odeparms_optim, odeparms_fixed) +#> xidep_i <- subset(xidep, id == i) +#> if (analytical) { +#> out_values <- mkin_model$deg_func(xidep_i, odeini, +#> odeparms) +#> } +#> else { +#> i_time <- xidep_i$time +#> i_name <- xidep_i$name +#> out_wide <- mkinpredict(mkin_model, odeparms = odeparms, +#> odeini = odeini, solution_type = object[[1]]$solution_type, +#> outtimes = sort(unique(i_time))) +#> out_index <- cbind(as.character(i_time), as.character(i_name)) +#> out_values <- out_wide[out_index] +#> } +#> return(out_values) +#> }, mc.cores = cores) +#> res <- unlist(res_list) +#> return(res) +#> } +#> <bytecode: 0x55555e4213d8> +#> <environment: 0x55555c47cdf0> +#> Nb of parameters: 4 +#> parameter names: parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> distribution: +#> Parameter Distribution Estimated +#> [1,] parent_0 normal Estimated +#> [2,] log_k_parent normal Estimated +#> [3,] log_k_A1 normal Estimated +#> [4,] f_parent_ilr_1 normal Estimated +#> Variance-covariance matrix: +#> parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> parent_0 1 0 0 0 +#> log_k_parent 0 1 0 0 +#> log_k_A1 0 0 1 0 +#> f_parent_ilr_1 0 0 0 1 +#> Error model: constant , initial values: a.1=1 +#> No covariate in the model. +#> Initial values +#> parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> Pop.CondInit 86.53449 -3.207005 -3.060308 -1.920449
d_saemix <- saemix_data(f_mmkin)
#> +#> +#> The following SaemixData object was successfully created: +#> +#> Object of class SaemixData +#> longitudinal data for use with the SAEM algorithm +#> Dataset ds_saemix +#> Structured data: value ~ time + name | ds +#> X variable for graphs: time ()
saemix_options <- list(seed = 123456, + save = FALSE, save.graphs = FALSE, displayProgress = FALSE, + nbiter.saemix = c(200, 80)) +f_saemix <- saemix(m_saemix, d_saemix, saemix_options)
#> Running main SAEM algorithm +#> [1] "Wed May 27 05:55:50 2020" +#> .. +#> Minimisation finished +#> [1] "Wed May 27 06:01:54 2020"
#> Nonlinear mixed-effects model fit by the SAEM algorithm +#> ----------------------------------- +#> ---- Data ---- +#> ----------------------------------- +#> Object of class SaemixData +#> longitudinal data for use with the SAEM algorithm +#> Dataset ds_saemix +#> Structured data: value ~ time + name | ds +#> X variable for graphs: time () +#> Dataset characteristics: +#> number of subjects: 5 +#> number of observations: 170 +#> average/min/max nb obs: 34.00 / 30 / 38 +#> First 10 lines of data: +#> ds time name value mdv cens occ ytype +#> 1 Dataset 6 0 parent 97.2 0 0 1 1 +#> 2 Dataset 6 0 parent 96.4 0 0 1 1 +#> 3 Dataset 6 3 parent 71.1 0 0 1 1 +#> 4 Dataset 6 3 parent 69.2 0 0 1 1 +#> 5 Dataset 6 6 parent 58.1 0 0 1 1 +#> 6 Dataset 6 6 parent 56.6 0 0 1 1 +#> 7 Dataset 6 10 parent 44.4 0 0 1 1 +#> 8 Dataset 6 10 parent 43.4 0 0 1 1 +#> 9 Dataset 6 20 parent 33.3 0 0 1 1 +#> 10 Dataset 6 20 parent 29.2 0 0 1 1 +#> ----------------------------------- +#> ---- Model ---- +#> ----------------------------------- +#> Nonlinear mixed-effects model +#> Model function: Mixed model generated from mmkin object Model type: structural +#> function (psi, id, xidep) +#> { +#> uid <- unique(id) +#> res_list <- parallel::mclapply(uid, function(i) { +#> transparms_optim <- psi[i, ] +#> names(transparms_optim) <- names(degparms_optim) +#> odeini_optim <- transparms_optim[odeini_optim_parm_names] +#> names(odeini_optim) <- gsub("_0$", "", odeini_optim_parm_names) +#> odeini <- c(odeini_optim, odeini_fixed)[names(mkin_model$diffs)] +#> ode_transparms_optim_names <- setdiff(names(transparms_optim), +#> odeini_optim_parm_names) +#> odeparms_optim <- backtransform_odeparms(transparms_optim[ode_transparms_optim_names], +#> mkin_model, transform_rates = object[[1]]$transform_rates, +#> transform_fractions = object[[1]]$transform_fractions) +#> odeparms <- c(odeparms_optim, odeparms_fixed) +#> xidep_i <- subset(xidep, id == i) +#> if (analytical) { +#> out_values <- mkin_model$deg_func(xidep_i, odeini, +#> odeparms) +#> } +#> else { +#> i_time <- xidep_i$time +#> i_name <- xidep_i$name +#> out_wide <- mkinpredict(mkin_model, odeparms = odeparms, +#> odeini = odeini, solution_type = object[[1]]$solution_type, +#> outtimes = sort(unique(i_time))) +#> out_index <- cbind(as.character(i_time), as.character(i_name)) +#> out_values <- out_wide[out_index] +#> } +#> return(out_values) +#> }, mc.cores = cores) +#> res <- unlist(res_list) +#> return(res) +#> } +#> <bytecode: 0x55555e4213d8> +#> <environment: 0x55555c47cdf0> +#> Nb of parameters: 4 +#> parameter names: parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> distribution: +#> Parameter Distribution Estimated +#> [1,] parent_0 normal Estimated +#> [2,] log_k_parent normal Estimated +#> [3,] log_k_A1 normal Estimated +#> [4,] f_parent_ilr_1 normal Estimated +#> Variance-covariance matrix: +#> parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> parent_0 1 0 0 0 +#> log_k_parent 0 1 0 0 +#> log_k_A1 0 0 1 0 +#> f_parent_ilr_1 0 0 0 1 +#> Error model: constant , initial values: a.1=1 +#> No covariate in the model. +#> Initial values +#> parent_0 log_k_parent log_k_A1 f_parent_ilr_1 +#> Pop.CondInit 86.53449 -3.207005 -3.060308 -1.920449 +#> ----------------------------------- +#> ---- Key algorithm options ---- +#> ----------------------------------- +#> Estimation of individual parameters (MAP) +#> Estimation of standard errors and linearised log-likelihood +#> Estimation of log-likelihood by importance sampling +#> Number of iterations: K1=200, K2=80 +#> Number of chains: 10 +#> Seed: 123456 +#> Number of MCMC iterations for IS: 5000 +#> Simulations: +#> nb of simulated datasets used for npde: 1000 +#> nb of simulated datasets used for VPC: 100 +#> Input/output +#> save the results to a file: FALSE +#> save the graphs to files: FALSE +#> ---------------------------------------------------- +#> ---- Results ---- +#> ---------------------------------------------------- +#> ----------------- Fixed effects ------------------ +#> ---------------------------------------------------- +#> Parameter Estimate SE CV(%) +#> [1,] parent_0 86.14 1.61 1.9 +#> [2,] log_k_parent -3.21 0.59 18.5 +#> [3,] log_k_A1 -4.66 0.30 6.4 +#> [4,] f_parent_ilr_1 -0.33 0.30 91.7 +#> [5,] a.1 4.68 0.27 5.8 +#> ---------------------------------------------------- +#> ----------- Variance of random effects ----------- +#> ---------------------------------------------------- +#> Parameter Estimate SE CV(%) +#> parent_0 omega2.parent_0 7.71 8.14 106 +#> log_k_parent omega2.log_k_parent 1.76 1.12 63 +#> log_k_A1 omega2.log_k_A1 0.26 0.26 101 +#> f_parent_ilr_1 omega2.f_parent_ilr_1 0.39 0.28 71 +#> ---------------------------------------------------- +#> ------ Correlation matrix of random effects ------ +#> ---------------------------------------------------- +#> omega2.parent_0 omega2.log_k_parent omega2.log_k_A1 +#> omega2.parent_0 1 0 0 +#> omega2.log_k_parent 0 1 0 +#> omega2.log_k_A1 0 0 1 +#> omega2.f_parent_ilr_1 0 0 0 +#> omega2.f_parent_ilr_1 +#> omega2.parent_0 0 +#> omega2.log_k_parent 0 +#> omega2.log_k_A1 0 +#> omega2.f_parent_ilr_1 1 +#> ---------------------------------------------------- +#> --------------- Statistical criteria ------------- +#> ---------------------------------------------------- +#> Likelihood computed by linearisation +#> -2LL= 1064.364 +#> AIC = 1082.364 +#> BIC = 1078.848 +#> +#> Likelihood computed by importance sampling +#> -2LL= 1063.462 +#> AIC = 1081.462 +#> BIC = 1077.947 +#> ----------------------------------------------------
plot(f_saemix, plot.type = "convergence")
#> Plotting convergence plots
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/schaefer07_complex_case-1.png b/docs/dev/reference/schaefer07_complex_case-1.png new file mode 100644 index 00000000..7cf7484d Binary files /dev/null and b/docs/dev/reference/schaefer07_complex_case-1.png differ diff --git a/docs/dev/reference/schaefer07_complex_case.html b/docs/dev/reference/schaefer07_complex_case.html new file mode 100644 index 00000000..308db2db --- /dev/null +++ b/docs/dev/reference/schaefer07_complex_case.html @@ -0,0 +1,239 @@ + + + + + + + + +Metabolism data set used for checking the software quality of KinGUI — schaefer07_complex_case • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This dataset was used for a comparison of KinGUI and ModelMaker to check the + software quality of KinGUI in the original publication (Schäfer et al., 2007). + The results from the fitting are also included.

+
+ +
schaefer07_complex_case
+ + +

Format

+ +

The data set is a data frame with 8 observations on the following 6 variables.

+
time

a numeric vector

+
parent

a numeric vector

+
A1

a numeric vector

+
B1

a numeric vector

+
C1

a numeric vector

+
A2

a numeric vector

+ +

The results are a data frame with 14 results for different parameter values

+

References

+ +

Schäfer D, Mikolasch B, Rainbird P and Harvey B (2007). KinGUI: a new kinetic + software tool for evaluations according to FOCUS degradation kinetics. In: Del + Re AAM, Capri E, Fragoulis G and Trevisan M (Eds.). Proceedings of the XIII + Symposium Pesticide Chemistry, Piacenza, 2007, p. 916-923.

+ +

Examples

+
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.
# \dontrun{ + fit <- mkinfit(model, data, quiet = TRUE) + plot(fit)
endpoints(fit)
#> $ff +#> parent_A1 parent_B1 parent_C1 parent_sink A1_A2 A1_sink +#> 0.3809619 0.1954667 0.4235714 0.0000000 0.4479609 0.5520391 +#> +#> $distimes +#> DT50 DT90 +#> parent 13.95078 46.34350 +#> A1 49.75343 165.27733 +#> B1 37.26907 123.80517 +#> C1 11.23131 37.30959 +#> A2 28.50638 94.69614 +#>
# } + # Compare with the results obtained in the original publication + print(schaefer07_complex_results)
#> compound parameter KinGUI ModelMaker deviation +#> 1 parent degradation rate 0.0496 0.0506 2.0 +#> 2 parent DT50 13.9900 13.6900 2.2 +#> 3 metabolite A1 formation fraction 0.3803 0.3696 2.9 +#> 4 metabolite A1 degradation rate 0.0139 0.0136 2.2 +#> 5 metabolite A1 DT50 49.9600 50.8900 1.8 +#> 6 metabolite B1 formation fraction 0.1866 0.1818 2.6 +#> 7 metabolite B1 degradation rate 0.0175 0.0172 1.7 +#> 8 metabolite B1 DT50 39.6100 40.2400 1.6 +#> 9 metabolite C1 formation fraction 0.4331 0.4486 3.5 +#> 10 metabolite C1 degradation rate 0.0638 0.0700 8.9 +#> 11 metabolite C1 DT50 10.8700 9.9000 9.8 +#> 12 metabolite A2 formation fraction 0.4529 0.4559 0.7 +#> 13 metabolite A2 degradation rate 0.0245 0.0244 0.4 +#> 14 metabolite A2 DT50 28.2400 28.4500 0.7
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/sigma_twocomp.html b/docs/dev/reference/sigma_twocomp.html new file mode 100644 index 00000000..eac61a11 --- /dev/null +++ b/docs/dev/reference/sigma_twocomp.html @@ -0,0 +1,219 @@ + + + + + + + + +Two-component error model — sigma_twocomp • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Function describing the standard deviation of the measurement error in +dependence of the measured value \(y\):

+
+ +
sigma_twocomp(y, sigma_low, rsd_high)
+ +

Arguments

+ + + + + + + + + + + + + + +
y

The magnitude of the observed value

sigma_low

The asymptotic minimum of the standard deviation for low +observed values

rsd_high

The coefficient describing the increase of the standard +deviation with the magnitude of the observed value

+ +

Value

+ +

The standard deviation of the response variable.

+

Details

+ +

$$\sigma = \sqrt{ \sigma_{low}^2 + y^2 * {rsd}_{high}^2}$$ sigma = +sqrt(sigma_low^2 + y^2 * rsd_high^2)

+

This is the error model used for example by Werner et al. (1978). The model +proposed by Rocke and Lorenzato (1995) can be written in this form as well, +but assumes approximate lognormal distribution of errors for high values of +y.

+

References

+ +

Werner, Mario, Brooks, Samuel H., and Knott, Lancaster B. (1978) +Additive, Multiplicative, and Mixed Analytical Errors. Clinical Chemistry +24(11), 1895-1898.

+

Rocke, David M. and Lorenzato, Stefan (1995) A two-component model for +measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+ +
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/summary.mkinfit.html b/docs/dev/reference/summary.mkinfit.html new file mode 100644 index 00000000..99d7d7c4 --- /dev/null +++ b/docs/dev/reference/summary.mkinfit.html @@ -0,0 +1,337 @@ + + + + + + + + +Summary method for class "mkinfit" — summary.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

Lists model equations, initial parameter values, optimised parameters with +some uncertainty statistics, the chi2 error levels calculated according to +FOCUS guidance (2006) as defined therein, formation fractions, DT50 values +and optionally the data, consisting of observed, predicted and residual +values.

+
+ +
# S3 method for mkinfit
+summary(object, data = TRUE, distimes = TRUE, alpha = 0.05, ...)
+
+# S3 method for summary.mkinfit
+print(x, digits = max(3, getOption("digits") - 3), ...)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
object

an object of class mkinfit.

data

logical, indicating whether the data should be included in the +summary.

distimes

logical, indicating whether DT50 and DT90 values should be +included.

alpha

error level for confidence interval estimation from t +distribution

...

optional arguments passed to methods like print.

x

an object of class summary.mkinfit.

digits

Number of digits to use for printing

+ +

Value

+ +

The summary function returns a list with components, among others

+
version, Rversion

The mkin and R versions used

+
date.fit, date.summary

The dates where the fit and the summary were +produced

+
diffs

The differential equations used in the model

+
use_of_ff

Was maximum or minimum use made of formation fractions

+
bpar

Optimised and backtransformed +parameters

+
data

The data (see Description above).

+
start

The starting values and bounds, if applicable, for optimised +parameters.

+
fixed

The values of fixed parameters.

+
errmin

The chi2 error levels for +each observed variable.

+
bparms.ode

All backtransformed ODE +parameters, for use as starting parameters for related models.

+
errparms

Error model parameters.

+
ff

The estimated formation fractions derived from the fitted +model.

+
distimes

The DT50 and DT90 values for each observed variable.

+
SFORB

If applicable, eigenvalues of SFORB components of the model.

+The print method is called for its side effect, i.e. printing the summary. + +

References

+ +

FOCUS (2006) “Guidance Document on Estimating Persistence +and Degradation Kinetics from Environmental Fate Studies on Pesticides in +EU Registration” Report of the FOCUS Work Group on Degradation Kinetics, +EC Document Reference Sanco/10058/2005 version 2.0, 434 pp, +http://esdac.jrc.ec.europa.eu/projects/degradation-kinetics

+ +

Examples

+
+ summary(mkinfit(mkinmod(parent = mkinsub("SFO")), FOCUS_2006_A, quiet = TRUE))
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 06:02:05 2020 +#> Date of summary: Wed May 27 06:02:05 2020 +#> +#> Equations: +#> d_parent/dt = - k_parent * parent +#> +#> Model predictions using solution type analytical +#> +#> Fitted using 131 model solutions performed in 0.027 s +#> +#> Error model: Constant variance +#> +#> Error model algorithm: OLS +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 101.24 state +#> k_parent 0.10 deparm +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 101.240000 -Inf Inf +#> log_k_parent -2.302585 -Inf Inf +#> +#> Fixed parameter values: +#> None +#> +#> Results: +#> +#> AIC BIC logLik +#> 55.28197 55.5203 -24.64099 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 109.200 3.70400 99.630 118.700 +#> log_k_parent -3.291 0.09176 -3.527 -3.055 +#> sigma 5.266 1.31600 1.882 8.649 +#> +#> Parameter correlation: +#> parent_0 log_k_parent sigma +#> parent_0 1.000e+00 5.428e-01 1.648e-07 +#> log_k_parent 5.428e-01 1.000e+00 2.513e-07 +#> sigma 1.648e-07 2.513e-07 1.000e+00 +#> +#> 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 109.20000 29.47 4.218e-07 99.6300 118.70000 +#> k_parent 0.03722 10.90 5.650e-05 0.0294 0.04712 +#> sigma 5.26600 4.00 5.162e-03 1.8820 8.64900 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 8.385 2 6 +#> parent 8.385 2 6 +#> +#> Estimated disappearance times: +#> DT50 DT90 +#> parent 18.62 61.87 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 101.24 109.153 -7.9132 +#> 3 parent 99.27 97.622 1.6484 +#> 7 parent 90.11 84.119 5.9913 +#> 14 parent 72.19 64.826 7.3641 +#> 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
+
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/synthetic_data_for_UBA_2014-1.png b/docs/dev/reference/synthetic_data_for_UBA_2014-1.png new file mode 100644 index 00000000..02976ced Binary files /dev/null and b/docs/dev/reference/synthetic_data_for_UBA_2014-1.png differ diff --git a/docs/dev/reference/synthetic_data_for_UBA_2014.html b/docs/dev/reference/synthetic_data_for_UBA_2014.html new file mode 100644 index 00000000..da4af114 --- /dev/null +++ b/docs/dev/reference/synthetic_data_for_UBA_2014.html @@ -0,0 +1,470 @@ + + + + + + + + +Synthetic datasets for one parent compound with two metabolites — synthetic_data_for_UBA_2014 • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The 12 datasets were generated using four different models and three different + variance components. The four models are either the SFO or the DFOP model with either + two sequential or two parallel metabolites.

+

Variance component 'a' is based on a normal distribution with standard deviation of 3, + Variance component 'b' is also based on a normal distribution, but with a standard deviation of 7. + Variance component 'c' is based on the error model from Rocke and Lorenzato (1995), with the + minimum standard deviation (for small y values) of 0.5, and a proportionality constant of 0.07 + for the increase of the standard deviation with y. Note that this is a simplified version + of the error model proposed by Rocke and Lorenzato (1995), as in their model the error of the + measured values approximates lognormal distribution for high values, whereas we are using + normally distributed error components all along.

+

Initial concentrations for metabolites and all values where adding the variance component resulted + in a value below the assumed limit of detection of 0.1 were set to NA.

+

As an example, the first dataset has the title SFO_lin_a and is based on the SFO model + with two sequential metabolites (linear pathway), with added variance component 'a'.

+

Compare also the code in the example section to see the degradation models.

+
+ +
synthetic_data_for_UBA_2014
+ + +

Format

+ +

A list containing twelve datasets as an R6 class defined by mkinds, + each containing, among others, the following components

+
title

The name of the dataset, e.g. SFO_lin_a

+
data

A data frame with the data in the form expected by mkinfit

+ + + +

Source

+ +

Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative + zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452

+

Rocke, David M. und Lorenzato, Stefan (1995) A two-component model for + measurement error in analytical chemistry. Technometrics 37(2), 176-184.

+ +

Examples

+
# \dontrun{ +# The data have been generated using the following kinetic models +m_synth_SFO_lin <- mkinmod(parent = list(type = "SFO", to = "M1"), + M1 = list(type = "SFO", to = "M2"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+ +m_synth_SFO_par <- mkinmod(parent = list(type = "SFO", to = c("M1", "M2"), + sink = FALSE), + M1 = list(type = "SFO"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+m_synth_DFOP_lin <- mkinmod(parent = list(type = "DFOP", to = "M1"), + M1 = list(type = "SFO", to = "M2"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+m_synth_DFOP_par <- mkinmod(parent = list(type = "DFOP", to = c("M1", "M2"), + sink = FALSE), + M1 = list(type = "SFO"), + M2 = list(type = "SFO"), use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+# The model predictions without intentional error were generated as follows +sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120) + +d_synth_SFO_lin <- mkinpredict(m_synth_SFO_lin, + c(k_parent = 0.7, f_parent_to_M1 = 0.8, + k_M1 = 0.3, f_M1_to_M2 = 0.7, + k_M2 = 0.02), + c(parent = 100, M1 = 0, M2 = 0), + sampling_times) + +d_synth_DFOP_lin <- mkinpredict(m_synth_DFOP_lin, + c(k1 = 0.2, k2 = 0.02, g = 0.5, + f_parent_to_M1 = 0.5, k_M1 = 0.3, + f_M1_to_M2 = 0.7, k_M2 = 0.02), + c(parent = 100, M1 = 0, M2 = 0), + sampling_times) + +d_synth_SFO_par <- mkinpredict(m_synth_SFO_par, + c(k_parent = 0.2, + f_parent_to_M1 = 0.8, k_M1 = 0.01, + f_parent_to_M2 = 0.2, k_M2 = 0.02), + c(parent = 100, M1 = 0, M2 = 0), + sampling_times) + +d_synth_DFOP_par <- mkinpredict(m_synth_DFOP_par, + c(k1 = 0.3, k2 = 0.02, g = 0.7, + f_parent_to_M1 = 0.6, k_M1 = 0.04, + f_parent_to_M2 = 0.4, k_M2 = 0.01), + c(parent = 100, M1 = 0, M2 = 0), + sampling_times) + +# Construct names for datasets with errors +d_synth_names = paste0("d_synth_", c("SFO_lin", "SFO_par", + "DFOP_lin", "DFOP_par")) + +# Original function used or adding errors. The add_err function now published +# with this package is a slightly generalised version where the names of +# secondary compartments that should have an initial value of zero (M1 and M2 +# in this case) are not hardcoded any more. +# add_err = function(d, sdfunc, LOD = 0.1, reps = 2, seed = 123456789) +# { +# set.seed(seed) +# d_long = mkin_wide_to_long(d, time = "time") +# d_rep = data.frame(lapply(d_long, rep, each = 2)) +# d_rep$value = rnorm(length(d_rep$value), d_rep$value, sdfunc(d_rep$value)) +# +# d_rep[d_rep$time == 0 & d_rep$name %in% c("M1", "M2"), "value"] <- 0 +# d_NA <- transform(d_rep, value = ifelse(value < LOD, NA, value)) +# d_NA$value <- round(d_NA$value, 1) +# return(d_NA) +# } + +# The following is the simplified version of the two-component model of Rocke +# and Lorenzato (1995) +sdfunc_twocomp = function(value, sd_low, rsd_high) { + sqrt(sd_low^2 + value^2 * rsd_high^2) +} + +# Add the errors. +for (d_synth_name in d_synth_names) +{ + d_synth = get(d_synth_name) + assign(paste0(d_synth_name, "_a"), add_err(d_synth, function(value) 3)) + assign(paste0(d_synth_name, "_b"), add_err(d_synth, function(value) 7)) + assign(paste0(d_synth_name, "_c"), add_err(d_synth, + function(value) sdfunc_twocomp(value, 0.5, 0.07))) + +} + +d_synth_err_names = c( + paste(rep(d_synth_names, each = 3), letters[1:3], sep = "_") +) + +# This is just one example of an evaluation using the kinetic model used for +# the generation of the data + fit <- mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data, + quiet = TRUE) + plot_sep(fit)
summary(fit)
#> mkin version used for fitting: 0.9.50.3 +#> R version used for fitting: 4.0.0 +#> Date of fit: Wed May 27 06:02:14 2020 +#> Date of summary: Wed May 27 06:02:14 2020 +#> +#> Equations: +#> d_parent/dt = - k_parent * parent +#> d_M1/dt = + f_parent_to_M1 * k_parent * parent - k_M1 * M1 +#> d_M2/dt = + f_M1_to_M2 * k_M1 * M1 - k_M2 * M2 +#> +#> Model predictions using solution type deSolve +#> +#> Fitted using 817 model solutions performed in 0.623 s +#> +#> Error model: Constant variance +#> +#> Error model algorithm: OLS +#> +#> Starting values for parameters to be optimised: +#> value type +#> parent_0 101.3500 state +#> k_parent 0.1000 deparm +#> k_M1 0.1001 deparm +#> k_M2 0.1002 deparm +#> f_parent_to_M1 0.5000 deparm +#> f_M1_to_M2 0.5000 deparm +#> +#> Starting values for the transformed parameters actually optimised: +#> value lower upper +#> parent_0 101.350000 -Inf Inf +#> log_k_parent -2.302585 -Inf Inf +#> log_k_M1 -2.301586 -Inf Inf +#> log_k_M2 -2.300587 -Inf Inf +#> f_parent_ilr_1 0.000000 -Inf Inf +#> f_M1_ilr_1 0.000000 -Inf Inf +#> +#> Fixed parameter values: +#> value type +#> M1_0 0 state +#> M2_0 0 state +#> +#> Results: +#> +#> AIC BIC logLik +#> 188.7274 200.3723 -87.36368 +#> +#> Optimised, transformed parameters with symmetric confidence intervals: +#> Estimate Std. Error Lower Upper +#> parent_0 102.1000 1.57000 98.8600 105.3000 +#> log_k_parent -0.3020 0.03885 -0.3812 -0.2229 +#> log_k_M1 -1.2070 0.07123 -1.3520 -1.0620 +#> log_k_M2 -3.9010 0.06571 -4.0350 -3.7670 +#> f_parent_ilr_1 0.8492 0.16640 0.5103 1.1880 +#> f_M1_ilr_1 0.6780 0.17600 0.3196 1.0360 +#> sigma 2.2730 0.25740 1.7490 2.7970 +#> +#> Parameter correlation: +#> parent_0 log_k_parent log_k_M1 log_k_M2 f_parent_ilr_1 +#> parent_0 1.000e+00 3.933e-01 -1.605e-01 2.819e-02 -4.624e-01 +#> log_k_parent 3.933e-01 1.000e+00 -4.082e-01 7.166e-02 -5.682e-01 +#> log_k_M1 -1.605e-01 -4.082e-01 1.000e+00 -3.929e-01 7.478e-01 +#> log_k_M2 2.819e-02 7.166e-02 -3.929e-01 1.000e+00 -2.658e-01 +#> f_parent_ilr_1 -4.624e-01 -5.682e-01 7.478e-01 -2.658e-01 1.000e+00 +#> f_M1_ilr_1 1.614e-01 4.102e-01 -8.109e-01 5.419e-01 -8.605e-01 +#> sigma -1.384e-07 -2.581e-07 9.499e-08 1.518e-07 1.236e-07 +#> f_M1_ilr_1 sigma +#> parent_0 1.614e-01 -1.384e-07 +#> log_k_parent 4.102e-01 -2.581e-07 +#> log_k_M1 -8.109e-01 9.499e-08 +#> log_k_M2 5.419e-01 1.518e-07 +#> f_parent_ilr_1 -8.605e-01 1.236e-07 +#> f_M1_ilr_1 1.000e+00 8.795e-09 +#> sigma 8.795e-09 1.000e+00 +#> +#> 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 102.10000 65.000 7.281e-36 98.86000 105.30000 +#> k_parent 0.73930 25.740 2.948e-23 0.68310 0.80020 +#> k_M1 0.29920 14.040 1.577e-15 0.25880 0.34590 +#> k_M2 0.02023 15.220 1.653e-16 0.01769 0.02312 +#> f_parent_to_M1 0.76870 18.370 7.295e-19 0.67300 0.84290 +#> f_M1_to_M2 0.72290 14.500 6.418e-16 0.61110 0.81240 +#> sigma 2.27300 8.832 2.161e-10 1.74900 2.79700 +#> +#> FOCUS Chi2 error levels in percent: +#> err.min n.optim df +#> All data 8.454 6 17 +#> parent 8.660 2 6 +#> M1 10.583 2 5 +#> M2 3.586 2 6 +#> +#> Resulting formation fractions: +#> ff +#> parent_M1 0.7687 +#> parent_sink 0.2313 +#> M1_M2 0.7229 +#> M1_sink 0.2771 +#> +#> Estimated disappearance times: +#> DT50 DT90 +#> parent 0.9376 3.114 +#> M1 2.3170 7.697 +#> M2 34.2689 113.839 +#> +#> Data: +#> time variable observed predicted residual +#> 0 parent 101.5 1.021e+02 -0.56248 +#> 0 parent 101.2 1.021e+02 -0.86248 +#> 1 parent 53.9 4.873e+01 5.17118 +#> 1 parent 47.5 4.873e+01 -1.22882 +#> 3 parent 10.4 1.111e+01 -0.70773 +#> 3 parent 7.6 1.111e+01 -3.50773 +#> 7 parent 1.1 5.772e-01 0.52283 +#> 7 parent 0.3 5.772e-01 -0.27717 +#> 14 parent 3.5 3.264e-03 3.49674 +#> 28 parent 3.2 1.045e-07 3.20000 +#> 90 parent 0.6 9.535e-10 0.60000 +#> 120 parent 3.5 -5.941e-10 3.50000 +#> 1 M1 36.4 3.479e+01 1.61088 +#> 1 M1 37.4 3.479e+01 2.61088 +#> 3 M1 34.3 3.937e+01 -5.07027 +#> 3 M1 39.8 3.937e+01 0.42973 +#> 7 M1 15.1 1.549e+01 -0.38715 +#> 7 M1 17.8 1.549e+01 2.31285 +#> 14 M1 5.8 1.995e+00 3.80469 +#> 14 M1 1.2 1.995e+00 -0.79531 +#> 60 M1 0.5 2.111e-06 0.50000 +#> 90 M1 3.2 -9.676e-10 3.20000 +#> 120 M1 1.5 7.671e-10 1.50000 +#> 120 M1 0.6 7.671e-10 0.60000 +#> 1 M2 4.8 4.455e+00 0.34517 +#> 3 M2 20.9 2.153e+01 -0.62527 +#> 3 M2 19.3 2.153e+01 -2.22527 +#> 7 M2 42.0 4.192e+01 0.07941 +#> 7 M2 43.1 4.192e+01 1.17941 +#> 14 M2 49.4 4.557e+01 3.83353 +#> 14 M2 44.3 4.557e+01 -1.26647 +#> 28 M2 34.6 3.547e+01 -0.87275 +#> 28 M2 33.0 3.547e+01 -2.47275 +#> 60 M2 18.8 1.858e+01 0.21837 +#> 60 M2 17.6 1.858e+01 -0.98163 +#> 90 M2 10.6 1.013e+01 0.47130 +#> 90 M2 10.8 1.013e+01 0.67130 +#> 120 M2 9.8 5.521e+00 4.27893 +#> 120 M2 3.3 5.521e+00 -2.22107
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/test_data_from_UBA_2014-1.png b/docs/dev/reference/test_data_from_UBA_2014-1.png new file mode 100644 index 00000000..431181cf Binary files /dev/null and b/docs/dev/reference/test_data_from_UBA_2014-1.png differ diff --git a/docs/dev/reference/test_data_from_UBA_2014-2.png b/docs/dev/reference/test_data_from_UBA_2014-2.png new file mode 100644 index 00000000..4a064163 Binary files /dev/null and b/docs/dev/reference/test_data_from_UBA_2014-2.png differ diff --git a/docs/dev/reference/test_data_from_UBA_2014.html b/docs/dev/reference/test_data_from_UBA_2014.html new file mode 100644 index 00000000..291e3959 --- /dev/null +++ b/docs/dev/reference/test_data_from_UBA_2014.html @@ -0,0 +1,251 @@ + + + + + + + + +Three experimental datasets from two water sediment systems and one soil — test_data_from_UBA_2014 • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The datasets were used for the comparative validation of several kinetic evaluation + software packages (Ranke, 2014).

+
+ +
test_data_from_UBA_2014
+ + +

Format

+ +

A list containing three datasets as an R6 class defined by mkinds. + Each dataset has, among others, the following components

+
title

The name of the dataset, e.g. UBA_2014_WS_river

+
data

A data frame with the data in the form expected by mkinfit

+ + + +

Source

+ +

Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative + zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452

+ +

Examples

+
# \dontrun{ + # This is a level P-II evaluation of the dataset according to the FOCUS kinetics + # guidance. Due to the strong correlation of the parameter estimates, the + # covariance matrix is not returned. Note that level P-II evaluations are + # generally considered deprecated due to the frequent occurrence of such + # large parameter correlations, among other reasons (e.g. the adequacy of the + # model). + m_ws <- mkinmod(parent_w = mkinsub("SFO", "parent_s"), + parent_s = mkinsub("SFO", "parent_w"))
#> Successfully compiled differential equation model from auto-generated C code.
f_river <- mkinfit(m_ws, test_data_from_UBA_2014[[1]]$data, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
plot_sep(f_river)
+ summary(f_river)$bpar
#> Warning: Could not calculate correlation; no covariance matrix
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_w_0 95.91998116 NA NA NA NA NA +#> k_parent_w 0.41145375 NA NA NA NA NA +#> k_parent_s 0.04663944 NA NA NA NA NA +#> f_parent_w_to_parent_s 0.12467894 NA NA NA NA NA +#> f_parent_s_to_parent_w 0.50000000 NA NA NA NA NA +#> sigma 3.13612618 NA NA NA NA NA
mkinerrmin(f_river)
#> err.min n.optim df +#> All data 0.1090929 5 6 +#> parent_w 0.0817436 3 3 +#> parent_s 0.1619965 2 3
+ # This is the evaluation used for the validation of software packages + # in the expertise from 2014 + m_soil <- mkinmod(parent = mkinsub("SFO", c("M1", "M2")), + M1 = mkinsub("SFO", "M3"), + M2 = mkinsub("SFO", "M3"), + M3 = mkinsub("SFO"), + use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+ f_soil <- mkinfit(m_soil, test_data_from_UBA_2014[[3]]$data, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
plot_sep(f_soil, lpos = c("topright", "topright", "topright", "bottomright"))
summary(f_soil)$bpar
#> Estimate se_notrans t value Pr(>t) Lower +#> parent_0 76.55425584 0.859186419 89.1008681 1.113862e-26 74.755958720 +#> k_parent 0.12081956 0.004601919 26.2541703 1.077361e-16 0.111561576 +#> k_M1 0.84258629 0.806165149 1.0451783 1.545282e-01 0.113778910 +#> k_M2 0.04210878 0.017083049 2.4649452 1.170195e-02 0.018013823 +#> k_M3 0.01122919 0.007245870 1.5497364 6.885076e-02 0.002909418 +#> f_parent_to_M1 0.32240193 0.240785518 1.3389590 9.819221e-02 NA +#> f_parent_to_M2 0.16099854 0.033691991 4.7785404 6.531224e-05 NA +#> f_M1_to_M3 0.27921506 0.269425582 1.0363346 1.565282e-01 0.022977955 +#> f_M2_to_M3 0.55641331 0.595121774 0.9349571 1.807710e-01 0.008002320 +#> sigma 1.14005399 0.149696423 7.6157731 1.727024e-07 0.826735778 +#> Upper +#> parent_0 78.35255297 +#> k_parent 0.13084582 +#> k_M1 6.23974738 +#> k_M2 0.09843271 +#> k_M3 0.04334017 +#> f_parent_to_M1 NA +#> f_parent_to_M2 NA +#> f_M1_to_M3 0.86450905 +#> f_M2_to_M3 0.99489911 +#> sigma 1.45337221
mkinerrmin(f_soil)
#> err.min n.optim df +#> All data 0.09649963 9 20 +#> parent 0.04721283 2 6 +#> M1 0.26551208 2 5 +#> M2 0.20327575 2 5 +#> M3 0.05196550 3 4
# } +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/transform_odeparms.html b/docs/dev/reference/transform_odeparms.html new file mode 100644 index 00000000..d0858eda --- /dev/null +++ b/docs/dev/reference/transform_odeparms.html @@ -0,0 +1,319 @@ + + + + + + + + +Functions to transform and backtransform kinetic parameters for fitting — transform_odeparms • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

The transformations are intended to map parameters that should only take on +restricted values to the full scale of real numbers. For kinetic rate +constants and other parameters 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 ilr transformation is used.

+
+ +
transform_odeparms(
+  parms,
+  mkinmod,
+  transform_rates = TRUE,
+  transform_fractions = TRUE
+)
+
+backtransform_odeparms(
+  transparms,
+  mkinmod,
+  transform_rates = TRUE,
+  transform_fractions = TRUE
+)
+ +

Arguments

+ + + + + + + + + + + + + + + + + + + + + + +
parms

Parameters of kinetic models as used in the differential +equations.

mkinmod

The kinetic model of class mkinmod, containing +the names of the model variables that are needed for grouping the +formation fractions before ilr transformation, the parameter +names and the information if the pathway to sink is included in the model.

transform_rates

Boolean specifying if kinetic rate constants should +be transformed in the model specification used in the fitting for better +compliance with the assumption of normal distribution of the estimator. If +TRUE, also alpha and beta parameters of the FOMC model are +log-transformed, as well as k1 and k2 rate constants for the DFOP and HS +models and the break point tb of the HS model.

transform_fractions

Boolean specifying if formation fractions +constants should be transformed in the model specification used in the +fitting for better compliance with the assumption of normal distribution +of the estimator. The default (TRUE) is to do transformations. 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 ilr transformation.

transparms

Transformed parameters of kinetic models as used in the +fitting procedure.

+ +

Value

+ +

A vector of transformed or backtransformed parameters

+

Details

+ +

The transformation of sets of formation fractions is fragile, as it supposes +the same ordering of the components in forward and backward transformation. +This is no problem for the internal use in mkinfit.

+ +

Examples

+
+SFO_SFO <- mkinmod( + parent = list(type = "SFO", to = "m1", sink = TRUE), + m1 = list(type = "SFO"))
#> Successfully compiled differential equation model from auto-generated C code.
# Fit the model to the FOCUS example dataset D using defaults +fit <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit.s <- summary(fit) +# Transformed and backtransformed parameters +print(fit.s$par, 3)
#> Estimate Std. Error Lower Upper +#> parent_0 99.598 1.5702 96.4038 102.793 +#> log_k_parent -2.316 0.0409 -2.3988 -2.233 +#> log_k_m1 -5.248 0.1332 -5.5184 -4.977 +#> f_parent_ilr_1 0.041 0.0631 -0.0875 0.169 +#> sigma 3.126 0.3585 2.3961 3.855
print(fit.s$bpar, 3)
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_0 99.59848 1.57022 63.43 2.30e-36 96.40384 102.7931 +#> k_parent 0.09870 0.00403 24.47 4.96e-23 0.09082 0.1073 +#> k_m1 0.00526 0.00070 7.51 6.16e-09 0.00401 0.0069 +#> f_parent_to_m1 0.51448 0.02230 23.07 3.10e-22 0.46912 0.5596 +#> sigma 3.12550 0.35852 8.72 2.24e-10 2.39609 3.8549
+# \dontrun{ +# Compare to the version without transforming rate parameters +fit.2 <- mkinfit(SFO_SFO, FOCUS_2006_D, transform_rates = FALSE, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
#> Error in if (cost < cost.current) { assign("cost.current", cost, inherits = TRUE) if (!quiet) cat(ifelse(OLS, "Sum of squared residuals", "Negative log-likelihood"), " at call ", calls, ": ", cost.current, "\n", sep = "")}: missing value where TRUE/FALSE needed
#> Timing stopped at: 0.003 0 0.003
fit.2.s <- summary(fit.2)
#> Error in summary(fit.2): object 'fit.2' not found
print(fit.2.s$par, 3)
#> Error in print(fit.2.s$par, 3): object 'fit.2.s' not found
print(fit.2.s$bpar, 3)
#> Error in print(fit.2.s$bpar, 3): object 'fit.2.s' not found
# } + +initials <- fit$start$value +names(initials) <- rownames(fit$start) +transformed <- fit$start_transformed$value +names(transformed) <- rownames(fit$start_transformed) +transform_odeparms(initials, SFO_SFO)
#> parent_0 log_k_parent log_k_m1 f_parent_ilr_1 +#> 100.750000 -2.302585 -2.301586 0.000000
backtransform_odeparms(transformed, SFO_SFO)
#> parent_0 k_parent k_m1 f_parent_to_m1 +#> 100.7500 0.1000 0.1001 0.5000
+# \dontrun{ +# The case of formation fractions +SFO_SFO.ff <- mkinmod( + parent = list(type = "SFO", to = "m1", sink = TRUE), + m1 = list(type = "SFO"), + use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit.ff.s <- summary(fit.ff) +print(fit.ff.s$par, 3)
#> Estimate Std. Error Lower Upper +#> parent_0 99.598 1.5702 96.4038 102.793 +#> log_k_parent -2.316 0.0409 -2.3988 -2.233 +#> log_k_m1 -5.248 0.1332 -5.5184 -4.977 +#> f_parent_ilr_1 0.041 0.0631 -0.0875 0.169 +#> sigma 3.126 0.3585 2.3961 3.855
print(fit.ff.s$bpar, 3)
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_0 99.59848 1.57022 63.43 2.30e-36 96.40384 102.7931 +#> k_parent 0.09870 0.00403 24.47 4.96e-23 0.09082 0.1073 +#> k_m1 0.00526 0.00070 7.51 6.16e-09 0.00401 0.0069 +#> f_parent_to_m1 0.51448 0.02230 23.07 3.10e-22 0.46912 0.5596 +#> sigma 3.12550 0.35852 8.72 2.24e-10 2.39609 3.8549
initials <- c("f_parent_to_m1" = 0.5) +transformed <- transform_odeparms(initials, SFO_SFO.ff) +backtransform_odeparms(transformed, SFO_SFO.ff)
#> f_parent_to_m1 +#> 0.5
+# And without sink +SFO_SFO.ff.2 <- mkinmod( + parent = list(type = "SFO", to = "m1", sink = FALSE), + m1 = list(type = "SFO"), + use_of_ff = "max")
#> Successfully compiled differential equation model from auto-generated C code.
+ +fit.ff.2 <- mkinfit(SFO_SFO.ff.2, FOCUS_2006_D, quiet = TRUE)
#> Warning: Observations with value of zero were removed from the data
fit.ff.2.s <- summary(fit.ff.2) +print(fit.ff.2.s$par, 3)
#> Estimate Std. Error Lower Upper +#> parent_0 84.79 3.012 78.67 90.91 +#> log_k_parent -2.76 0.082 -2.92 -2.59 +#> log_k_m1 -4.21 0.123 -4.46 -3.96 +#> sigma 8.22 0.943 6.31 10.14
print(fit.ff.2.s$bpar, 3)
#> Estimate se_notrans t value Pr(>t) Lower Upper +#> parent_0 84.7916 3.01203 28.15 1.92e-25 78.6704 90.913 +#> k_parent 0.0635 0.00521 12.19 2.91e-14 0.0538 0.075 +#> k_m1 0.0148 0.00182 8.13 8.81e-10 0.0115 0.019 +#> sigma 8.2229 0.94323 8.72 1.73e-10 6.3060 10.140
# } + +
+
+ +
+ + +
+ + +
+

Site built with pkgdown 1.5.1.

+
+ +
+
+ + + + + + + + diff --git a/docs/dev/reference/update.mkinfit-1.png b/docs/dev/reference/update.mkinfit-1.png new file mode 100644 index 00000000..4cbefa56 Binary files /dev/null and b/docs/dev/reference/update.mkinfit-1.png differ diff --git a/docs/dev/reference/update.mkinfit-2.png b/docs/dev/reference/update.mkinfit-2.png new file mode 100644 index 00000000..f432f6f8 Binary files /dev/null and b/docs/dev/reference/update.mkinfit-2.png differ diff --git a/docs/dev/reference/update.mkinfit.html b/docs/dev/reference/update.mkinfit.html new file mode 100644 index 00000000..d6363edf --- /dev/null +++ b/docs/dev/reference/update.mkinfit.html @@ -0,0 +1,214 @@ + + + + + + + + +Update an mkinfit model with different arguments — update.mkinfit • mkin + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + +
+ +
+
+ + +
+

This function will return an updated mkinfit object. The fitted degradation +model parameters from the old fit are used as starting values for the +updated fit. Values specified as 'parms.ini' and/or 'state.ini' will +override these starting values.

+
+ +
# S3 method for mkinfit
+update(object, ..., evaluate = TRUE)
+ +

Arguments

+ + + + + + + + + + + + + + +
object

An mkinfit object to be updated

...

Arguments to mkinfit that should replace +the arguments from the original call. Arguments set to NULL will +remove arguments given in the original call

evaluate

Should the call be evaluated or returned as a call

+ + +

Examples

+
# \dontrun{ +fit <- mkinfit("SFO", subset(FOCUS_2006_D, value != 0), quiet = TRUE) +parms(fit)
#> parent_0 k_parent_sink sigma +#> 99.44423886 0.09793574 3.39632469
fit_2 <- update(fit, error_model = "tc") +parms(fit_2)
#> parent_0 k_parent_sink sigma_low rsd_high +#> 1.008549e+02 1.005665e-01 3.752222e-03 6.763434e-02
plot_err(fit_2)
# } +
+
+ +
+ + + +
+ + + + + + + + -- cgit v1.2.1