From 6693ee373c61d716e877386d6be16e3f9f0f40ab Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 26 Feb 2019 09:12:50 +0100 Subject: Add another NAFTA dataset + test --- .../nafta-sop-appendix-b.svg | 462 +++++++++++++++++++++ .../figs/plotting/mkinparplot-for-focus-c-sfo.svg | 85 ++++ tests/testthat/FOCUS_2006_D.csf | 2 +- tests/testthat/NAFTA_SOP_Appendix_B.txt | 35 ++ tests/testthat/NAFTA_SOP_Appendix_D.txt | 35 ++ tests/testthat/print_nafta_analysis.txt | 33 -- tests/testthat/test_CAKE_export.R | 22 - tests/testthat/test_nafta.R | 28 +- 8 files changed, 642 insertions(+), 60 deletions(-) create mode 100644 tests/figs/evaluations-according-to-2015-nafta-guidance/nafta-sop-appendix-b.svg create mode 100644 tests/figs/plotting/mkinparplot-for-focus-c-sfo.svg create mode 100644 tests/testthat/NAFTA_SOP_Appendix_B.txt create mode 100644 tests/testthat/NAFTA_SOP_Appendix_D.txt delete mode 100644 tests/testthat/print_nafta_analysis.txt (limited to 'tests') diff --git a/tests/figs/evaluations-according-to-2015-nafta-guidance/nafta-sop-appendix-b.svg b/tests/figs/evaluations-according-to-2015-nafta-guidance/nafta-sop-appendix-b.svg new file mode 100644 index 00000000..617e39b3 --- /dev/null +++ b/tests/figs/evaluations-according-to-2015-nafta-guidance/nafta-sop-appendix-b.svg @@ -0,0 +1,462 @@ + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + +aerobic aquatic +SFO + +χ +2 + +error level += +20.4% + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 +140 + + + + +-5 +0 +5 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + +SFO residuals + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + +aerobic aquatic +IORE + +χ +2 + +error level += +5.06% + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 +140 + + + + +-2 +0 +2 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + +IORE residuals + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 + + + + + + + +0 +10 +20 +30 +40 +50 + + + + + + +Time +Observed + + + + + + + + + + + + + + + + + + + + + + + + + +aerobic aquatic +DFOP + +χ +2 + +error level += +3.39% + + + + + + + + + + + + + + + + + + + +0 +20 +40 +60 +80 +100 +120 +140 + + + + + + + + +-3 +-2 +-1 +0 +1 +2 +3 + + + + + + +Time +Residual + + + + + + + + + + + + + + + + + + + + + + + + + +DFOP residuals + + + + + + diff --git a/tests/figs/plotting/mkinparplot-for-focus-c-sfo.svg b/tests/figs/plotting/mkinparplot-for-focus-c-sfo.svg new file mode 100644 index 00000000..c6a19428 --- /dev/null +++ b/tests/figs/plotting/mkinparplot-for-focus-c-sfo.svg @@ -0,0 +1,85 @@ + + + + + + + + + + + + + +0 +20 +40 +60 +80 + + + + + + + + + + + +parent_0 + + + + + + + + + + + + + + + + + + + + +0.0 +0.1 +0.2 +0.3 +0.4 + + + + + + + + + + + + +k_parent_sink + + + + + + + + + diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index d695e90d..22c5f2b4 100644 --- a/tests/testthat/FOCUS_2006_D.csf +++ b/tests/testthat/FOCUS_2006_D.csf @@ -5,7 +5,7 @@ Description: MeasurementUnits: % AR TimeUnits: days Comments: Created using mkin::CAKE_export -Date: 2019-02-25 +Date: 2019-02-26 Optimiser: IRLS [Data] diff --git a/tests/testthat/NAFTA_SOP_Appendix_B.txt b/tests/testthat/NAFTA_SOP_Appendix_B.txt new file mode 100644 index 00000000..54b70880 --- /dev/null +++ b/tests/testthat/NAFTA_SOP_Appendix_B.txt @@ -0,0 +1,35 @@ +Sums of squares: + SFO IORE DFOP +174.39718 21.91831 16.57180 + +Critical sum of squares for checking the SFO model: +[1] 26.93798 + +Parameters: +$SFO + Estimate Pr(>t) Lower Upper +parent_0 51.2430312 1.178492e-10 45.4036817 57.0823806 +k_parent_sink 0.2531291 1.608492e-06 0.1935733 0.3310082 + +$IORE + Estimate Pr(>t) Lower Upper +parent_0 51.71052958 8.522722e-15 4.951371e+01 53.907348315 +k__iore_parent_sink 0.00134836 6.841092e-02 3.421381e-04 0.005313861 +N_parent 2.66146927 3.975823e-08 2.191012e+00 3.131926902 + +$DFOP + Estimate Pr(>t) Lower Upper +parent_0 51.70546719 3.457982e-14 49.677926850 53.73300753 +k1 0.41569648 1.002119e-06 0.330769606 0.52242879 +k2 0.01273299 1.393989e-03 0.007230162 0.02242399 +g 0.83380396 5.718367e-12 0.771816175 0.88153694 + + +DTx values: + DT50 DT90 DT50_rep +SFO 3 9 3 +IORE 1 28 9 +DFOP 2 40 54 + +Representative half-life: +[1] 8.573301 diff --git a/tests/testthat/NAFTA_SOP_Appendix_D.txt b/tests/testthat/NAFTA_SOP_Appendix_D.txt new file mode 100644 index 00000000..d01accf2 --- /dev/null +++ b/tests/testthat/NAFTA_SOP_Appendix_D.txt @@ -0,0 +1,35 @@ +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.755751519 8.076390e-15 76.928220975 90.583282063 +k_parent_sink 0.001703321 7.452357e-05 0.001108568 0.002617164 + +$IORE + Estimate Pr(>t) Lower Upper +parent_0 9.685291e+01 NA 8.752855e+01 1.061773e+02 +k__iore_parent_sink 8.403374e-14 NA 1.092054e-19 6.466412e-08 +N_parent 6.684458e+00 NA 3.538511e+00 9.830405e+00 + +$DFOP + Estimate Pr(>t) Lower Upper +parent_0 9.755655e+01 4.439930e-13 8.884447e+01 1.062686e+02 +k1 4.240633e-02 3.554769e-02 1.414189e-02 1.271610e-01 +k2 8.237928e-04 2.060933e-02 3.172784e-04 2.138925e-03 +g 2.881037e-01 1.313715e-04 1.783967e-01 4.299694e-01 + + +DTx values: + DT50 DT90 DT50_rep +SFO 407 1352 407 +IORE 541 5192066 1562968 +DFOP 429 2383 841 + +Representative half-life: +[1] 841.4096 diff --git a/tests/testthat/print_nafta_analysis.txt b/tests/testthat/print_nafta_analysis.txt deleted file mode 100644 index 61d2539f..00000000 --- a/tests/testthat/print_nafta_analysis.txt +++ /dev/null @@ -1,33 +0,0 @@ -Sums of squares: - SFO IORE DFOP -1378.6832 615.7730 517.8836 -[1] 717.4598 - -Parameters: -$SFO - Estimate Pr(>t) Lower Upper -parent_0 83.755751519 8.076390e-15 76.928220975 90.583282063 -k_parent_sink 0.001703321 7.452357e-05 0.001108568 0.002617164 - -$IORE - Estimate Pr(>t) Lower Upper -parent_0 9.685291e+01 NA 8.752855e+01 1.061773e+02 -k__iore_parent_sink 8.403374e-14 NA 1.092054e-19 6.466412e-08 -N_parent 6.684458e+00 NA 3.538511e+00 9.830405e+00 - -$DFOP - Estimate Pr(>t) Lower Upper -parent_0 9.755655e+01 4.439930e-13 8.884447e+01 1.062686e+02 -k1 4.240633e-02 3.554769e-02 1.414189e-02 1.271610e-01 -k2 8.237928e-04 2.060933e-02 3.172784e-04 2.138925e-03 -g 2.881037e-01 1.313715e-04 1.783967e-01 4.299694e-01 - - -DTx values: - DT50 DT90 DT50_rep -SFO 407 1352 407 -IORE 541 5192066 1562968 -DFOP 429 2383 841 - -Representative half-life: -[1] 841.4096 diff --git a/tests/testthat/test_CAKE_export.R b/tests/testthat/test_CAKE_export.R index aeb192c8..5f984782 100644 --- a/tests/testthat/test_CAKE_export.R +++ b/tests/testthat/test_CAKE_export.R @@ -27,25 +27,3 @@ test_that("Exporting is reproducible", { csf <- readLines(con = "FOCUS_2006_D.csf") expect_known_output(csf, "FOCUS_2006_D.txt") }) - -test_that("Test data from Appendix D are correctly evaluated", { - expect_message(res <- nafta(MRID_555555, "MRID 555555")) - - # From Figure D.1 - dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2) - expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1, - scale = 1) - - C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6) - C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"]) - expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1) - - expect_equal(round(res$S_c), 717) - expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3) - expect_equal(round(res$t_rep), 841) - - expect_known_output(print(res), "print_nafta_analysis.txt") - - plot_nafta <- function() plot(res) - vdiffr::expect_doppelganger("Plot NAFTA analysis", plot_nafta) -}) diff --git a/tests/testthat/test_nafta.R b/tests/testthat/test_nafta.R index 10de3ce0..a50d8f36 100644 --- a/tests/testthat/test_nafta.R +++ b/tests/testthat/test_nafta.R @@ -21,13 +21,33 @@ context("Evaluations according to 2015 NAFTA guidance") test_that("Data for more than one compound are rejected", expect_error(nafta(FOCUS_2006_D))) +test_that("Test data from Appendix B are correctly evaluated", { + expect_message(res <- nafta(NAFTA_SOP_Appendix_B, "aerobic aquatic")) + + # From Figure D.1 + dtx_sop <- matrix(c(2.74, 1.37, 2.17, 9.1, 28.5, 39.9), nrow = 3, ncol = 2) + expect_equivalent(signif(res$distimes[, 1:2], 3), dtx_sop) + + C0_sop <- c(SFO = 51.2, IORE = 51.7, DFOP = 51.7) + C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"]) + expect_equivalent(C0_mkin, C0_sop, scale = 1, tolerance = 0.1) + + expect_equal(signif(res$S_c, 3), 26.9) + expect_equal(signif(res$S[["SFO"]], 3), 174) + expect_equal(signif(res$t_rep, 3), 8.57) + + expect_known_output(print(res), "NAFTA_SOP_Appendix_B.txt") + + plot_nafta <- function() plot(res) + vdiffr::expect_doppelganger("NAFTA SOP Appendix B", plot_nafta) +}) + test_that("Test data from Appendix D are correctly evaluated", { - expect_message(res <- nafta(MRID_555555, "MRID 555555")) + expect_message(res <- nafta(NAFTA_SOP_Appendix_D, "MRID 555555")) # From Figure D.1 dtx_sop <- matrix(c(407, 541, 429, 1352, 5192066, 2383), nrow = 3, ncol = 2) - expect_equivalent(res$distimes[, 1:2], dtx_sop, tolerance = 1, - scale = 1) + expect_equivalent(round(res$distimes[, 1:2]), dtx_sop) C0_sop <- c(SFO = 83.8, IORE = 96.9, DFOP = 97.6) C0_mkin <- sapply(res$parameters, function(x) x["parent_0", "Estimate"]) @@ -37,7 +57,7 @@ test_that("Test data from Appendix D are correctly evaluated", { expect_equal(signif(res$S[["SFO"]], 3), 1.38e+3) expect_equal(round(res$t_rep), 841) - expect_known_output(print(res), "print_nafta_analysis.txt") + expect_known_output(print(res), "NAFTA_SOP_Appendix_D.txt") plot_nafta <- function() plot(res) vdiffr::expect_doppelganger("Plot NAFTA analysis", plot_nafta) -- cgit v1.2.1