aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testthat')
-rw-r--r--tests/testthat/_snaps/multistart/mixed-model-fit-for-saem-object-with-mkin-transformations.svg (renamed from tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg)0
-rw-r--r--tests/testthat/setup_script.R3
-rw-r--r--tests/testthat/test_mixed.R8
-rw-r--r--tests/testthat/test_multistart.R15
-rw-r--r--tests/testthat/test_plot.R4
5 files changed, 18 insertions, 12 deletions
diff --git a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg b/tests/testthat/_snaps/multistart/mixed-model-fit-for-saem-object-with-mkin-transformations.svg
index 69fa6a4d..69fa6a4d 100644
--- a/tests/testthat/_snaps/plot/mixed-model-fit-for-saem-object-with-mkin-transformations.svg
+++ b/tests/testthat/_snaps/multistart/mixed-model-fit-for-saem-object-with-mkin-transformations.svg
diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R
index 2448886d..4e2f76ab 100644
--- a/tests/testthat/setup_script.R
+++ b/tests/testthat/setup_script.R
@@ -109,7 +109,4 @@ sfo_saem_1_reduced <- update(sfo_saem_1, no_random_effect = "parent_0")
dfop_saem_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin",
no_random_effect = c("parent_0", "g_qlogis"))
-saem_dfop_sfo_m <- saem(mmkin_dfop_sfo, transformations = "mkin", quiet = TRUE)
-saem_dfop_sfo_s <- saem(mmkin_dfop_sfo, transformations = "saemix", quiet = TRUE)
-
parallel::stopCluster(cl)
diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R
index ab8dfc27..8c257738 100644
--- a/tests/testthat/test_mixed.R
+++ b/tests/testthat/test_mixed.R
@@ -46,6 +46,9 @@ test_that("nlme results are reproducible to some degree", {
test_that("saemix results are reproducible for biphasic fits", {
+ skip_on_cran()
+ saem_dfop_sfo_s <- saem(mmkin_dfop_sfo, transformations = "saemix", quiet = TRUE)
+
test_summary <- summary(saem_dfop_sfo_s)
test_summary$saemixversion <- "Dummy 0.0 for testing"
test_summary$mkinversion <- "Dummy 0.0 for testing"
@@ -65,11 +68,6 @@ test_that("saemix results are reproducible for biphasic fits", {
expect_true(all(ci_dfop_sfo_s_s[, "lower"] < dfop_sfo_pop))
expect_true(all(ci_dfop_sfo_s_s[, "upper"] > dfop_sfo_pop))
- # k2 is not fitted well
- ci_dfop_sfo_s_m <- summary(saem_dfop_sfo_m)$confint_back
- expect_true(all(ci_dfop_sfo_s_m[no_k2, "lower"] < dfop_sfo_pop[no_k2]))
- expect_true(all(ci_dfop_sfo_s_m[no_k1, "upper"] > dfop_sfo_pop[no_k1]))
-
# I tried to only do few iterations in routine tests as this is so slow
# but then deSolve fails at some point (presumably at the switch between
# the two types of iterations)
diff --git a/tests/testthat/test_multistart.R b/tests/testthat/test_multistart.R
index 3a511e06..91ef71f0 100644
--- a/tests/testthat/test_multistart.R
+++ b/tests/testthat/test_multistart.R
@@ -4,6 +4,7 @@ test_that("multistart works for saem.mmkin models", {
skip_on_cran() # Save CRAN time
set.seed(123456)
saem_sfo_s_multi <- multistart(sfo_saem_1_reduced, n = 8, cores = n_cores)
+
anova_sfo <- anova(sfo_saem_1,
sfo_saem_1_reduced,
best(saem_sfo_s_multi),
@@ -13,6 +14,17 @@ test_that("multistart works for saem.mmkin models", {
expect_equal(round(anova_sfo, 1)["best(saem_sfo_s_multi)", "AIC"], 1302.2)
expect_true(anova_sfo[3, "Pr(>Chisq)"] > 0.2) # Local: 1, win-builder: 0.4
+ saem_dfop_sfo_m <- saem(mmkin_dfop_sfo, transformations = "mkin", quiet = TRUE)
+ dfop_sfo_pop <- attr(ds_dfop_sfo, "pop")
+
+ # k2 is not fitted well (compare saem_dfop_sfo_s in test_mixed.R)
+ ci_dfop_sfo_s_m <- summary(saem_dfop_sfo_m)$confint_back
+ no_k1 <- c(1, 2, 3, 5, 6)
+ no_k2 <- c(1, 2, 3, 4, 6)
+ expect_true(all(ci_dfop_sfo_s_m[no_k2, "lower"] < dfop_sfo_pop[no_k2]))
+ expect_true(all(ci_dfop_sfo_s_m[no_k1, "upper"] > dfop_sfo_pop[no_k1]))
+
+
set.seed(123456)
saem_dfop_sfo_m_multi <- multistart(saem_dfop_sfo_m, n = 8,
cores = n_cores)
@@ -28,6 +40,9 @@ test_that("multistart works for saem.mmkin models", {
tolerance = 1e-4)
skip_on_travis() # Plots are platform dependent
+ plot_dfop_sfo_saem_m <- function() plot(saem_dfop_sfo_m)
+ vdiffr::expect_doppelganger("mixed model fit for saem object with mkin transformations", plot_dfop_sfo_saem_m)
+
llhist_sfo <- function() llhist(saem_sfo_s_multi)
parplot_sfo <- function() parplot(saem_sfo_s_multi, ylim = c(0.5, 2))
vdiffr::expect_doppelganger("llhist for sfo fit", llhist_sfo)
diff --git a/tests/testthat/test_plot.R b/tests/testthat/test_plot.R
index 01b0c1ee..f5da5982 100644
--- a/tests/testthat/test_plot.R
+++ b/tests/testthat/test_plot.R
@@ -41,7 +41,6 @@ test_that("Plotting mkinfit, mmkin and mixed model objects is reproducible", {
f_uba_mmkin <- mmkin(list("DFOP-SFO" = dfop_sfo_uba),
ds_uba, quiet = TRUE, cores = n_cores)
f_uba_dfop_sfo_mixed <- mixed(f_uba_mmkin["DFOP-SFO", ])
-
f_uba_dfop_sfo_saem <- saem(f_uba_mmkin["DFOP-SFO", ], quiet = TRUE, transformations = "saemix")
plot_dfop_sfo_mmkin <- function() plot(f_uba_dfop_sfo_mixed, pop_curve = TRUE)
@@ -59,9 +58,6 @@ test_that("Plotting mkinfit, mmkin and mixed model objects is reproducible", {
# Biphasic fits with lots of data and fits have lots of potential for differences
plot_dfop_sfo_nlme <- function() plot(nlme_dfop_sfo)
#plot_dfop_sfo_saem_s <- function() plot(saem_dfop_sfo_s)
- plot_dfop_sfo_saem_m <- function() plot(saem_dfop_sfo_m)
-
- vdiffr::expect_doppelganger("mixed model fit for saem object with mkin transformations", plot_dfop_sfo_saem_m)
# different results when working with eigenvalues
plot_errmod_fit_D_obs_eigen <- function() plot_err(fit_D_obs_eigen, sep_obs = FALSE)

Contact - Imprint