UUPharmacometrics / assemblerr

Quickly assemble pharmacometric models
https://uupharmacometrics.github.io/assemblerr/
Other
10 stars 4 forks source link

Bugs with the function prm_no_var #23

Closed cossonvalerie closed 3 years ago

cossonvalerie commented 3 years ago

I did a couple of tests with the function prm_no_var, to get rid of some BSV on parameters. Depending in which the functions (pk_absorption_fo_transit or pk_distribution_3cmp) the function prm_no_var is embedded or depending on the parameters affected by the prm_no_var or if the parameter name is written with upper cases or lower cases, I get the NM code I expected or not

Trying the function prm_no_var on mat and vc (or written VC) I get the expected NM control file

pkmb <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp(prm_no_var("vc")) + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb) render(pkmb)

Trying with another parameter, q1

pkmb2 <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp(prm_no_var("q1")) + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb2) render(pkmb2)

I get the following message and nothing is done, there is still BSV on Q1

Warning message: Building block replaced x The building block [q1: no variability] has been replaced with [q1: log-normal]

When the parameter q1 is written with upper case, No warning but an additional parameter is created

pkmb3 <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp(prm_no_var("Q1")) + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb3) render(pkmb3)

$PK MDT = THETA(1) EXP(ETA(1)) MAT = THETA(2) Q1 = THETA(3) VP1 = THETA(4) EXP(ETA(2)) VP2 = THETA(5) EXP(ETA(3)) Q1 = THETA(6) EXP(ETA(4)) Q2 = THETA(7) EXP(ETA(5)) CLIN = THETA(8) EXP(ETA(6)) VMAX = THETA(9) EXP(ETA(7)) KM = THETA(10) EXP(ETA(8)) KTR = 3/MDT KA = 1/MAT (...) $THETA (0, 0.5, Inf) ; POP_MDT $THETA (0, 1, Inf) ; POP_MAT $THETA (0, 1, Inf) ; POP_Q1 $THETA (0, 5, Inf) ; POP_VP1 $THETA (0, 5, Inf) ; POP_VP2 $THETA (0, 25, Inf) ; POP_Q1 $THETA (0, 25, Inf) ; POP_Q2 $THETA (0, 50, Inf) ; POP_CLIN $THETA (0, 10, Inf) ; POP_VMAX $THETA (0, 0.5, Inf) ; POP_KM

Trying with the function not embedded in pk_distribution_3cmp() and upper case, No warning but an additional parameter is created as above

pkmb4 <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp() + prm_no_var("Q1") + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb4) render(pkmb4)

Trying with the function not embedded in pk_distribution_3cmp() and lower case, there NM code as expected

pkmb5 <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp() + prm_no_var("q1") + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb5) render(pkmb5)

Finally trying the function not embedded in pk_distribution_3cmp() and lower case with another parameter, clin, there is still BSV on CLIN

pkmb6 <- pk_model() + pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) + pk_distribution_3cmp() + prm_no_var("clin") + pk_elimination_linear_mm() + obs_proportional(conc~C["central"]) check(pkmb6) render(pkmb6)

sebastianueckert commented 3 years ago

I think there are two issues with these examples:

  1. assemblerr is case sensitive (i.e., q1 and Q1 are two different parameters)
  2. when providing the parameter name to the function, one needs to pay attention to the argument order or use named arguments so the following should work
pkmb2 <- pk_model() +
    pk_absorption_fo_transit(transit_compartments = 3, prm_no_var("mat")) +
    pk_distribution_3cmp(prm_q1 = prm_no_var("q1")) +
    pk_elimination_linear_nl() +
    obs_proportional(conc~C["central"])
check(pkmb2)
render(pkmb2)