Skip to contents

To add additional compartments to the model

Usage

addComp(
  model,
  numPeripheral,
  central = "central",
  depot = "depot",
  peripheralComp = "peripheral",
  vp = "vp",
  vc = "vc",
  q = "q"
)

Arguments

model

The model as a function

numPeripheral

number of peripheral compartments to be added to the model

central

a character vector representing the central compartment

depot

a character vector representing the depot compartment

peripheralComp

A character vector representing the prefix of peripheral compartments

vp

parameter representing the peripheral volume of the first (central) compartment and the prefix of the other compartments

vc

parameter representing the central volume of the first (central) compartment and the prefix of the other compartment's volume

q

inter-compartmental clearance parameter or prefix (depending on the model)

Value

A rxode2 model function with an additional compartment added

Examples

readModelDb("PK_1cmt_des") |>
  addComp(1)
#>  
#>  
#>  promote `lvp` to population parameter with initial estimate 0.05
#>  change initial estimate of `lvp` to `0.05`
#>  promote `lq` to population parameter with initial estimate 0.05
#>  change initial estimate of `lq` to `0.05`
#>  ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>    lka    lcl    lvc propSd    lvp     lq 
#>   0.45   1.00   3.45   0.50   0.05   0.05 
#> 
#> States ($state or $stateDf): 
#>   Compartment Number Compartment Name
#> 1                  1          central
#> 2                  2      peripheral1
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     description <- "One compartment PK model with linear clearance using differential equations"
#>     ini({
#>         lka <- 0.45
#>         label("Absorption rate (Ka)")
#>         lcl <- 1
#>         label("Clearance (CL)")
#>         lvc <- 3.45
#>         label("Central volume of distribution (V)")
#>         propSd <- c(0, 0.5)
#>         label("Proportional residual error (fraction)")
#>         lvp <- 0.05
#>         lq <- 0.05
#>     })
#>     model({
#>         ka <- exp(lka)
#>         cl <- exp(lcl)
#>         vc <- exp(lvc)
#>         vp <- exp(lvp)
#>         q <- exp(lq)
#>         k12 <- q/vc
#>         k21 <- q/vp
#>         d/dt(central) <- ka * depot - kel * central + k21 * peripheral1 - 
#>             k12 * central
#>         d/dt(peripheral1) <- k12 * central - k21 * peripheral1
#>         Cc <- central/vc
#>         Cc ~ prop(propSd)
#>     })
#> }