Skip to contents

To remove peripheral compartments from the model

Usage

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

Arguments

model

The model as a function

peripheral

The number of peripheral compartments to remove

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

rxode2 model function/ui with a compartment removed

Examples

library(rxode2)
readModelDb("PK_2cmt_des") |> removeComp(1)
#>  
#>  
#>  ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>    lka    lcl    lvc propSd 
#>   0.45   1.00   3.00   0.50 
#> 
#> States ($state or $stateDf): 
#>   Compartment Number Compartment Name
#> 1                  1            depot
#> 2                  2          central
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     description <- "Two compartment PK model with linear clearance using differential equations"
#>     ini({
#>         lka <- 0.45
#>         label("Absorption rate (Ka)")
#>         lcl <- 1
#>         label("Clearance (CL)")
#>         lvc <- 3
#>         label("Central volume of distribution (V)")
#>         propSd <- c(0, 0.5)
#>         label("Proportional residual error (fraction)")
#>     })
#>     model({
#>         ka <- exp(lka)
#>         cl <- exp(lcl)
#>         vc <- exp(lvc)
#>         kel <- cl/vc
#>         d/dt(depot) <- -ka * depot
#>         d/dt(central) <- ka * depot - kel * central
#>         Cc <- central/vc
#>         Cc ~ prop(propSd)
#>     })
#> }