mrgsolve icon indicating copy to clipboard operation
mrgsolve copied to clipboard

SS=1 happens before system is reset EVID=4 on the same record

Open benjaminrich opened this issue 3 years ago • 3 comments

A small example:

library(mrgsolve)

mod <- mread_cache("pk1", modlib())

dat <- read.table(header=T, text="
ID TIME CMT AMT EVID SS II
 1    0   1 100    4  1 12
 2    0   1 100    1  1 12
 3    0   1 100    4  0  0
 4    0   1 100    1  0  0
")

sim <- mod |>
  data_set(dat) |>
  mrgsim(end=5)

all(sim$CP[sim$ID==1] == sim$CP[sim$ID==2]) ## [1] FALSE
all(sim$CP[sim$ID==1] == sim$CP[sim$ID==3]) ## [1] TRUE
all(sim$CP[sim$ID==1] == sim$CP[sim$ID==4]) ## [1] TRUE

For ID=1, I was expecting the result to be identical to ID=2 (as in NONMEM). Instead, it gave the same result as ID=3 and ID=4.

benjaminrich avatar Aug 18 '22 17:08 benjaminrich

Thanks, @benjaminrich; I'll take a look.

kylebaron avatar Aug 18 '22 17:08 kylebaron

It looks like mrgsolve is advancing to steady state then resetting then dosing.

Confirming the NONMEM behavior here: https://github.com/mrgsolve/nmtests/blob/master/dosing/dosing-vignette.md#21-reset-and-dose-evid-4-with-ss1

Link isn't working; but it is case 21 Screen Shot 2022-08-18 at 2 42 04 PM

kylebaron avatar Aug 18 '22 19:08 kylebaron

Make sure the fix matches this too: Screen Shot 2022-08-18 at 2 47 02 PM

kylebaron avatar Aug 18 '22 19:08 kylebaron