diff --git a/tests/testthat/test-ui-mod-functions.R b/tests/testthat/test-ui-mod-functions.R index f7024e8d7..0baf281c0 100644 --- a/tests/testthat/test-ui-mod-functions.R +++ b/tests/testthat/test-ui-mod-functions.R @@ -660,4 +660,65 @@ rxTest({ }) + test_that("bind together 2 models with etas with overlapping etas w/cov in 2", { + + ocmt <- function() { + ini({ + tka <- 0.45 + tcl <- 1 + tv <- 3.45 + eta.ka ~ 0.1 + eta.v + eta.cl~ c(0.1, + 0.01, 0.1) + add.sd <- 0.7 + }) + model({ + ka <- exp(tka + eta.ka) + cl <- exp(tcl + eta.cl) + v <- exp(tv + eta.v) + d/dt(depot) = -ka * depot + d/dt(center) = ka * depot - cl / v * center + cp = center / v + cp ~ add(add.sd) + }) + } + + idr <- function() { + ini({ + tkin <- log(1) + tkout <- log(1) + tic50 <- log(10) + gamma <- fix(1) + idr.sd <- 1 + eta.kin ~ 0.1 + eta.kout ~ 0.1 + eta.ic50 ~ 0.1 + eta.v ~ 1 + }) + model({ + kin <- exp(tkin + eta.kin) + kout <- exp(tkout + eta.kout) + ic50 <- exp(tic50 + eta.ic50) + d/dt(eff) <- kin - kout*(1-ceff^gamma/(ic50^gamma+ceff^gamma) + eta.v) + eff ~ add(idr.sd) + }) + } + + m1 <- rxAppendModel(ocmt %>% model(ceff=cp,append=TRUE), idr) + + expect_equal(m1$omega, + lotri({ + eta.ka ~ 0.1 + eta.cl ~ 0.1 + eta.v ~ 0.1 + eta.kin ~ 0.1 + eta.kout ~ 0.1 + eta.ic50 ~ 0.1 + })) + + expect_equal(m1$theta, + c(tka = 0.45, tcl = 1, tv = 3.45, add.sd = 0.7, tkin = 0, tkout = 0, tic50 = 2.30258509299405, gamma = 1, idr.sd = 1)) + + }) + })