Skip to content

Commit

Permalink
Test when etas are shared
Browse files Browse the repository at this point in the history
  • Loading branch information
mattfidler committed Dec 1, 2023
1 parent dd278f3 commit 4a142df
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions tests/testthat/test-ui-mod-functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -478,5 +478,66 @@ rxTest({

})

test_that("bind together 2 models with etas with overlapping etas", {

ocmt <- function() {
ini({
tka <- 0.45
tcl <- 1
tv <- 3.45
eta.ka ~ 0.1
eta.cl ~ 0.1
eta.v ~ 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))

})


})

0 comments on commit 4a142df

Please sign in to comment.