From 48c463680b51fa767b4cd7bd62865f192d0354ac Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sat, 6 Feb 2021 18:30:32 +0100 Subject: Reintroduce interface to saemix Also after the upgrade from buster to bullseye of my local system, some test results for saemix have changed. --- tests/testthat/setup_script.R | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests/testthat/setup_script.R') diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 547b2d6c..9229c198 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -178,6 +178,10 @@ ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { }) # Mixed model fits +saemix_available <- FALSE +if (requireNamespace("saemix", quietly = TRUE)) { + if(packageVersion("saemix") >= "3.1.9000") saemix_available <- TRUE +} mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cores = n_cores) mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE, cores = n_cores) mmkin_biphasic <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE, cores = n_cores) @@ -186,6 +190,16 @@ mmkin_biphasic_mixed <- mixed(mmkin_biphasic) dfop_nlme_1 <- nlme(mmkin_dfop_1) nlme_biphasic <- nlme(mmkin_biphasic) +if (saemix_available) { + sfo_saem_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") + + dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin") + dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix") + + saem_biphasic_m <- saem(mmkin_biphasic, transformations = "mkin", quiet = TRUE) + saem_biphasic_s <- saem(mmkin_biphasic, transformations = "saemix", quiet = TRUE) +} + ds_uba <- lapply(experimental_data_for_UBA_2019[6:10], function(x) subset(x$data[c("name", "time", "value")])) names(ds_uba) <- paste("Dataset", 6:10) @@ -197,3 +211,7 @@ f_uba_mmkin <- mmkin(list("SFO-SFO" = sfo_sfo_uba, "DFOP-SFO" = dfop_sfo_uba), ds_uba, quiet = TRUE, cores = n_cores) f_uba_dfop_sfo_mixed <- mixed(f_uba_mmkin[2, ]) +if (saemix_available) { + f_uba_sfo_sfo_saem <- saem(f_uba_mmkin["SFO-SFO", ], quiet = TRUE, transformations = "saemix") + f_uba_dfop_sfo_saem <- saem(f_uba_mmkin["DFOP-SFO", ], quiet = TRUE, transformations = "saemix") +} -- cgit v1.2.1 From c73b2f30ec836c949885784ab576e814eb8070a9 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Tue, 9 Mar 2021 17:35:47 +0100 Subject: Some improvements for borderline cases - fit_with_errors for saem() - test_log_parms for mean_degparms() and saem() --- tests/testthat/setup_script.R | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests/testthat/setup_script.R') diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 9229c198..96e865d4 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -106,6 +106,7 @@ const <- function(value) 2 set.seed(123456) SFO <- mkinmod(parent = mkinsub("SFO")) k_parent = rlnorm(n, log(0.03), log_sd) +set.seed(123456) ds_sfo <- lapply(1:n, function(i) { ds_mean <- mkinpredict(SFO, c(k_parent = k_parent[i]), c(parent = 100), sampling_times) @@ -118,6 +119,7 @@ fomc_pop <- list(parent_0 = 100, alpha = 2, beta = 8) fomc_parms <- as.matrix(data.frame( alpha = rlnorm(n, log(fomc_pop$alpha), 0.4), beta = rlnorm(n, log(fomc_pop$beta), 0.2))) +set.seed(123456) ds_fomc <- lapply(1:3, function(i) { ds_mean <- mkinpredict(FOMC, fomc_parms[i, ], c(parent = 100), sampling_times) @@ -131,6 +133,7 @@ dfop_parms <- as.matrix(data.frame( k1 = rlnorm(n, log(dfop_pop$k1), log_sd), k2 = rlnorm(n, log(dfop_pop$k2), log_sd), g = plogis(rnorm(n, qlogis(dfop_pop$g), log_sd)))) +set.seed(123456) ds_dfop <- lapply(1:n, function(i) { ds_mean <- mkinpredict(DFOP, dfop_parms[i, ], c(parent = dfop_pop$parent_0), sampling_times) @@ -144,6 +147,7 @@ hs_parms <- as.matrix(data.frame( k1 = rlnorm(n, log(hs_pop$k1), log_sd), k2 = rlnorm(n, log(hs_pop$k2), log_sd), tb = rlnorm(n, log(hs_pop$tb), 0.1))) +set.seed(123456) ds_hs <- lapply(1:10, function(i) { ds_mean <- mkinpredict(HS, hs_parms[i, ], c(parent = hs_pop$parent_0), sampling_times) @@ -171,6 +175,7 @@ ds_biphasic_mean <- lapply(1:n_biphasic, c(parent = 100, m1 = 0), sampling_times) } ) +set.seed(123456) ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { add_err(ds, sdfunc = function(value) sqrt(err_1$const^2 + value^2 * err_1$prop^2), @@ -193,8 +198,18 @@ nlme_biphasic <- nlme(mmkin_biphasic) if (saemix_available) { sfo_saem_1 <- saem(mmkin_sfo_1, quiet = TRUE, transformations = "saemix") - dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin") - dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix") + # With default control parameters, we do not get good results with mkin + # transformations here + dfop_saemix_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin", + control = list( + displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE, + rw.init = 1, nbiter.saemix = c(600, 100)) + ) + dfop_saemix_2 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "saemix", + control = list( + displayProgress = FALSE, print = FALSE, save = FALSE, save.graphs = FALSE, + rw.init = 0.5, nbiter.saemix = c(600, 100)) + ) saem_biphasic_m <- saem(mmkin_biphasic, transformations = "mkin", quiet = TRUE) saem_biphasic_s <- saem(mmkin_biphasic, transformations = "saemix", quiet = TRUE) -- cgit v1.2.1 From d75378911cef79b3ed95daef71bf67db413d2ac8 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Wed, 17 Nov 2021 12:59:49 +0100 Subject: Update required saemix version, update tests --- tests/testthat/setup_script.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/testthat/setup_script.R') diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 96e865d4..cb3713aa 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -185,7 +185,7 @@ ds_biphasic <- lapply(ds_biphasic_mean, function(ds) { # Mixed model fits saemix_available <- FALSE if (requireNamespace("saemix", quietly = TRUE)) { - if(packageVersion("saemix") >= "3.1.9000") saemix_available <- TRUE + if(packageVersion("saemix") >= "3.0") saemix_available <- TRUE } mmkin_sfo_1 <- mmkin("SFO", ds_sfo, quiet = TRUE, error_model = "tc", cores = n_cores) mmkin_dfop_1 <- mmkin("DFOP", ds_dfop, quiet = TRUE, cores = n_cores) -- cgit v1.2.1