metrumresearchgroup / mrgsolve

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

Complex dosing expected behavior or bug? #459

Closed mattfidler closed 5 years ago

mattfidler commented 5 years ago

Hi Kyle,

You have an interesting article about complex dosing here:

https://mrgsolve.github.io/blog/2017-complex-events.html

RxODE has something similar and I was cross-checking and came across an inconsistency in what you have done here.

There you have:

> e4 <- seq(e1, wait = 72, e2, wait = 72, e1)
> e4
. Events:
.   time cmt amt evid ii addl
. 1    0   1 100    1 24    6
. 2  240   1 200    1 24    6
. 3  480   1 100    1 24    6

Shouldn't it be 72 hours since the last dose, not 72 hours + ii?

If that is the case, I think you should have:

> e4
. Events:
.   time cmt amt evid ii addl
. 1    0   1 100    1 24    6
. 2  216   1 200    1 24    6
. 3  432   1 100    1 24    6

In psudo-code, the rule for RxODE is

if wait interval > last II use wait interval
else use wait interval + last II

I have an option to always add the last II but it is off by default.

Also, I'm unsure how long this has been implemented or used, if you change it, you may have to have some backward compatibility warning.

kylebaron commented 5 years ago

Hi @mattfidler -

That's been a part of the package for about a year and a half.

Shouldn't it be 72 hours since the last dose, not 72 hours + ii?

No; the behavior is ii + 72. You but you can get that behavior if you want.

Kyle

library(mrgsolve)

e0 <- ev(amt = 100)

e1 <- ev(amt = 100, ii = 24)

seq(e0, wait = 24, e0)
#> Events:
#>   time cmt amt evid ii addl
#> 1    0   1 100    1  0    0
#> 2   24   1 100    1  0    0

seq(e1, wait = 24, e0)
#> Events:
#>   time cmt amt evid ii addl
#> 1    0   1 100    1 24    0
#> 2   48   1 100    1  0    0

seq(e1, wait = 0, e0)
#> Events:
#>   time cmt amt evid ii addl
#> 1    0   1 100    1 24    0
#> 2   24   1 100    1  0    0

seq(e1, wait = -12, e0)
#> Events:
#>   time cmt amt evid ii addl
#> 1    0   1 100    1 24    0
#> 2   12   1 100    1  0    0

Created on 2019-02-14 by the reprex package (v0.2.1)

mattfidler commented 5 years ago

Ok.

vjd commented 5 years ago

seq(e1, wait = 24, e0)

> Events:

> time cmt amt evid ii addl

> 1 0 1 100 1 24 0

> 2 48 1 100 1 0 0

I did not expect that you can pass ii>0 when addl is 0? How does that make sense? Does it just mean that you are not giving an additional dose?

kylebaron commented 5 years ago

@vjd It was a way to delay the next intervention before we had that wait mechanism in there. I believe NONMEM will complain (maybe?) but mrgsolve won't.

kylebaron commented 5 years ago

@mattfidler I'm not sure what the default should be there. I can clarify the documentation or add an option. It is just isn't a bug.

mattfidler commented 5 years ago

That is fine; Its your choice.

It is not what I expected when reading the documentation. You said:

What if we want a 3-day holiday between each treatment period? Simply schedule a waiting period in the sequence:

I can see where it could mean a 3 day and then resume treatment after 24 hours, but when I read it initially I thought it meant a 3 day holiday and then immediately start treatment.

What do you think most people would think? I'm not sure. Perhaps a clarification should be sufficient.

I personally added an option that allows both.

mattfidler commented 5 years ago

By the way, I like the simplicity of seq/rep/c; you have done a good job with the event tables.