Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow simulation from completely empty time grid #648

Closed
kylebaron opened this issue Mar 10, 2020 · 3 comments
Closed

Allow simulation from completely empty time grid #648

kylebaron opened this issue Mar 10, 2020 · 3 comments

Comments

@kylebaron
Copy link
Collaborator

kylebaron commented Mar 10, 2020

Summary

SOLUTION:

  • refactor render_time so that it is more efficient and can return numeric(0) if there are really no times
  • We will still simulate a minimum time 0 record for each person by only if not doing so would result in zero rows in the output

Tests

  • tests/testthat/test-tgrid.R
    • stime can render length 0
    • no extra time 0 record when no observations
@kylebaron kylebaron self-assigned this Mar 10, 2020
@kylebaron kylebaron added this to Backlog in Development Mar 10, 2020
@kylebaron kylebaron added this to the Release 0.10.2 milestone Mar 10, 2020
@kylebaron kylebaron moved this from Backlog to Implement in Development Mar 15, 2020
kylebaron added a commit that referenced this issue Mar 15, 2020
@kylebaron
Copy link
Collaborator Author

library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter

mod <- house(end = 24)

dose <- ev(amt = 0, ii = 1, addl = 4,evid=2) %>% realize_addl()

dose
#> Events:
#>   time amt ii addl cmt evid
#> 1    0   0  0    0   1    2
#> 2    1   0  0    0   1    2
#> 3    2   0  0    0   1    2
#> 4    3   0  0    0   1    2
#> 5    4   0  0    0   1    2

mod %>% mrgsim(ev = dose, end = -1)
#> Model:  housemodel 
#> Dim:    6 x 7 
#> Time:   0 to 4 
#> ID:     1 
#>     ID time GUT CENT RESP DV CP
#> 1:   1    0   0    0   50  0  0
#> 2:   1    0   0    0   50  0  0
#> 3:   1    1   0    0   50  0  0
#> 4:   1    2   0    0   50  0  0
#> 5:   1    3   0    0   50  0  0
#> 6:   1    4   0    0   50  0  0

Created on 2020-03-14 by the reprex package (v0.3.0)

@kylebaron
Copy link
Collaborator Author

library(mrgsolve)
#> 
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#> 
#>     filter

mod <- house(end = 24)

dose <- ev(amt = 0, ii = 1, addl = 4,evid=2) %>% realize_addl()

dose
#> Events:
#>   time amt ii addl cmt evid
#> 1    0   0  0    0   1    2
#> 2    1   0  0    0   1    2
#> 3    2   0  0    0   1    2
#> 4    3   0  0    0   1    2
#> 5    4   0  0    0   1    2

mod %>% mrgsim(ev = dose, end = -1)
#> Model:  housemodel 
#> Dim:    5 x 7 
#> Time:   0 to 4 
#> ID:     1 
#>     ID time GUT CENT RESP DV CP
#> 1:   1    0   0    0   50  0  0
#> 2:   1    1   0    0   50  0  0
#> 3:   1    2   0    0   50  0  0
#> 4:   1    3   0    0   50  0  0
#> 5:   1    4   0    0   50  0  0

Created on 2020-03-14 by the reprex package (v0.3.0)

@kylebaron
Copy link
Collaborator Author

Fixed tests in inst/maintenance/unit/test-nocb.R to be consistent with new behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development
  
Done
Development

No branches or pull requests

1 participant