require(mstate)
require(ggplot2)
#Generate from an illness-death model with exponential transitions with
#rates 1/2, 1/10 and 1 for 10 subjects over a time grid.
gd <- sim_weibmsm(tmat = trans.illdeath(), shape = c(1,1,1),
scale = c(2, 10, 1), n_subj = 10, obs_pars = c(2, 0.5, 20),
startprobs = c(0.9, 0.1, 0), true_trajec = TRUE)
#Observed trajectories
visualise_msm(gd$observed)
#True trajectories
visualise_msm(gd$true)
#Can supply data-frame with specified observation times
obs_df <- data.frame(time = c(0, 1, 3, 5, 0.5, 6, 9),
id = c(1, 1, 1, 1, 2, 2, 2))
gd <- sim_weibmsm(data = obs_df, tmat = trans.illdeath(), shape = c(1, 1, 1),
scale = c(2, 10, 1))
visualise_msm(gd)
Run the code above in your browser using DataLab