Skip to contents

To remove transit compartments from the model

Usage

removeTransit(
  ui,
  ntransit,
  central = "central",
  depot = "depot",
  transit = "transit",
  ktr = "ktr",
  ka = "ka",
  model
)

Arguments

ui

The model as a function

ntransit

the number of transit compartments to be added

central

central compartment name

depot

depot compartment name

transit

The number of transit compartments to remove

ktr

the parameter name for the transit compartment rate

ka

absorption rate parameter name

model

Deprecated alias for ui. Supplying model instead of ui still works but emits a deprecation warning.

Value

rxode2 model with transit compartment removed

Examples

pk1cmtDes <- function() {
  ini({
    lka <- 0.45; label("Absorption rate (Ka)")
    lcl <- 1; label("Clearance (CL)")
    lvc <- 3.45; label("Central volume of distribution (V)")
    propSd <- 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)
  })
}


# In this example the transit is added and then a few are removed

pk1cmtDes |> addTransit(4) |> removeTransit(3)
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#>  ── rxode2-based free-form 3-cmt ODE model ────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>    lka    lcl    lvc propSd   lktr 
#>   0.45   1.00   3.45   0.50   0.10 
#> 
#> States ($state or $stateDf): 
#>   Compartment Number Compartment Name
#> 1                  1            depot
#> 2                  2         transit1
#> 3                  3          central
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     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)")
#>         lktr <- 0.1
#>         label("First order transition rate (ktr)")
#>     })
#>     model({
#>         ka <- exp(lka)
#>         cl <- exp(lcl)
#>         vc <- exp(lvc)
#>         kel <- cl/vc
#>         ktr <- exp(lktr)
#>         d/dt(depot) <- -ktr * depot
#>         d/dt(transit1) <- ktr * depot - ktr * transit1
#>         d/dt(central) <- ka * transit1 - kel * central
#>         Cc <- central/vc
#>         Cc ~ prop(propSd)
#>     })
#> }

pk1cmtDes |> addTransit(4) |> removeTransit()
#>  
#>  
#> ℹ parameter labels from comments are typically ignored in non-interactive mode
#> ℹ Need to run with the source intact to parse comments
#>  ── rxode2-based free-form 2-cmt ODE model ────────────────────────────────────── 
#>  ── Initalization: ──  
#> Fixed Effects ($theta): 
#>    lka    lcl    lvc propSd 
#>   0.45   1.00   3.45   0.50 
#> 
#> States ($state or $stateDf): 
#>   Compartment Number Compartment Name
#> 1                  1            depot
#> 2                  2          central
#>  ── Model (Normalized Syntax): ── 
#> function() {
#>     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)")
#>     })
#>     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)
#>     })
#> }