From 9e346fabe99de71b21ef085be102027cfa774910 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 10 Aug 2022 12:58:35 +0200 Subject: Batch processing for hierarchical fits - 'R/mhmkin.R': New method for performing multiple hierarchical mkin fits in one function call, optionally in parallel. - 'R/saem.R': 'logLik' and 'update' methods for 'saem.mmkin' objects. - 'R/illparms.R': Add methods for 'saem.mmkin' and 'mhmkin' objects. tests: Use 2 cores on travis, should work according to docs --- tests/testthat/convergence_fits_synth_const.txt | 0 tests/testthat/convergence_hfits_synth.txt | 0 tests/testthat/illparms_hfits_synth.txt | 0 tests/testthat/setup_script.R | 4 ++-- tests/testthat/test_mhmkin.R | 31 +++++++++++++++++++++++++ 5 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/convergence_fits_synth_const.txt create mode 100644 tests/testthat/convergence_hfits_synth.txt create mode 100644 tests/testthat/illparms_hfits_synth.txt create mode 100644 tests/testthat/test_mhmkin.R (limited to 'tests') diff --git a/tests/testthat/convergence_fits_synth_const.txt b/tests/testthat/convergence_fits_synth_const.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/convergence_hfits_synth.txt b/tests/testthat/convergence_hfits_synth.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/illparms_hfits_synth.txt b/tests/testthat/illparms_hfits_synth.txt new file mode 100644 index 00000000..e69de29b diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 62cdf78e..af059668 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -8,8 +8,8 @@ if (identical(Sys.getenv("NOT_CRAN"), "true")) { n_cores <- 1 } -# We are only allowed one core on travis, but they also set NOT_CRAN=true -if (Sys.getenv("TRAVIS") != "") n_cores = 1 +# Use the two available cores on travis +if (Sys.getenv("TRAVIS") != "") n_cores = 2 # On Windows we would need to make a cluster first if (Sys.info()["sysname"] == "Windows") n_cores = 1 diff --git a/tests/testthat/test_mhmkin.R b/tests/testthat/test_mhmkin.R new file mode 100644 index 00000000..5243f971 --- /dev/null +++ b/tests/testthat/test_mhmkin.R @@ -0,0 +1,31 @@ +context("Batch fitting and diagnosing hierarchical kinetic models") + +test_that("Multiple hierarchical kinetic models can be fitted and diagnosed", { + + skip_on_cran() + fits_synth_const <- suppressWarnings( + mmkin(c("SFO", "FOMC"), ds_sfo[1:6], cores = n_cores, quiet = TRUE)) + + fits_synth_tc <- suppressWarnings( + update(fits_synth_const, error_model = "tc")) + + expect_known_output( + convergence(fits_synth_const), + "convergence_fits_synth_const.txt") + + hfits <- mhmkin(list(fits_synth_const, fits_synth_tc)) + + expect_known_output( + convergence(hfits), + "convergence_hfits_synth.txt") + + expect_known_output( + illparms(hfits), + "illparms_hfits_synth.txt") + + expect_equal(which.min(AIC(hfits)), 3) + + hfit_sfo_tc <- update(hfits[["SFO", "tc"]], + covariance.model = diag(c(0, 1))) + expect_equal(illparms(hfit_sfo_tc), character(0)) +}) -- cgit v1.2.1