nlmixrdevelopment / nlmixr

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

convention for nmDataConvert and infusion data if RATE > 0 and DV specified #82

Closed mayerbry closed 6 years ago

mayerbry commented 6 years ago

I'm working with infusion data that I've previously fit with NONMEM. When using the nmDataConvert, I receive the following warning output "Warning message: In nmDataConvert(test_data) : Assumed all DV values are observations. (EVID=0)". It is not clear how DV should be coded to get the correct EVID specification (I believe 10101). Coding DV as NA or "." (NM spec) does not affect the outcome.

short example below:

library(nlmixr)

test_data = structure(list(ID = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1), TIME = c(0, 0.041667, 0.0625, 0.16667, 0.29167, 
0.41667, 0.54167, 1, 2, 6, 7, 14, 21, 28, 42, 84, 119, 142, 168
), DV = c(0, 74.15, 69.09, 49.96, 50.75, 50, 45.56, 42.08, 36.77, 
24.99, 23.01, 16.31, 12.4, 11.64, 6.04, 1.54, 0.53, 0.2, 0.2), 
    AMT = c(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0), RATE = c(6120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, 19L), class = "data.frame")

input_data = nmDataConvert(test_data)

and output:

Warning message:
In nmDataConvert(test_data) :
  Assumed all DV values are observations. (EVID=0)

> head(input_data, 2)

   ID       TIME DV   AMT  RATE EVID
1   1 0.00000000  0  6120  6120    0
21  1 0.04166667  0 -6120 -6120    0

I then just manually recode those EVIDs to 10101.

Relatedly, any additional documentation/tutorial/examples for infusion data would be greatly appreciated, especially EVID specification. I've been figuring out the rxode data requirements by reading various presentations with trial and error. nlmixr has been great and I'm trying to completely convert over. So far the data specs has been my main bottleneck.

Thanks so much! Bryan

mattfidler commented 6 years ago

This is a work-around for now. When writing the converted, AMT=0 implies EVID=0. This was not handled with the nmDataConvert.

mattfidler commented 6 years ago

This has been fixed in the github version:

library(nlmixr)

test_data = structure(list(ID = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1), TIME = c(0, 0.041667, 0.0625, 0.16667, 0.29167, 
0.41667, 0.54167, 1, 2, 6, 7, 14, 21, 28, 42, 84, 119, 142, 168
), DV = c(0, 74.15, 69.09, 49.96, 50.75, 50, 45.56, 42.08, 36.77, 
24.99, 23.01, 16.31, 12.4, 11.64, 6.04, 1.54, 0.53, 0.2, 0.2), 
    AMT = c(255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0), RATE = c(6120, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 0)), row.names = c(NA, 19L), class = "data.frame")

input_data = nmDataConvert(test_data)
head(input_data, 4)

Now gives:

> input_data = nmDataConvert(test_data)
Warning message:
In nmDataConvert(test_data) :
  Assumed all AMT=0 values are observations. (EVID=0)
> head(input_data, 4)
   ID       TIME    DV   AMT  RATE  EVID
1   1 0.00000000  0.00  6120  6120 10101
21  1 0.04166667  0.00 -6120 -6120 10101
2   1 0.04166700 74.15     0     0     0
3   1 0.06250000 69.09     0     0     0
mattfidler commented 6 years ago

Note that EVIDs for RxODE are described here:

https://nlmixrdevelopment.github.io/RxODE/articles/RxODE-events.html

We were going to eventually transition to NONMEM-style events, so we haven't emphasized the documentation as much as we used to. The EVID is also described in the page courses in the RxODE presentation:

https://github.com/nlmixrdevelopment/PAGE-2018/blob/master/Presentations_PAGE2018.zip

Thank you for pointing out a case we missed, that is missing MDV and EVID, AMT=0 assumes EVID=0. Once that was fixed in the converter everything seems to work much better.

Here are the current limitations of nlmixr/RxODE when it comes to infusions and dosing events

mattfidler commented 6 years ago

Feel free to test this and make sure it works for you. Also feel free to post if you have any more questions.

mayerbry commented 6 years ago

Thanks for addressing this and for the extra documentation for RxODE event id coding. Updated nmDataConvert works great, thanks!