Different Sampling time for different ID's #558
-
Hello,
I am looking for a way to set different measurement for each individual without having to fit each individual separately. iCov and events should be able to match accordingly. Is that possible in rxode2? Thank you, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I'm not certain that I understand the question. If I'm interpreting it correctly, you're wanting to have a different observation time for each subject. If so, you can choose which times to assign to each subject randomly with the following code. Any other way that you want to choose the id to time mapping should work similarly: library(tidyverse)
library(rxode2)
#> rxode2 2.0.13.9000 using 8 threads (see ?getRxThreads)
#> no cache: create with `rxCreateCache()`
# This will have same time for all individuals
ev <- eventTable(time.units="hours") %>%
add.sampling(0:24) %>%
et(id = 1:4)
ev
#> ── EventTable with 100 records ──
#> 0 dosing records (see x$get.dosing(); add with add.dosing or et)
#> 100 observation times (see x$get.sampling(); add with add.sampling or et)
#> ── First part of x: ──
#> # A tibble: 100 × 3
#> id time evid
#> <int> [h] <evid>
#> 1 1 0 0:Observation
#> 2 1 1 0:Observation
#> 3 1 2 0:Observation
#> 4 1 3 0:Observation
#> 5 1 4 0:Observation
#> 6 1 5 0:Observation
#> 7 1 6 0:Observation
#> 8 1 7 0:Observation
#> 9 1 8 0:Observation
#> 10 1 9 0:Observation
#> # ℹ 90 more rows
d_time_id <-
data.frame(
id = 1:4,
keep_time = sample(0:24, size = 4, replace = TRUE)
)
ev_sampled <-
ev %>%
as.data.frame() %>%
left_join(d_time_id) %>%
filter(as.numeric(time) == keep_time)
#> Joining with `by = join_by(id)`
ev_sampled
#> id time evid keep_time
#> 1 1 1 [h] 0 1
#> 2 2 21 [h] 0 21
#> 3 3 7 [h] 0 7
#> 4 4 12 [h] 0 12 Created on 2023-07-30 with reprex v2.0.2 |
Beta Was this translation helpful? Give feedback.
I'm not certain that I understand the question. If I'm interpreting it correctly, you're wanting to have a different observation time for each subject. If so, you can choose which times to assign to each subject randomly with the following code. Any other way that you want to choose the id to time mapping should work similarly: