aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS.md2
-rw-r--r--data/synthetic_data_for_UBA_2014.RDatabin0 -> 2243 bytes
-rw-r--r--man/synthetic_data_for_UBA.Rd65
-rw-r--r--tests/testthat/test_FOCUS_D_UBA_expertise.R2
-rw-r--r--tests/testthat/test_synthetic_data_for_UBA_2014.R67
5 files changed, 135 insertions, 1 deletions
diff --git a/NEWS.md b/NEWS.md
index cc9f28f9..c0874a6e 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -15,6 +15,8 @@
- `mkinfit()`: Report successful termination when quiet = FALSE. This is helpful for more difficult problems fitted with reweight.method = obs, as no progress is often indicated during the reweighting.
- A first test using results established in the expertise written for the German Federal Environmental Agency (UBA) was added.
+- Add synthetic datasets generated for expertise written for the German Federal Environmental Agency UBA
+- Add tests based on these datasets
# CHANGES in mkin VERSION 0.9-34
diff --git a/data/synthetic_data_for_UBA_2014.RData b/data/synthetic_data_for_UBA_2014.RData
new file mode 100644
index 00000000..12132c97
--- /dev/null
+++ b/data/synthetic_data_for_UBA_2014.RData
Binary files differ
diff --git a/man/synthetic_data_for_UBA.Rd b/man/synthetic_data_for_UBA.Rd
new file mode 100644
index 00000000..5d924afd
--- /dev/null
+++ b/man/synthetic_data_for_UBA.Rd
@@ -0,0 +1,65 @@
+\name{synthetic_data_for_UBA_2014}
+\alias{synthetic_data_for_UBA_2014}
+\docType{data}
+\title{
+ Synthetic datasets for one parent compound with two metabolites
+}
+\description{
+ 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.
+
+ 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 \code{NA}.
+
+ As an example, the first dataset has the title \code{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.
+}
+\usage{synthetic_data_for_UBA_2014}
+\format{
+ A list containing datasets in the form internally used by the 'gmkin' package.
+ The list has twelfe components. Each of the components is one dataset that has,
+ among others, the following components
+ \describe{
+ \item{\code{title}}{The name of the dataset, e.g. \code{SFO_lin_a}}
+ \item{\code{data}}{A data frame with the data in the form expected by \code{\link{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{
+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")
+
+
+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")
+
+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")
+
+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")
+
+mkinfit(m_synth_SFO_lin, synthetic_data_for_UBA_2014[[1]]$data)
+}
+\keyword{datasets}
diff --git a/tests/testthat/test_FOCUS_D_UBA_expertise.R b/tests/testthat/test_FOCUS_D_UBA_expertise.R
index f9322714..ce1e0a5a 100644
--- a/tests/testthat/test_FOCUS_D_UBA_expertise.R
+++ b/tests/testthat/test_FOCUS_D_UBA_expertise.R
@@ -34,7 +34,7 @@ test_that("Fitted parameters are correct for FOCUS D", {
c(99.60, 0.0987, 0.0053, 0.5145))
})
-test_that("Fitted parameters are correct for FOCUS D", {
+test_that("FOCUS chi2 error levels are correct for FOCUS D", {
expect_equivalent(round(100 * mkinerrmin(fit.ff)$err.min, 2),
c(6.40, 6.46, 4.69))
})
diff --git a/tests/testthat/test_synthetic_data_for_UBA_2014.R b/tests/testthat/test_synthetic_data_for_UBA_2014.R
new file mode 100644
index 00000000..2bf01075
--- /dev/null
+++ b/tests/testthat/test_synthetic_data_for_UBA_2014.R
@@ -0,0 +1,67 @@
+# Copyright (C) 2015 Johannes Ranke
+# Contact: jranke@uni-bremen.de
+
+# This file is part of the R package mkin
+
+# mkin is free software: you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation, either version 3 of the License, or (at your option) any later
+# version.
+
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>
+
+context("Results for synthetic data established in expertise for UBA (Ranke 2014)")
+
+
+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")
+
+
+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")
+
+fit_SFO_lin_a <- mkinfit(m_synth_SFO_lin,
+ synthetic_data_for_UBA_2014[[1]]$data,
+ quiet = TRUE)
+fit_DFOP_par_c <- mkinfit(m_synth_DFOP_par,
+ synthetic_data_for_UBA_2014[[12]]$data,
+ quiet = TRUE)
+
+# Results for SFO_lin_a from p. 48
+
+test_that("Fitted parameters are correct for SFO_lin_a", {
+ parms <- round(fit_SFO_lin_a$bparms.optim, c(1, 4, 4, 4, 4, 4))
+ expect_equivalent(parms, c(102.1, 0.7393, 0.2992, 0.0202, 0.7687, 0.7229))
+})
+
+test_that("FOCUS chi2 error levels are correct for SFO_lin_a", {
+ errmin <- round(100 * mkinerrmin(fit_SFO_lin_a)$err.min, 2)
+ expect_equivalent(errmin, c(8.45, 8.66, 10.58, 3.59))
+})
+
+# Results for DFOP_par_c from p. 54
+
+test_that("Fitted parameters are correct for DFOP_par_c", {
+ parms <- round(fit_DFOP_par_c$bparms.optim, c(1, 4, 4, 4, 4, 4, 4, 4))
+ expect_equal(parms, c(parent_0 = 103.0,
+ k_M1 = 0.0389, k_M2 = 0.0095,
+ f_parent_to_M1 = 0.5565, f_parent_to_M2 = 0.3784,
+ k1 = 0.3263, k2 = 0.0202, g = 0.7130))
+})
+
+test_that("FOCUS chi2 error levels are correct for DFOP_par_c", {
+ errmin <- round(100 * mkinerrmin(fit_DFOP_par_c)$err.min, 2)
+ expect_equivalent(errmin, c(4.03, 3.05, 5.07, 3.17))
+})
+
+# References:
+# Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative
+# zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452

Contact - Imprint