[Experimental]

Makes the necessary code changes to go from one ADVAN (and TRANS) to another.

subroutine(m, advan = NA, trans = 1, recursive = TRUE)

Arguments

m

An nm object.

advan

Character. desired ADVAN.

trans

Character. desired TRANS.

recursive

Logical (default = TRUE). Internal argument, do not modify.

Value

An nm object with modified ctl_contents field.

Details

Can only switch between subroutines listed in available_advans.

See also

Examples


# create example object m1 from package demo files
exdir <- system.file("extdata", "examples", "theopp", package = "NMproject")
m1 <- new_nm(run_id = "m1",
             based_on = file.path(exdir, "Models", "ADVAN2.mod"),
             data_path = file.path(exdir, "SourceData", "THEOPP.csv"))


advan(m1) ## 2
#> [1] 2
trans(m1) ## 1
#> [1] 1

m1 <- m1 %>% subroutine(advan = 2, trans = 2)

ds <- .available_advans %>%
  dplyr::filter(oral) %>%
  dplyr::mutate(
    m = m1 %>% child(run_id = label) %>%
      subroutine(advan = advan, trans = trans)
  )

ds
#> # A tibble: 7 × 7
#>   advan trans   cmt oral  params                  label m              
#>   <dbl> <dbl> <dbl> <lgl> <chr>                   <chr> <nm_list>      
#> 1     2     1     1 TRUE  KA,K,V                  a2t1  <nm_exect [23]>
#> 2     2     2     1 TRUE  KA,CL,V                 a2t2  <nm_exect [23]>
#> 3     4     1     2 TRUE  KA,K,K23,K32,V2         a4t1  <nm_exect [23]>
#> 4     4     3     2 TRUE  KA,CL,Q,V,VSS           a4t3  <nm_exect [23]>
#> 5     4     4     2 TRUE  KA,CL,Q,V2,V3           a4t4  <nm_exect [23]>
#> 6    12     1     3 TRUE  KA,K,K23,K32,K24,K42,V2 a12t1 <nm_exect [23]>
#> 7    12     4     3 TRUE  KA,CL,Q3,V2,V3,Q4,V4    a12t4 <nm_exect [23]>

ds$m %>% dollar("PK")
#> $`execute.Models/a2t1`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVK=EXP(THETA(2))
#>   8| MU_2=LOG(TVK)
#>   9| K = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV=EXP(THETA(3))
#>  12| MU_3=LOG(TVV)
#>  13| V = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V
#>  18| 
#> 
#> $`execute.Models/a2t2`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVCL=EXP(THETA(2))
#>   8| MU_2=LOG(TVCL)
#>   9| CL = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV=EXP(THETA(3))
#>  12| MU_3=LOG(TVV)
#>  13| V = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V
#>  18| 
#> 
#> $`execute.Models/a4t1`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVK=EXP(THETA(2))
#>   8| MU_2=LOG(TVK)
#>   9| K = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV2=EXP(THETA(3))
#>  12| MU_3=LOG(TVV2)
#>  13| V2 = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V2
#>  18| 
#>  19| TVK23=EXP(THETA(4))
#>  20| MU_4=LOG(TVK23)
#>  21| K23 = EXP(MU_4+ETA(4))
#>  22| TVK32=EXP(THETA(5))
#>  23| MU_5=LOG(TVK32)
#>  24| K32 = EXP(MU_5+ETA(5))
#> 
#> $`execute.Models/a4t3`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVCL=EXP(THETA(2))
#>   8| MU_2=LOG(TVCL)
#>   9| CL = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV=EXP(THETA(3))
#>  12| MU_3=LOG(TVV)
#>  13| V = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V
#>  18| 
#>  19| TVQ=EXP(THETA(4))
#>  20| MU_4=LOG(TVQ)
#>  21| Q = EXP(MU_4+ETA(4))
#>  22| TVVSS=EXP(THETA(5))
#>  23| MU_5=LOG(TVVSS)
#>  24| VSS = EXP(MU_5+ETA(5))
#> 
#> $`execute.Models/a4t4`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVCL=EXP(THETA(2))
#>   8| MU_2=LOG(TVCL)
#>   9| CL = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV2=EXP(THETA(3))
#>  12| MU_3=LOG(TVV2)
#>  13| V2 = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V2
#>  18| 
#>  19| TVQ=EXP(THETA(4))
#>  20| MU_4=LOG(TVQ)
#>  21| Q = EXP(MU_4+ETA(4))
#>  22| TVV3=EXP(THETA(5))
#>  23| MU_5=LOG(TVV3)
#>  24| V3 = EXP(MU_5+ETA(5))
#> 
#> $`execute.Models/a12t1`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVK=EXP(THETA(2))
#>   8| MU_2=LOG(TVK)
#>   9| K = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV2=EXP(THETA(3))
#>  12| MU_3=LOG(TVV2)
#>  13| V2 = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V2
#>  18| 
#>  19| TVK23=EXP(THETA(4))
#>  20| MU_4=LOG(TVK23)
#>  21| K23 = EXP(MU_4+ETA(4))
#>  22| TVK32=EXP(THETA(5))
#>  23| MU_5=LOG(TVK32)
#>  24| K32 = EXP(MU_5+ETA(5))
#>  25| TVK24=EXP(THETA(6))
#>  26| MU_6=LOG(TVK24)
#>  27| K24 = EXP(MU_6+ETA(6))
#>  28| TVK42=EXP(THETA(7))
#>  29| MU_7=LOG(TVK42)
#>  30| K42 = EXP(MU_7+ETA(7))
#> 
#> $`execute.Models/a12t4`
#>   1| $PK
#>   2| 
#>   3| TVKA=EXP(THETA(1))
#>   4| MU_1=LOG(TVKA)
#>   5| KA = EXP(MU_1+ETA(1))
#>   6| 
#>   7| TVCL=EXP(THETA(2))
#>   8| MU_2=LOG(TVCL)
#>   9| CL = EXP(MU_2+ETA(2))
#>  10| 
#>  11| TVV2=EXP(THETA(3))
#>  12| MU_3=LOG(TVV2)
#>  13| V2 = EXP(MU_3+ETA(3))
#>  14| 
#>  15| ; CL = K*V
#>  16| 
#>  17| S2 = V2
#>  18| 
#>  19| TVQ3=EXP(THETA(4))
#>  20| MU_4=LOG(TVQ3)
#>  21| Q3 = EXP(MU_4+ETA(4))
#>  22| TVV3=EXP(THETA(5))
#>  23| MU_5=LOG(TVV3)
#>  24| V3 = EXP(MU_5+ETA(5))
#>  25| TVQ4=EXP(THETA(6))
#>  26| MU_6=LOG(TVQ4)
#>  27| Q4 = EXP(MU_6+ETA(6))
#>  28| TVV4=EXP(THETA(7))
#>  29| MU_7=LOG(TVV4)
#>  30| V4 = EXP(MU_7+ETA(7))
#>