UUPharmacometrics / assemblerr

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

Bug associated to user defined general pharmacometric model #18

Closed SimonBuatois closed 3 years ago

SimonBuatois commented 3 years ago

Hi,

I tried to create a PK model as follows and faced an issue:

If I write it like this it works well:

  prm_log_normal("KA") +
  prm_log_normal("CL") +
  prm_log_normal("V2") +
  prm_log_normal("Q") +
  prm_log_normal("V3") +
  compartment("dose") +
  compartment("central", volume = ~V2) +
  compartment("peripheral", volume = ~V3) +
  flow(from = "dose", to = "central", definition = ~KA*A )+
  flow(from = "central", definition = ~CL/V2*A) +
  flow(from = "central", to = "peripheral", definition = ~Q/V2*A) +
  flow(from = "peripheral", to = "central", definition = ~Q/V3*A) +
  obs_additive(conc~C["central"]) 

render(m)

Output:

$PROBLEM $INPUT ID TIME DV AMT $DATA data.csv IGNORE=@ $SUBROUTINES ADVAN4 TRANS4 $PK KA = THETA(1) EXP(ETA(1)) CL = THETA(2) EXP(ETA(2)) V2 = THETA(3) EXP(ETA(3)) Q = THETA(4) EXP(ETA(4)) V3 = THETA(5) * EXP(ETA(5)) KA = KA CL = CL V2 = V2 Q = Q V3 = V3 $ERROR CONC = A(2)/V2 Y = CONC + EPS(1) $ESTIMATION METHOD=COND INTER $COVARIANCE PRINT=E $THETA (0, 1, Inf) ; POP_KA $THETA (0, 1, Inf) ; POP_CL $THETA (0, 1, Inf) ; POP_V2 $THETA (0, 1, Inf) ; POP_Q $THETA (0, 1, Inf) ; POP_V3 $OMEGA 0.1; IIV_KA $OMEGA 0.1; IIV_CL $OMEGA 0.1; IIV_V2 $OMEGA 0.1; IIV_Q $OMEGA 0.1; IIV_V3 $SIGMA 0.1; RUV_ADD

If I add parentheses to the definition of the flows it fails:

  prm_log_normal("KA") +
  prm_log_normal("CL") +
  prm_log_normal("V2") +
  prm_log_normal("Q") +
  prm_log_normal("V3") +
  compartment("dose") +
  compartment("central", volume = ~V2) +
  compartment("peripheral", volume = ~V3) +
  flow(from = "dose", to = "central", definition = ~KA*A )+
  flow(from = "central", definition = ~(CL/V2)*A) +
  flow(from = "central", to = "peripheral", definition = ~(Q/V2)*A) +
  flow(from = "peripheral", to = "central", definition = ~(Q/V3)*A) +
  obs_additive(conc~C["central"]) 

render(m)

Output: $PROBLEM $INPUT ID TIME DV AMT $DATA data.csv IGNORE=@ $SUBROUTINES ADVAN4 TRANS4 $PK KA = THETA(1) EXP(ETA(1)) CL = THETA(2) EXP(ETA(2)) V2 = THETA(3) EXP(ETA(3)) Q = THETA(4) EXP(ETA(4)) V3 = THETA(5) * EXP(ETA(5)) KA = KA CL = (CL/V2) V2 = (CL/V2) Q = (Q/V3) V3 = (Q/V3) $ERROR CONC = A(2)/V2 Y = CONC + EPS(1) $ESTIMATION METHOD=COND INTER $COVARIANCE PRINT=E $THETA (0, 1, Inf) ; POP_KA $THETA (0, 1, Inf) ; POP_CL $THETA (0, 1, Inf) ; POP_V2 $THETA (0, 1, Inf) ; POP_Q $THETA (0, 1, Inf) ; POP_V3 $OMEGA 0.1; IIV_KA $OMEGA 0.1; IIV_CL $OMEGA 0.1; IIV_V2 $OMEGA 0.1; IIV_Q $OMEGA 0.1; IIV_V3 $SIGMA 0.1; RUV_ADD Warning messages: 1: In expr1 == expr2 : longer object length is not a multiple of shorter object length 2: In expr1 == expr2 : longer object length is not a multiple of shorter object length 3: In expr1 == expr2 : longer object length is not a multiple of shorter object length

If I use micro constants instead of macro constants it also fails:

  prm_log_normal("KA") +
  prm_log_normal("K") +
  prm_log_normal("K23") +
  prm_log_normal("K32") +
  prm_log_normal("V") +
  compartment("dose") +
  compartment("central", volume = ~V) +
  compartment("peripheral") +
  flow(from = "dose", to = "central", definition = ~KA*A )+
  flow(from = "central", definition = ~K*A) +
  flow(from = "central", to = "peripheral", definition = ~K23*A) +
  flow(from = "peripheral", to = "central", definition = ~K32*A) +
  obs_additive(conc~C["central"]) 

render(m)

Output:

$PROBLEM $INPUT ID TIME DV AMT $DATA data.csv IGNORE=@ $SUBROUTINES ADVAN4 TRANS4 $PK KA = THETA(1) EXP(ETA(1)) K = THETA(2) EXP(ETA(2)) K23 = THETA(3) EXP(ETA(3)) K32 = THETA(4) EXP(ETA(4)) V = THETA(5) * EXP(ETA(5)) KA = KA CL = K V2 = K Q = K32 V3 = K32 $ERROR CONC = A(2)/V Y = CONC + EPS(1) $ESTIMATION METHOD=COND INTER $COVARIANCE PRINT=E $THETA (0, 1, Inf) ; POP_KA $THETA (0, 1, Inf) ; POP_K $THETA (0, 1, Inf) ; POP_K23 $THETA (0, 1, Inf) ; POP_K32 $THETA (0, 1, Inf) ; POP_V $OMEGA 0.1; IIV_KA $OMEGA 0.1; IIV_K $OMEGA 0.1; IIV_K23 $OMEGA 0.1; IIV_K32 $OMEGA 0.1; IIV_V $SIGMA 0.1; RUV_ADD