aboutsummaryrefslogtreecommitdiff
path: root/tests/testthat/test_mixed.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2020-12-08 22:08:38 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2020-12-08 22:08:38 +0100
commitf606838c5310f365eea1c0d6421f5c3636a4dc79 (patch)
treebdf4fdb5cb3a94cc46176f9e69132af11e81f749 /tests/testthat/test_mixed.R
parent2663158c85fca9c088d1f8cfa3bc05ad1ac36f94 (diff)
mixed.mmkin and test coverage
Diffstat (limited to 'tests/testthat/test_mixed.R')
-rw-r--r--tests/testthat/test_mixed.R35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/testthat/test_mixed.R b/tests/testthat/test_mixed.R
new file mode 100644
index 00000000..2d69e13e
--- /dev/null
+++ b/tests/testthat/test_mixed.R
@@ -0,0 +1,35 @@
+context("Fitting of nonlinear mixed effects models")
+
+sampling_times = c(0, 1, 3, 7, 14, 28, 60, 90, 120)
+n_biphasic <- 8
+err_1 = list(const = 1, prop = 0.07)
+
+DFOP_SFO <- mkinmod(
+ parent = mkinsub("DFOP", "m1"),
+ m1 = mkinsub("SFO"),
+ quiet = TRUE)
+
+set.seed(123456)
+log_sd <- 0.3
+syn_biphasic_parms <- as.matrix(data.frame(
+ k1 = rlnorm(n_biphasic, log(0.05), log_sd),
+ k2 = rlnorm(n_biphasic, log(0.01), log_sd),
+ g = plogis(rnorm(n_biphasic, 0, log_sd)),
+ f_parent_to_m1 = plogis(rnorm(n_biphasic, 0, log_sd)),
+ k_m1 = rlnorm(n_biphasic, log(0.002), log_sd)))
+
+ds_biphasic_mean <- lapply(1:n_biphasic,
+ function(i) {
+ mkinpredict(DFOP_SFO, syn_biphasic_parms[i, ],
+ c(parent = 100, m1 = 0), sampling_times)
+ }
+)
+
+set.seed(123456L)
+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),
+ n = 1, secondary = "m1")[[1]]
+})
+
+f_mmkin <- mmkin(list("DFOP-SFO" = DFOP_SFO), ds_biphasic, quiet = TRUE)

Contact - Imprint