Description Usage Arguments Examples
Merging states in a multistate model to produce new (marginal) model.
1 | merge_states(df, new_states, new_tmat)
|
df |
Multistate data frame of the type from sim_fun. |
new_states |
A list list of how new states are composed of old states. |
new_tmat |
The corresponding tmat (see tmat_function) for the marginal multistate model. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | jump_types <- matrix(c(NA, "exp", "exp", NA, "exp",
"exp", NA ,NA,"exp", "exp",
"exp", NA, NA, "exp", "exp",
NA, "exp", "exp", NA, "exp",
rep(NA, times = 5)), 5, 5, byrow = T)
tmat <- tmat_function(jump_types)
lambda <- matrix(c(NA, 0.1, 0.15, NA, 0.08,
0.12, NA ,NA,0.15, 0.05,
0.1, NA, NA, 0.1, 0.08,
NA, 0.12, 0.1, NA, 0.05,
rep(NA, times = 5)), 5, 5, byrow = T)
par_list2 <- list(lambda = lambda)
data_sim <- sim_fun(init_probs = c(0.5,0,0.5,rep(0, times = 2)), jump_types, pars = par_list2,
cens_time = 1000, nbr = 1000)
new_states <- list(state1 = 1:4, state2 = 5)
new_tmat <- matrix(NA, 2, 2)
new_tmat[1,2] <- 1
data_margial <- merge_states(data_sim, new_states, new_tmat)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.