nlmixr2 / nlmixr2est

nlmixr2 estimation routines
https://nlmixr2.github.io/nlmixr2est/
GNU General Public License v2.0
7 stars 3 forks source link

Warnings suppressed when using `nlmixr2` with "rxSolve" estimation method. #453

Closed mattfidler closed 3 months ago

mattfidler commented 4 months ago
# This is an example to simulate and estimate dual first order
# and zero order absorption

library(nlmixr2)
#> Warning: package 'nlmixr2' was built under R version 4.3.3
#> Loading required package: nlmixr2data
#> Warning: package 'nlmixr2data' was built under R version 4.3.3

library(rxode2)
#> Warning: package 'rxode2' was built under R version 4.3.3
#> rxode2 2.1.3 using 4 threads (see ?getRxThreads)
#>   no cache: create with `rxCreateCache()`
set.seed(123)
rxSetSeed(123)

# Setup the rxode2 event table
eventTable <- et(amt=320, evid=1, cmt=20, time = 0) %>% # nolint: object_name_linter.
  et(2, 4)

# Now define the nlmixr2/rxode2 model used for both estimation and simulation
mod <- function() {
  # Parameters
  ini({
    tka <- 0.45; label("Ka (first order absorption)")
    trate <- 0.4 ; label("Zero order rate")
    tcl <- 1; label("Cl")
    tv <- 3.45; label("V")
    fDepot <- logit(0.5) ; label("amount of dose in first order absorption")
    eta.ka ~ 0.6
    eta.cl ~ 0.3
    eta.v ~ 0.1
    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

    f(depot) <- expit(fDepot)
    f(center) <- 1-expit(fDepot)
    rate(center) <- exp(trate)

    cp = center / v
    cp ~ add(add.sd)
  })
}

mod <- mod()

# Solving data with nlmixr2 suppresses all warnings
d <- nlmixr2(mod, eventTable, "rxSolve", control = rxControl(addDosing = TRUE))

# But solving with rxSolve does not
d2 <- rxSolve(mod, eventTable, addDosing=TRUE)
#> Warning: dose to compartment 20 ignored (not in system; 'id=1')

Created on 2024-07-22 with reprex v2.1.0

billdenney commented 4 months ago

Why would that not be an error? It seems like an unintentional issue with a dataset that should be corrected.

mattfidler commented 4 months ago

It has always been a warning. I don't like breaking changes. It is already there, I just didn't see it in my particular use case

mattfidler commented 4 months ago

I saw it in my fit, though.

mattfidler commented 4 months ago

You can see with rxSolve() no warnings are suppressed, though with nlmixr2(...,est="rxSolve") warnings are suppressed. (note I added it at the beginning of issue).