-
Hi @kylebaron- Is there any way to individualize
This above will sample all population with same times. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @Mutaz94 - A couple of different ways to do it: library(tidyverse)
library(mrgsolve)
#>
#> Attaching package: 'mrgsolve'
#> The following object is masked from 'package:stats':
#>
#> filter
mod <- modlib("popex")
#> Building popex ...
#> done.
data <- as_data_set(
ev(amt = 300, ii = 24, addl = 10, ID = 1:10, GROUP = 1)
) Option 1 - tgridset.seed(132)
dl <- map(data$ID, ~ sample(seq(0,24),5))
idata <- select(data, ID)
out <- mrgsim(
mod,
data = data,
idata = idata,
deslist = dl,
descol = "ID"
)
plot(out, DV~time, scales = "free", type = 'b') Option 2 - build up dataset.seed(22233)
data2 <-
data %>%
select(-time) %>%
mutate(
time = map(ID, ~sample(seq(0,24),5))
)
data2 <-
data2 %>%
mutate(evid = 0, amt = 0, ii = 0) %>%
unnest(cols = "time") %>%
bind_rows(data) %>%
arrange(ID,time)
out <- mrgsim(mod, data2)
plot(out, DV ~ time, type = 'b') Created on 2021-05-05 by the reprex package (v1.0.0) |
Beta Was this translation helpful? Give feedback.
-
THANK YOU!! thats exactly what I want. option 1 is the winner I guess. |
Beta Was this translation helpful? Give feedback.
Hi @Mutaz94 -
A couple of different ways to do it:
Option 1 - tgrid
Option 2 - build up data