visits_to_mstate {oncomsm}R Documentation

Convert cross-sectional visit data to multi-state format

Description

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)


[Package oncomsm version 0.1.4 Index]