Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle EVID4 doses at steady state with lag time #1262

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kylebaron
Copy link
Collaborator

@kylebaron kylebaron commented Feb 22, 2025

EVID===4 resets the system and then doses. SS==1 advances the system to steady-state and then doses. The current behavior is that EVID 4 records at steady state act just like EVID 1 records at steady state; this was confirmed by testing against NONMEMs behavior.

It was noted in #1261 that, when there is also a lag time for the dose, mrgsolve was dosing as immediately after reset rather than immediately after advancing to steady state. This PR fixes that behavior.

Some terminology / background

  • A dose that is not Armed means there appears to be a dose at that time, but nothing is actually dosed; this is in place at the time of the apparent dose
  • When there is a lagged dose, we disarm the apparent dosing record, then schedule a dose or series of doses at the lag time; these are "phantom" records that actually implement a dose some time after the apparent dose
  1. In the dose implement method, if the record is not Armed, we just break out; there is nothing to reset and we don't want to go on and dose after that reset
  2. In the main simulation code, lagged doses all lose the ss flag and they are all converted in to evid 1, to act like vanilla dosing records

Confirming that we now match up with NONMEM here:
https://github.com/mrgsolve/nmtests/blob/master/dosing/dosing-vignette.md#23-reset-and-dose-evid-4-with-ss1-and-lag

And the mis-match prior to fixing here:
mrgsolve/nmtests@fc464d8#diff-f9292bfdbc09d870158ed0c0760957e19c4161d00f623e1c4b143ba83503a400

Also, there is a unit test showing that steady state doses with a lag time are identical whether EVID is 1 or 4.

@kylebaron kylebaron linked an issue Feb 27, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System won't go to steady state with EVID=4
1 participant