nlmixrdevelopment / nlmixr

nlmixr: an R package for population PKPD modeling
https://nlmixrdevelopment.github.io/nlmixr/
GNU General Public License v2.0
114 stars 45 forks source link

Difference for defining time-varying model parameters between saem and focei #578

Closed diabloyg closed 2 years ago

diabloyg commented 2 years ago

Hi @mattfidler , I am trying to build such time-varying clearance as follows:

cl <- exp(theta_cl+eta_cl)
clt <- cl*exp(theta_tmax*time/(theta_t50+time))

Such model worked pretty fine with focei. However when I was trying to use saem, I got messages:

Error in eval(substitute(expr), data, enclos = parent.frame()) : For SAEM: Initial parameters defined based on ini({}) block variables cannot be defined in terms of time; To fix:

  1. Define ini({}) variables/relationships first.
  2. Use the new variables in an time-based if/else clause later in the model({})

I am not sure how to deal with this. Could you please help me?

Besides, all of my packages are updated to the latest version on CRAN.

mattfidler commented 2 years ago

Hi @diabloyg

Without a reproducible example, it is harder to help.

Perhaps something like:

# prior parameter relationships
cl <-  exp(theta_cl+eta_cl)
tmax <- theta_tmax
t50 <- theta_t5
# Rest of the parameter relationships above
clt <- cl*exp(tmax*time/(t50+time)
# differentials below

Also, you may wish to use tad instead of time, though I am unsure how robust tad is....

mattfidler commented 2 years ago

I am attempting to make saem more robust and not require the mu-referencing. This type of example would be good to test against.

Thank you for reporting and reminding me of this. This would be true of entero-hepatic recycling too

diabloyg commented 2 years ago

Hi @mattfidler ,your suspection is right. After I rewrite the paramaters fully with mu-referencing format, the issue was resolved. It seems that the indication there is not relevant to the real cause. Thank you very much.

mattfidler commented 2 years ago

Great