From 656466946f093617ababebe5ec3b36809234112a Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 15 May 2015 08:49:40 +0200 Subject: Finished migration from RUnit to testthat --- tests/testthat/test_FOCUS_D_UBA_expertise.R | 58 +++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 tests/testthat/test_FOCUS_D_UBA_expertise.R (limited to 'tests/testthat/test_FOCUS_D_UBA_expertise.R') diff --git a/tests/testthat/test_FOCUS_D_UBA_expertise.R b/tests/testthat/test_FOCUS_D_UBA_expertise.R new file mode 100644 index 00000000..f9322714 --- /dev/null +++ b/tests/testthat/test_FOCUS_D_UBA_expertise.R @@ -0,0 +1,58 @@ +# 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 + +context("Results for FOCUS D established in expertise for UBA (Ranke 2014)") + +SFO_SFO <- mkinmod(parent = list(type = "SFO", to = "m1"), + m1 = list(type = "SFO")) +SFO_SFO.ff <- mkinmod(parent = list(type = "SFO", to = "m1"), + m1 = list(type = "SFO"), + use_of_ff = "max") + +fit.default <- mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE) +fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE) + +# Results are from p. 40 + +test_that("Fitted parameters are correct for FOCUS D", { + expect_equivalent(round(fit.ff$bparms.optim, c(2, 4, 4, 4)), + c(99.60, 0.0987, 0.0053, 0.5145)) +}) + +test_that("Fitted parameters are correct for FOCUS D", { + expect_equivalent(round(100 * mkinerrmin(fit.ff)$err.min, 2), + c(6.40, 6.46, 4.69)) +}) + +test_that("DT50/90 are correct for FOCUS D when using formation fractions", { + expect_equal(round(as.numeric(endpoints(fit.ff)$distimes["parent", ]), 2), + c(7.02, 23.33)) + expect_equal(round(as.numeric(endpoints(fit.ff)$distimes["m1", ]), 1), + c(131.8, 437.7)) +}) + +test_that("DT50/90 are correct for FOCUS D when not using formation fractions", { + expect_equal(round(as.numeric(endpoints(fit.default)$distimes["parent", ]), 2), + c(7.02, 23.33)) + expect_equal(round(as.numeric(endpoints(fit.default)$distimes["m1", ]), 1), + c(131.8, 437.7)) +}) + +# References: +# Ranke (2014) Prüfung und Validierung von Modellierungssoftware als Alternative +# zu ModelMaker 4.0, Umweltbundesamt Projektnummer 27452 -- cgit v1.2.1 From 9a5d2378845e584a2a2c6c09f7ef99a82d09273b Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Fri, 15 May 2015 13:04:36 +0200 Subject: Add synthetic data generated for UBA expertise, tests The new tests are based on the results documented in the expertise I wrote for the UBA (currently unpublished). --- tests/testthat/test_FOCUS_D_UBA_expertise.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/testthat/test_FOCUS_D_UBA_expertise.R') 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)) }) -- cgit v1.2.1