Closed JohanWBorg closed 10 months ago
Hi @JohanWBorg
You don't actually need to convert this to an event table. You can use the data as is.
That being said this seems to be a bug. I actually could not remember that et(data frame)
would try to produce an event table. If you use this method you would loose all of your covariates so I don't recommend this approach in general.
Hi! Thanks for your quick response!
When running my model on it I did use the data as is (without any conversion to an event table). The purpose of converting it was mainly for debugging and trying to understand why the resulting values were off. It was through this I found the issue with the modeled rate/dur.
Thanks for reporting!
A reprex:
library(rxode2et)
d <- data.frame(id = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
time = c(0, 2, 12.5, 24.5, 37, 48, 60.5, 72.5, 85.3, 96.5, 108.5, 112.5),
amt = c(25, 0, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 0),
rate = c(-2, 0, -2, -2, -2, -2, -2, -2, -2, -2, -2, 0))
et(d)
#> ── EventTable with 12 records ──
#> 10 dosing records (see x$get.dosing(); add with add.dosing or et)
#> 2 observation times (see x$get.sampling(); add with add.sampling or et)
#> ── First part of x: ──
#> # A tibble: 12 × 4
#> id time amt evid
#> <int> <dbl> <dbl> <evid>
#> 1 1 0 25 1:Dose (Add)
#> 2 1 2 NA 0:Observation
#> 3 1 12.5 3.5 1:Dose (Add)
#> 4 1 24.5 3.5 1:Dose (Add)
#> 5 1 37 3.5 1:Dose (Add)
#> 6 1 48 3.5 1:Dose (Add)
#> 7 1 60.5 3.5 1:Dose (Add)
#> 8 1 72.5 3.5 1:Dose (Add)
#> 9 1 85.3 3.5 1:Dose (Add)
#> 10 1 96.5 3.5 1:Dose (Add)
#> 11 1 108. 3.5 1:Dose (Add)
#> 12 1 112. NA 0:Observation
Created on 2023-12-07 with reprex v2.0.2
Fixed in the development rxode2et
Works with this pull request
library(rxode2et)
d <- data.frame(id = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
time = c(0, 2, 12.5, 24.5, 37, 48, 60.5, 72.5, 85.3, 96.5, 108.5, 112.5),
amt = c(25, 0, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 3.5, 0),
rate = c(-2, 0, -2, -2, -2, -2, -2, -2, -2, -2, -2, 0))
et(d)
#> ── EventTable with 12 records ──
#> 10 dosing records (see x$get.dosing(); add with add.dosing or et)
#> 2 observation times (see x$get.sampling(); add with add.sampling or et)
#> ── First part of x: ──
#> # A tibble: 12 × 5
#> id time amt rate evid
#> <int> <dbl> <dbl> <rate/dur> <evid>
#> 1 1 0 25 -2:dur 1:Dose (Add)
#> 2 1 2 NA NA 0:Observation
#> 3 1 12.5 3.5 -2:dur 1:Dose (Add)
#> 4 1 24.5 3.5 -2:dur 1:Dose (Add)
#> 5 1 37 3.5 -2:dur 1:Dose (Add)
#> 6 1 48 3.5 -2:dur 1:Dose (Add)
#> 7 1 60.5 3.5 -2:dur 1:Dose (Add)
#> 8 1 72.5 3.5 -2:dur 1:Dose (Add)
#> 9 1 85.3 3.5 -2:dur 1:Dose (Add)
#> 10 1 96.5 3.5 -2:dur 1:Dose (Add)
#> 11 1 108. 3.5 -2:dur 1:Dose (Add)
#> 12 1 112. NA NA 0:Observation
Created on 2023-12-07 with reprex v2.0.2
Amazing! Thank you so much. I'll try it out as soon as possible.
Hi! I've encountered a possible bug in RxODE2 while trying to read a dataset with a rate column with a value of either -1 or -2. My dataset is looking like the following (subset of only one individual) :
Converting this to an event table using
et()
seems to ignore the 'rate' columnThis differs from how the EventTable looks like in the RxODE2 manual, where the rate column is also present with a value of -2.
I believe this might be a bug because if the value in the 'rate' column is changed to something positive (and hence not -2 or -1) it is correctly translated to the EventTable. Please take a look at the example below.
Naturally, with the missing rate column, the values of the results are off when trying to run a model on the dataset. I would much appreciate any comments or insights as to why the modeled rate seems to be missing.
Please let me know if there is any more information I can provide and many thanks in advance.