metrumresearchgroup / mrgsolve

Simulate from ODE-based population PK/PD and QSP models in R
https://mrgsolve.org
GNU General Public License v2.0
131 stars 36 forks source link

Issue with timing of change of time-varying variable (not related to nocb=T option) #1036

Open ssancheGH opened 1 year ago

ssancheGH commented 1 year ago

Hi,

I noticed an issue with the package (version 1.0.6). This concerns time-varying parameters/covariates (not related to the nocb option).

In dset (see attached image), ETA_F1_IOV is an interoccasion variability transformed into F_DEPOT for each dosing occasion using the .cpp equations. You can see from dset that the bioavailability parameter is meant to change at 168.0167 (then at 336.0, 504.0167, etc).
image

I then simulated concentrations using: sdata.frame <- mod %>% data_set(dset) %>% idata_set(iparams) %>% Req(CP,PPI,PctPPI,KA,F_DEPOT,DOSN) %>% mrgsim_df(end=2000, nocb=F,delta=0.05)

The issue: I compared simulation outputs between NONMEM and mrgsolve and there was no match. After simulating and outputting the bioavailability values at the different time points, you can notice that F_DEPOT changes from 0.3518 to 0.4151 after 168.0167. image

So the timing of the ETA_F1_IOV change is slightly off. It may not be an issue for most time-varying variables, but the timing of the change is quite important for bioavailability because I understand the total amount of absorbed drug is determined from the bioavailability at the time of dose administration. I solved the issue by adding 0 doses just before the timing of new doses and changing ETA_F1_IOV at that point (see attached). This resulted in a match between mrgsolve and NONMEM outputs. image

Do you have enough information to fix the issue? Let me know! Steven Sanche (PhD) Associate Director IDD, Certara Inc.

kylebaron commented 1 year ago

Hi @ssancheGH -

Thanks for reaching out. If you could create a reproducible example for this that I could run with you, I could definitely look into this.

We do have tests for time-varying covariates here https://github.com/mrgsolve/nmtests/blob/master/time-varying/time-varying-vignette.md

This test looks at time-varying covariates on disposition parameters.

I did open up an issue earlier that looked at how time-varying covariates should affect dosing events (like your example): https://github.com/metrumresearchgroup/mrgsolve/issues/808

At the end of that, I still couldn't tell if there was a problem or not and haven't had time to dig into it. I think if you can give me a minimal example that runs under NONMEM and mrgsolve it could give us a place to dig in and figure it out.

Thanks! Kyle