From 3c5b2596daef4ed0ee5c38a7141fdf48dbe7c070 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 26 Oct 2022 09:07:04 +0200 Subject: Reduced sfo model for multistart.saem.mkin tests --- .../_snaps/multistart/llhist-for-sfo-fit.svg | 48 ++++------ .../_snaps/multistart/parhist-for-sfo-fit.svg | 106 +++++++++++++++++++++ tests/testthat/setup_script.R | 1 + tests/testthat/test_multistart.R | 8 +- tests/testthat/test_saemix_parent.R | 3 +- 5 files changed, 134 insertions(+), 32 deletions(-) create mode 100644 tests/testthat/_snaps/multistart/parhist-for-sfo-fit.svg (limited to 'tests') diff --git a/tests/testthat/_snaps/multistart/llhist-for-sfo-fit.svg b/tests/testthat/_snaps/multistart/llhist-for-sfo-fit.svg index 21fa8af8..4342df9b 100644 --- a/tests/testthat/_snaps/multistart/llhist-for-sfo-fit.svg +++ b/tests/testthat/_snaps/multistart/llhist-for-sfo-fit.svg @@ -19,32 +19,26 @@ Frequency of log likelihoods - - - - - - - + --644.0 --644.5 --645.0 --645.5 --646.0 --646.5 --647.0 + + + + +-649.836 +-649.834 +-649.832 +-649.830 +-649.828 - - - + + 0 -1 -2 -3 -4 +1 +2 +3 @@ -52,13 +46,11 @@ - - - - - - - + + + + + original fit diff --git a/tests/testthat/_snaps/multistart/parhist-for-sfo-fit.svg b/tests/testthat/_snaps/multistart/parhist-for-sfo-fit.svg new file mode 100644 index 00000000..f3373901 --- /dev/null +++ b/tests/testthat/_snaps/multistart/parhist-for-sfo-fit.svg @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +parent_0 +k_parent +a.1 +b.1 +SD.k_parent + + + + + +0.5 +1.0 +1.5 +2.0 +Normalised parameters + + + + + + + + + + + + + + + +Starting parameters +Original run +Multistart runs + + diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 4de2674f..777c998a 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -183,6 +183,7 @@ nlme_biphasic <- suppressWarnings(nlme(mmkin_biphasic)) # saemix sfo_saem_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") +sfo_saem_1_reduced <- update(sfo_saem_1, no_random_effect = "parent_0") dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin", no_random_effect = "parent_0") diff --git a/tests/testthat/test_multistart.R b/tests/testthat/test_multistart.R index 60fdefdc..e5b44e78 100644 --- a/tests/testthat/test_multistart.R +++ b/tests/testthat/test_multistart.R @@ -1,10 +1,14 @@ context("Multistart method for saem.mmkin models") test_that("multistart works for saem.mmkin models", { - saem_sfo_s_multi <- multistart(sfo_saem_1, n = 8, cores = n_cores) + set.seed(123456) + saem_sfo_s_multi <- multistart(sfo_saem_1_reduced, n = 8, cores = n_cores, + no_random_effect = "parent_0") - llhist_sfo <- function() llhist(saem_sfo_s_multi, xlim = c(-644, -647)) + llhist_sfo <- function() llhist(saem_sfo_s_multi) + parhist_sfo <- function() parhist(saem_sfo_s_multi, ylim = c(0.5, 2)) vdiffr::expect_doppelganger("llhist for sfo fit", llhist_sfo) + vdiffr::expect_doppelganger("parhist for sfo fit", parhist_sfo) set.seed(123456) saem_biphasic_m_multi <- multistart(saem_biphasic_m, n = 8, diff --git a/tests/testthat/test_saemix_parent.R b/tests/testthat/test_saemix_parent.R index d8b6b19e..193dcdcd 100644 --- a/tests/testthat/test_saemix_parent.R +++ b/tests/testthat/test_saemix_parent.R @@ -10,8 +10,7 @@ test_that("Parent fits using saemix are correctly implemented", { # We did not introduce variance of parent_0 in the data generation # This is correctly detected expect_equal(illparms(sfo_saem_1), "sd(parent_0)") - # So we remove this variance - sfo_saem_1_reduced <- update(sfo_saem_1, no_random_effect = "parent_0") + # So we have also done a fit without this variance expect_equal(illparms(sfo_saem_1_reduced), character(0)) # We cannot currently do the fit with completely fixed initial values -- cgit v1.2.1