nlmixr2 / nonmem2rx

nonmem2rx
https://nlmixr2.github.io/nonmem2rx/
9 stars 0 forks source link

augPred with Fixed 0 Etas #149

Closed ColeCampton closed 1 year ago

ColeCampton commented 1 year ago

It seems like since fixed eta values are excluded from a fit nlmixr2 object the nonmem2rx::augPred method fails. Steps to reproduce:

  one.compartment <- function() {
  ini({
    tka <- log(1.57); label("Ka")
    tcl <- log(2.72); label("Cl")
    tv <- log(31.5); label("V")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ fix(0)
    add.sd <- 0.7
  })
  # and a model block with the error specification and model specification
  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 ~ add(add.sd)
  })
}
fit <- nlmixr2(one.compartment, theo_sd,  est="saem", saemControl(print=0))
 p<-augPred(fit)

Produces the following error:

 Error in rxSolveSEXP(object, .ctl, .nms, .xtra, params, events, inits,  : 
 The following parameter(s) are required for solving: eta.v

Note that the same error does not occur when the value of eta is fixed to a non-zero value (i.e. eta.v ~ fix(.1) instead).

Is there a simple work-around? It seems that it is not-straight forward to set the excluded etas in the fit object (fit$eta$eta.v <- 0 produces a size error).

Thank you

billdenney commented 1 year ago

Are you using the development or CRAN version? An issue that may be similar was recently fixed.

ColeCampton commented 1 year ago

This is with the CRAN version nonmem2rx_0.1.1. I will test with the development version. Edit: The issue seems to persist with the development versionnonmem2rx_0.1.1.9000.

mattfidler commented 1 year ago

I would also note the fix would not be in nonmem2rx but rather in nlmixr2est where the augPred() code lives (and also note that the generic function augPred() is from nlme, that is nlme::augPred() and may be re-exported elsewhere).

So, make sure you have the development version of nlmixr2est. The easiest way to install the development stack is through R-universe (as long as it hasn't been blocked by your organization):

install.packages(c("dparser", "nlmixr2data", "lotri", "rxode2ll",
                   "rxode2parse", "rxode2random", "rxode2et",
                   "rxode2", "nlmixr2est", "nlmixr2extra", "nlmixr2plot",
                   "nlmixr2", "nonmem2rx", "babelmixr2"),
                 repos = c('https://nlmixr2.r-universe.dev',
                           'https://cloud.r-project.org'))

If it still doesn't work, I will transfer this issue there and the work on it if I when I get some time for it.