Skip to content

Individualize tgrid #825

Answered by kylebaron
Mutaz94 asked this question in Q&A
Discussion options

You must be logged in to vote

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 - tgrid

set.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 data

set.seed(22233)
data2 <- 
  data %>% 
  select(-time) %>%
  mutate(
  time = map(ID, ~sample…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Mutaz94
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants