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

translation of non mu referenced model #101

Open RichardHooijmaijers opened 9 months ago

RichardHooijmaijers commented 9 months ago

When translating a mu referenced model, everything works perfect. However I have been doing some testing with a model that does not have mu referencing and got an error message that I could not really explain. I have included a reproducible example below. Please let me know if you need some additional information

mumod <- 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({
    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)
  })
}

nonmumod <- function() {
  ini({
    tka <- 0.45   # Log Ka
    tcl <- 0.009     # Log Cl
    tv  <- 0.003     # Log V
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    prop.sd <- 0.7
  })
  model({
    ka <- tka * exp(eta.ka)
    cl <- tcl * exp(eta.cl)
    v <- tv * exp(eta.v)
    d/dt(depot) = -ka * depot
    d/dt(center) = ka * depot - cl / v * center
    cp = center / v
    cp ~ prop(prop.sd)
  })
}

So this works as expected:

dMod <- nlmixr2data::theo_sd
dMod_nozero <- dMod[(dMod$DV != 0 & dMod$EVID == 0) | (dMod$EVID == 101), ]

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

But got an error with the second model

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