nlmixr2 / babelmixr2

The goal of babelmixr2 is to interface nlmixr2 with other pharmacometric tools
https://nlmixr2.github.io/babelmixr2/
8 stars 1 forks source link

model with non informative ETA or if statement #102

Open RichardHooijmaijers opened 7 months ago

RichardHooijmaijers commented 7 months ago

I found an issue that might be related to #101 and/or the issue reported here. When having a model that fits oral and IV I am having problems in getting initial estimates. There is an easy work-around for this by getting initials for a model without the if statement and add the values afterwards but wanted to let you know what is going on. Find below the data and model that I have tested (this is the same as reported in the nlmixr2est issue):

dat <- structure(list(ID = c(11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 
                             12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, 21, 21, 21, 21, 
                             21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23), 
                      TIME = c(0, 0.05, 0.25, 0.5, 1, 3, 5, 0, 0.05, 0.25, 0.5, 
                               1, 3, 5, 0, 0.05, 0.25, 0.5, 1, 3, 5, 8, 0, 0.25, 0.5, 1, 3, 
                               5, 8, 0, 0.25, 0.5, 1, 3, 5, 8, 0, 0.25, 0.5, 1, 3, 5, 8), 
                      DV = c(NA,2017.85, 1323.74, 792.5, 822.72, 36.27, 3.33, NA, 1702, 1290.75, 
                             1095.95, 907.6, 125.44, 14.44, NA, 1933.04, 1242.43, 661.22, 
                             193.52, 1.75, NA, NA, NA, 706.58, 1063.14, 2257.62, 941.33, 629.69, 
                             100, NA, 1462.95, 2217.76, 2739.5, 705.3, 108.47, 8.75, NA, 211.66, 
                             467.23, 174.24, 153.6, 27.07, 2.81), 
                      AMT = c(1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 
                              0, 0, 5, 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0), 
                      EVID = c(1,0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 
                               1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0), 
                      CMT = c(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 1, 2, 
                              2, 2, 2, 2, 2), 
                      DOSE = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5), 
                      ROUTE = c(1, 1, 1, 1, 1, 1, 1,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2)), 
                 row.names = c(NA, -43L), class = "data.frame")

modA <- function() {
  ini({
    tka <- 0.45   # Log Ka
    tcl <- -7     # Log Cl
    tv  <- -8     # Log V
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    prop.sd <- 0.7
  })
  model({
    if(ROUTE!=1) ka <- exp(tka + eta.ka)
    cl <- exp(tcl + eta.cl)
    v <- exp(tv + eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ prop(prop.sd)
  })
}

modPknca1cmt <-
  nlmixr2(
    modA,
    data = dat2, est = "pknca",
    control = pkncaControl(ncaData = dMod, concu = "mg/L", doseu = "mg/kg", timeu = "hr", volumeu = "L/kg")
  )

As you can see the last step fails. When removing the if statements all work as expected

mattfidler commented 7 months ago

@billdenney

billdenney commented 7 months ago

There are several different pknca estimation limitations that I'm seeing when working with these data:

  1. The PKNCA estimation does not work with combination IV/oral administration.
  2. You do not have time 0 concentration data in your dataset, and the pknca estimation relies on that for AUC calculation.
  3. PKNCA estimation does not work if you have covariates in the model.

I'll start tackling each of these.