Skip to contents

Removes peripheral2 (or peripheral1 when it is the only one), rewiring the central compartment and dropping the associated parameters. peripheral1 cannot be removed while peripheral2 is still present.

Usage

removePeriph(ui, n = NULL, central = "central", model)

Arguments

ui

The model as a function (or something convertible to an rxUi object)

n

which peripheral to remove: 1 or 2; defaults to the highest-numbered one present

central

central compartment name

model

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

Value

a model with the peripheral compartment removed

See also

Other Distribution and elimination building blocks: addCmtProp(), addPeriph(), convertMM()

Author

Matthew L. Fidler

Examples

pk2cmtDes <- function() {
  ini({
    lka <- 0.45; label("Absorption rate (Ka)")
    lcl <- 1; label("Clearance (CL)")
    lvc <- 3; label("Central volume of distribution (V)")
    lvp <- 5; label("Peripheral volume of distribution (Vp)")
    lq <- 0.1; label("Intercompartmental clearance (Q)")
    propSd <- 0.5; label("Proportional residual error (fraction)")
  })
  model({
    ka <- exp(lka)
    cl <- exp(lcl)
    vc <- exp(lvc)
    vp <- exp(lvp)
    q <- exp(lq)
    kel <- cl / vc
    k12 <- q / vc
    k21 <- q / vp
    d/dt(depot) <- -ka * depot
    d/dt(central) <- ka * depot - kel * central - k12 * central + k21 * peripheral1
    d/dt(peripheral1) <- k12 * central - k21 * peripheral1
    Cc <- central / vc
    Cc ~ prop(propSd)
  })
}


pk2cmtDes |> removePeriph()
#>  
#>  
#> ℹ 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.00   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
#>         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)
#>     })
#> }