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 --- R/nafta.R | 3 +- build.log | 1 + data/NAFTA_2015.rda | Bin 264 -> 0 bytes data/NAFTA_SOP_2015.rda | Bin 0 -> 390 bytes man/NAFTA_2015_datasets.Rd | 35 -- man/NAFTA_SOP_2015.Rd | 36 ++ man/nafta.Rd | 2 +- test.log | 43 +- .../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 +- 16 files changed, 708 insertions(+), 114 deletions(-) delete mode 100644 data/NAFTA_2015.rda create mode 100644 data/NAFTA_SOP_2015.rda delete mode 100644 man/NAFTA_2015_datasets.Rd create mode 100644 man/NAFTA_SOP_2015.Rd 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 diff --git a/R/nafta.R b/R/nafta.R index 2af2404f..03bd77c1 100644 --- a/R/nafta.R +++ b/R/nafta.R @@ -49,7 +49,7 @@ nafta <- function(ds, title = NA, quiet = FALSE) { result$S["IORE"] result$S_c <- result$S[["IORE"]] * (1 + p/(n - p) * qf(0.5, p, n - p)) - result$t_rep <- .evaluate_nafta_results(result$S, result$S_c, + result$t_rep <- .evaluate_nafta_results(result$S, result$S_c, result$distimes, quiet = quiet) class(result) <- "nafta" @@ -67,6 +67,7 @@ plot.nafta <- function(x, legend = FALSE, main = "auto", ...) { print.nafta <- function(x, quiet = TRUE, ...) { cat("Sums of squares:\n") print(x$S) + cat("\nCritical sum of squares for checking the SFO model:\n") print(x$S_c) cat("\nParameters:\n") print(x$parameters) diff --git a/build.log b/build.log index 6831459d..217b621f 100644 --- a/build.log +++ b/build.log @@ -5,6 +5,7 @@ * creating vignettes ... OK * checking for LF line-endings in source and make files and shell scripts * checking for empty or unneeded directories +Removed empty directory ‘mkin/tests/figs/export-dataset-for-reading-into-cake’ * looking to see if a ‘data/datalist’ file should be added * building ‘mkin_0.9.48.1.tar.gz’ diff --git a/data/NAFTA_2015.rda b/data/NAFTA_2015.rda deleted file mode 100644 index 48183048..00000000 Binary files a/data/NAFTA_2015.rda and /dev/null differ diff --git a/data/NAFTA_SOP_2015.rda b/data/NAFTA_SOP_2015.rda new file mode 100644 index 00000000..eb7ce63f Binary files /dev/null and b/data/NAFTA_SOP_2015.rda differ diff --git a/man/NAFTA_2015_datasets.Rd b/man/NAFTA_2015_datasets.Rd deleted file mode 100644 index 4ca494ee..00000000 --- a/man/NAFTA_2015_datasets.Rd +++ /dev/null @@ -1,35 +0,0 @@ -\name{NAFTA_2015_datasets} -\alias{MRID_555555} -\docType{data} -\title{ -Example datasets from the NAFTA guidance published 2015 -} -\description{ -Data taken from US EPA (2015), p. 23. -} -\usage{NAFTA_2015_datasets} -\format{ - 1 dataset with observations on the following variables. - \describe{ - \item{\code{name}}{a factor containing the name of the observed variable} - \item{\code{time}}{a numeric vector containing time points} - \item{\code{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 - \url{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 - \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance} -} -\examples{ - nafta_evaluation <- nafta(MRID_555555) - print(nafta_evaluation) - plot(nafta_evaluation) -} -\keyword{datasets} diff --git a/man/NAFTA_SOP_2015.Rd b/man/NAFTA_SOP_2015.Rd new file mode 100644 index 00000000..a47ae155 --- /dev/null +++ b/man/NAFTA_SOP_2015.Rd @@ -0,0 +1,36 @@ +\name{NAFTA_SOP_2015} +\alias{NAFTA_SOP_Appendix_B} +\alias{NAFTA_SOP_Appendix_D} +\docType{data} +\title{ +Example datasets from the NAFTA SOP published 2015 +} +\description{ +Data taken from US EPA (2015), p. 19 and 23. +} +\usage{NAFTA_SOP_2015} +\format{ + 2 datasets with observations on the following variables. + \describe{ + \item{\code{name}}{a factor containing the name of the observed variable} + \item{\code{time}}{a numeric vector containing time points} + \item{\code{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 + \url{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 + \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance} +} +\examples{ + nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D) + print(nafta_evaluation) + plot(nafta_evaluation) +} +\keyword{datasets} diff --git a/man/nafta.Rd b/man/nafta.Rd index cd06e02b..48b4fefe 100644 --- a/man/nafta.Rd +++ b/man/nafta.Rd @@ -39,7 +39,7 @@ nafta(ds, title = NA, quiet = FALSE) \url{https://www.epa.gov/pesticide-science-and-assessing-pesticide-risks/standard-operating-procedure-using-nafta-guidance} } \examples{ - nafta_evaluation <- nafta(MRID_555555) + nafta_evaluation <- nafta(NAFTA_SOP_Appendix_D) print(nafta_evaluation) plot(nafta_evaluation) } diff --git a/test.log b/test.log index 63f5b542..77981c86 100644 --- a/test.log +++ b/test.log @@ -1,15 +1,24 @@ Loading mkin Testing mkin ✔ | OK F W S | Context - ⠏ | 0 | Export dataset for reading into CAKE ⠋ | 1 | Export dataset for reading into CAKE ⠙ | 1 1 | Export dataset for reading into CAKE ⠙ | 2 | Export dataset for reading into CAKE ⠹ | 3 | Export dataset for reading into CAKE ⠸ | 4 | Export dataset for reading into CAKE ⠼ | 5 | Export dataset for reading into CAKE ⠴ | 6 | Export dataset for reading into CAKE ⠦ | 7 | Export dataset for reading into CAKE ⠧ | 8 | Export dataset for reading into CAKE ⠇ | 8 1 | Export dataset for reading into CAKE ✔ | 8 1 | Export dataset for reading into CAKE [1.4 s] -──────────────────────────────────────────────────────────────────────────────── -test_CAKE_export.R:50: skip: Test data from Appendix D are correctly evaluated -Figure not generated yet: plot-nafta-analysis.svg -Please run `vdiffr::manage_cases()` to validate the figure. -──────────────────────────────────────────────────────────────────────────────── - ⠏ | 0 | Calculation of FOCUS chi2 error levels ⠋ | 1 | Calculation of FOCUS chi2 error levels ⠙ | 2 | Calculation of FOCUS chi2 error levels ✔ | 2 | Calculation of FOCUS chi2 error levels [2.2 s] - ⠏ | 0 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠼ | 5 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠴ | 6 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠦ | 7 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠧ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠇ | 9 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠏ | 10 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠋ | 11 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠙ | 12 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠹ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [7.8 s] - ⠏ | 0 | Iteratively reweighted least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighted least squares (IRLS) fitting ⠙ | 2 | Iteratively reweighted least squares (IRLS) fitting ⠹ | 2 1 | Iteratively reweighted least squares (IRLS) fitting ✔ | 2 1 | Iteratively reweighted least squares (IRLS) fitting [15.9 s] + ⠏ | 0 | Export dataset for reading into CAKE ⠋ | 1 | Export dataset for reading into CAKE ⠙ | 1 1 | Export dataset for reading into CAKE ✖ | 1 1 | Export dataset for reading into CAKE +──────────────────────────────────────────────────────────────────────────────── +test_CAKE_export.R:32: error: Test data from Appendix D are correctly evaluated +Objekt 'MRID_555555' nicht gefunden +1: expect_message(res <- nafta(MRID_555555, "MRID 555555")) at /home/jranke/git/mkin/tests/testthat/test_CAKE_export.R:32 +2: quasi_capture(enquo(object), capture_messages, label = label) +3: capture(act$val <- eval_bare(get_expr(quo), get_env(quo))) +4: withCallingHandlers(code, message = function(condition) { + out$push(condition) + invokeRestart("muffleMessage") + }) +5: eval_bare(get_expr(quo), get_env(quo)) +6: nafta(MRID_555555, "MRID 555555") +7: levels(ds$name) at /home/jranke/git/mkin/R/nafta.R:20 +──────────────────────────────────────────────────────────────────────────────── + ⠏ | 0 | Calculation of FOCUS chi2 error levels ⠋ | 1 | Calculation of FOCUS chi2 error levels ⠙ | 2 | Calculation of FOCUS chi2 error levels ✔ | 2 | Calculation of FOCUS chi2 error levels [2.3 s] + ⠏ | 0 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠼ | 5 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠴ | 6 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠦ | 7 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠧ | 8 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠇ | 9 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠏ | 10 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠋ | 11 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠙ | 12 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠹ | 13 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ⠸ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) ✔ | 14 | Results for FOCUS D established in expertise for UBA (Ranke 2014) [7.9 s] + ⠏ | 0 | Iteratively reweighted least squares (IRLS) fitting ⠋ | 1 | Iteratively reweighted least squares (IRLS) fitting ⠙ | 2 | Iteratively reweighted least squares (IRLS) fitting ⠹ | 2 1 | Iteratively reweighted least squares (IRLS) fitting ✔ | 2 1 | Iteratively reweighted least squares (IRLS) fitting [16.0 s] ──────────────────────────────────────────────────────────────────────────────── test_irls.R:48: skip: Reweighting method 'tc' works Too much trouble with datasets that are randomly generated @@ -20,9 +29,9 @@ test_logistic.R:41: skip: The logistic fit can be done via differential equation Skip slow fit of logistic model using deSolve without compilation ──────────────────────────────────────────────────────────────────────────────── ⠏ | 0 | Model predictions with mkinpredict ⠋ | 1 | Model predictions with mkinpredict ⠙ | 2 | Model predictions with mkinpredict ⠹ | 3 | Model predictions with mkinpredict ✔ | 3 | Model predictions with mkinpredict [0.3 s] - ⠏ | 0 | Evaluations according to 2015 NAFTA guidance ⠋ | 1 | Evaluations according to 2015 NAFTA guidance ⠙ | 1 1 | Evaluations according to 2015 NAFTA guidance ⠙ | 2 | Evaluations according to 2015 NAFTA guidance ⠹ | 3 | Evaluations according to 2015 NAFTA guidance ⠸ | 4 | Evaluations according to 2015 NAFTA guidance ⠼ | 5 | Evaluations according to 2015 NAFTA guidance ⠴ | 6 | Evaluations according to 2015 NAFTA guidance ⠦ | 7 | Evaluations according to 2015 NAFTA guidance ⠧ | 8 | Evaluations according to 2015 NAFTA guidance ⠇ | 9 | Evaluations according to 2015 NAFTA guidance ✔ | 9 | Evaluations according to 2015 NAFTA guidance [0.8 s] - ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [23.7 s] - ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ⠼ | 5 | Calculation of maximum time weighted average concentrations (TWAs) ⠴ | 6 | Calculation of maximum time weighted average concentrations (TWAs) ⠦ | 7 | Calculation of maximum time weighted average concentrations (TWAs) ⠧ | 8 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 8 | Calculation of maximum time weighted average concentrations (TWAs) [7.2 s] + ⠏ | 0 | Evaluations according to 2015 NAFTA guidance ⠋ | 1 | Evaluations according to 2015 NAFTA guidance ⠙ | 2 | Evaluations according to 2015 NAFTA guidance ⠹ | 3 | Evaluations according to 2015 NAFTA guidance ⠸ | 4 | Evaluations according to 2015 NAFTA guidance ⠼ | 5 | Evaluations according to 2015 NAFTA guidance ⠴ | 6 | Evaluations according to 2015 NAFTA guidance ⠦ | 7 | Evaluations according to 2015 NAFTA guidance ⠧ | 8 | Evaluations according to 2015 NAFTA guidance ⠇ | 9 | Evaluations according to 2015 NAFTA guidance ⠏ | 9 1 | Evaluations according to 2015 NAFTA guidance ⠏ | 10 | Evaluations according to 2015 NAFTA guidance ⠋ | 11 | Evaluations according to 2015 NAFTA guidance ⠙ | 12 | Evaluations according to 2015 NAFTA guidance ⠹ | 13 | Evaluations according to 2015 NAFTA guidance ⠸ | 14 | Evaluations according to 2015 NAFTA guidance ⠼ | 15 | Evaluations according to 2015 NAFTA guidance ⠴ | 16 | Evaluations according to 2015 NAFTA guidance ⠦ | 17 | Evaluations according to 2015 NAFTA guidance ✔ | 17 | Evaluations according to 2015 NAFTA guidance [1.5 s] + ⠏ | 0 | Fitting of parent only models ⠋ | 1 | Fitting of parent only models ⠙ | 2 | Fitting of parent only models ⠹ | 3 | Fitting of parent only models ⠸ | 4 | Fitting of parent only models ⠼ | 5 | Fitting of parent only models ⠴ | 6 | Fitting of parent only models ⠦ | 7 | Fitting of parent only models ⠧ | 8 | Fitting of parent only models ⠇ | 9 | Fitting of parent only models ⠏ | 10 | Fitting of parent only models ⠋ | 11 | Fitting of parent only models ⠙ | 12 | Fitting of parent only models ⠹ | 13 | Fitting of parent only models ⠸ | 14 | Fitting of parent only models ⠼ | 15 | Fitting of parent only models ⠴ | 16 | Fitting of parent only models ⠦ | 17 | Fitting of parent only models ⠧ | 18 | Fitting of parent only models ⠇ | 19 | Fitting of parent only models ⠏ | 20 | Fitting of parent only models ⠋ | 21 | Fitting of parent only models ✔ | 21 | Fitting of parent only models [24.5 s] + ⠏ | 0 | Calculation of maximum time weighted average concentrations (TWAs) ⠋ | 1 | Calculation of maximum time weighted average concentrations (TWAs) ⠙ | 2 | Calculation of maximum time weighted average concentrations (TWAs) ⠹ | 3 | Calculation of maximum time weighted average concentrations (TWAs) ⠸ | 4 | Calculation of maximum time weighted average concentrations (TWAs) ⠼ | 5 | Calculation of maximum time weighted average concentrations (TWAs) ⠴ | 6 | Calculation of maximum time weighted average concentrations (TWAs) ⠦ | 7 | Calculation of maximum time weighted average concentrations (TWAs) ⠧ | 8 | Calculation of maximum time weighted average concentrations (TWAs) ✔ | 8 | Calculation of maximum time weighted average concentrations (TWAs) [7.3 s] ⠏ | 0 | Summary ⠋ | 1 | Summary ✔ | 1 | Summary ⠏ | 0 | Plotting ⠋ | 1 | Plotting ⠙ | 1 1 | Plotting ⠹ | 2 1 | Plotting ⠸ | 3 1 | Plotting ✔ | 3 1 | Plotting [0.3 s] ──────────────────────────────────────────────────────────────────────────────── @@ -31,12 +40,12 @@ Figure not generated yet: mkinparplot-for-focus-c-sfo.svg Please run `vdiffr::manage_cases()` to validate the figure. ──────────────────────────────────────────────────────────────────────────────── ⠏ | 0 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠋ | 1 | Complex test case from Schaefer et al. (2007) Piacenza paper ⠙ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper ✔ | 2 | Complex test case from Schaefer et al. (2007) Piacenza paper [5.9 s] - ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.3 s] + ⠏ | 0 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠋ | 1 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠙ | 2 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠹ | 3 | Results for synthetic data established in expertise for UBA (Ranke 2014) ⠸ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) ✔ | 4 | Results for synthetic data established in expertise for UBA (Ranke 2014) [7.5 s] ══ Results ═════════════════════════════════════════════════════════════════════ -Duration: 74.6 s +Duration: 75.2 s -OK: 77 -Failed: 0 +OK: 79 +Failed: 1 Warnings: 0 -Skipped: 4 +Skipped: 3 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