Description Usage Arguments Examples
The function merges a multistate dataset and a dataset of a time dependent covariate.
1 |
data |
Multistate date of the type from sim_fun. |
cov_data |
covariate data with column one with columns (id, time, value). |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 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)
A_data <- cbind(data_sim[,c("id", "Tstop")], as.numeric(data_sim$from %in% c(2, 4)))
names(A_data) <- c("id", "Tstop", "A")
data_margial <- add_cov(data_margial, cov_data = A_data)
data_margial$L <- as.numeric(data_margial$from %in% c(3, 4))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.