Skip to contents

visits_to_mstate() converts visits to interval-censored multi-state data where each row corresponds to a transition between states. The conversion assumes that visit spacing is tight enough to not miss any transitions.

Usage

visits_to_mstate(tbl_visits, model, now = max(tbl_visits$t))

Arguments

tbl_visits

data frame, visit data in long format

model

an object of class srpmodel containing prior information

now

time point since start of trial (might be later than last recorded visit)

Value

A data frame with multi-state data; variables are subject_id<chr>, group_id<chr>, subject_id<chr>, from<chr>, to<chr>, t_min<dbl>, t_max<dbl>, t_sot<dbl>, where to and from indicate the state from which and into which the transitions occurs, t_max and t_min specify the interval in which the transition occurred relative to t_sot

(start of treatment).

Examples

mdl <- create_srpmodel(A = define_srp_prior())
tbl_visits <- sample_predictive(mdl, n_per_group = 5L, nsim = 1, seed = 468L)
visits_to_mstate(tbl_visits, mdl)
#> # A tibble: 8 × 7
#>   subject_id group_id from     to          t_min t_max t_sot
#>   <chr>      <chr>    <chr>    <chr>       <dbl> <dbl> <dbl>
#> 1 ID05135273 A        stable   response    46.8  47.8   5.84
#> 2 ID05135273 A        response progression 54.8  55.8   5.84
#> 3 ID05466621 A        stable   progression 52.0  53.0   1.01
#> 4 ID05662273 A        stable   progression 35.8  36.8   3.81
#> 5 ID05729114 A        stable   response    12.3  13.3   6.26
#> 6 ID05729114 A        response progression 23.3  24.3   6.26
#> 7 ID07955012 A        stable   response     6.94  7.94  4.94
#> 8 ID07955012 A        response progression 25.9  26.9   4.94