FelicienLL / mapbayr

Easy Maximum A Posteriori Bayesian Estimation of PK parameters in R.
21 stars 2 forks source link

.datehour not updated with TOLA / AOLA covariates #194

Closed LauraMvn closed 1 year ago

LauraMvn commented 1 year ago

Hello, When there is a TOLA/AOLA covariate in a model, .datehour will not be updated along with addl if we don't specify "realize_addl = TRUE" in adm_rows().

mod1 <- mrgsolve::mcode("mod", "$PARAM @annotated @covariates
                        TOLA : 0 : time last adm")
#> Building mod ... done.
library(magrittr)
library(mapbayr)
#> 
#> Attachement du package : 'mapbayr'
#> 
#> L'objet suivant est masqué depuis 'package:stats':
#> 
#>     filter
mod1 %>% 
  adm_rows(amt = 100, cmt = 1, addl = 3, ii = 24, .datehour = "12/12/2012 12:12") %>% 
  add_covariates() %>% 
  get_data()
#> # A tibble: 4 × 10
#>      ID  time  evid   cmt   amt   mdv  addl    ii .datehour            TOLA
#>   <int> <dbl> <int> <int> <dbl> <int> <dbl> <dbl> <dttm>              <dbl>
#> 1     1     0     1     1   100     1     0     0 2012-12-12 12:12:00     0
#> 2     1    24     1     1   100     1     0     0 2012-12-12 12:12:00    24
#> 3     1    48     1     1   100     1     0     0 2012-12-12 12:12:00    48
#> 4     1    72     1     1   100     1     0     0 2012-12-12 12:12:00    72
# With realize_addl = TRUE
mod1 %>% 
  adm_rows(amt = 100, cmt = 1, addl = 3, ii = 24, .datehour = "12/12/2012 12:12", realize_addl = TRUE) %>% 
  add_covariates() %>% 
  get_data()
#> # A tibble: 4 × 10
#>      ID  time  evid   cmt   amt   mdv  addl    ii .datehour            TOLA
#>   <int> <dbl> <int> <int> <dbl> <int> <dbl> <dbl> <dttm>              <dbl>
#> 1     1     0     1     1   100     1     0     0 2012-12-12 12:12:00     0
#> 2     1    24     1     1   100     1     0     0 2012-12-13 12:12:00    24
#> 3     1    48     1     1   100     1     0     0 2012-12-14 12:12:00    48
#> 4     1    72     1     1   100     1     0     0 2012-12-15 12:12:00    72

Created on 2023-03-31 with reprex v2.0.2