diff options
author | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-10 21:53:00 +0200 |
---|---|---|
committer | Johannes Ranke <jranke@uni-bremen.de> | 2020-05-10 21:53:00 +0200 |
commit | d113cd79b178fdc91aecb894707ed356129dfb75 (patch) | |
tree | dc28e049e94eb3ee9745f9cd86387de96a894c93 /tests | |
parent | efab37957381919c21d874906ce870f4941c760a (diff) |
Default to analytical for coupled models if available
This revealed that transforming rates is necessary for fitting
the analytical solution of the SFO-SFO model to the FOCUS D dataset.
Benchmarks show that fitting coupled models with deSolve got a bit
slower through the latest changes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/testthat/FOCUS_2006_D.csf | 2 | ||||
-rw-r--r-- | tests/testthat/test_FOCUS_D_UBA_expertise.R | 21 |
2 files changed, 16 insertions, 7 deletions
diff --git a/tests/testthat/FOCUS_2006_D.csf b/tests/testthat/FOCUS_2006_D.csf index f113a668..d41f0a9f 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: 2020-05-09 +Date: 2020-05-10 Optimiser: IRLS [Data] diff --git a/tests/testthat/test_FOCUS_D_UBA_expertise.R b/tests/testthat/test_FOCUS_D_UBA_expertise.R index f3b12bd9..be2806de 100644 --- a/tests/testthat/test_FOCUS_D_UBA_expertise.R +++ b/tests/testthat/test_FOCUS_D_UBA_expertise.R @@ -2,19 +2,22 @@ context("Results for FOCUS D established in expertise for UBA (Ranke 2014)") # Results are from p. 40 +# Avoid warnings due to the zero value in the data for m1 at time zero +FOCUS_D <- subset(FOCUS_2006_D, value != 0) + test_that("Fits without formation fractions are correct for FOCUS D", { - fit.default <- expect_warning(mkinfit(SFO_SFO, FOCUS_2006_D, quiet = TRUE), "value of zero") + fit.noff <- mkinfit(SFO_SFO, FOCUS_D, quiet = TRUE) - expect_equal(round(as.numeric(endpoints(fit.default)$distimes["parent", ]), 2), + expect_equal(round(as.numeric(endpoints(fit.noff)$distimes["parent", ]), 2), c(7.02, 23.33)) - expect_equal(round(as.numeric(endpoints(fit.default)$distimes["m1", ]), 1), + expect_equal(round(as.numeric(endpoints(fit.noff)$distimes["m1", ]), 1), c(131.8, 437.7)) }) test_that("Fits with formation fractions are correct for FOCUS D", { skip_on_cran() - fit.ff <- expect_warning(mkinfit(SFO_SFO.ff, FOCUS_2006_D, quiet = TRUE), "value of zero") + fit.ff <- mkinfit(SFO_SFO.ff, FOCUS_D, quiet = TRUE) expect_equivalent(round(fit.ff$bparms.optim, c(2, 4, 4, 4)), c(99.60, 0.0987, 0.0053, 0.5145)) @@ -30,8 +33,15 @@ test_that("Fits with formation fractions are correct for FOCUS D", { test_that("Fits without internal transformations are correct for FOCUS D", { skip_on_cran() expect_warning( + # Analytical solutions (now the default for SFO_SFO with formation fractions) + # return NA at some point not internally transforming rates + expect_error(fit.ff.notrans <- mkinfit(SFO_SFO.ff, FOCUS_D, + transform_fractions = FALSE, transform_rates = FALSE, quiet = TRUE))) + + expect_warning( fit.ff.notrans <- mkinfit(SFO_SFO.ff, FOCUS_2006_D, - transform_fractions = FALSE, transform_rates = FALSE, quiet = TRUE), + transform_fractions = FALSE, transform_rates = FALSE, + quiet = TRUE, solution_type = "deSolve"), "sum of formation fractions") expect_equivalent(round(fit.ff.notrans$bparms.optim, c(2, 4, 4, 4)), @@ -40,7 +50,6 @@ test_that("Fits without internal transformations are correct for FOCUS D", { expect_equivalent(round(100 * mkinerrmin(fit.ff.notrans)$err.min, 2), c(6.40, 6.46, 4.69)) - expect_equal(round(as.numeric(endpoints(fit.ff.notrans)$distimes["parent", ]), 2), c(7.02, 23.33)) expect_equal(round(as.numeric(endpoints(fit.ff.notrans)$distimes["m1", ]), 1), |