Learn R Programming

icmstate (version 0.2.0)

visualise_msm: Visualise multi-state data

Description

Produce a plot with the y-axis representing subjects in the data and the x-axis representing the time at which states have been observed.

Usage

visualise_msm(gd, npmsm, tmat, neat = TRUE, cutoff)

Value

A plot will be produced in the plotting window.

Arguments

gd

A data.frame containing the following named columns:

id:

Identifier of subject;

state:

state of subject at time;

time:

time at which subject is observed;

npmsm

Output from npmsm function

tmat

A transition matrix as created by transMat

neat

Boolean indicating whether redundant observations should be removed in the plot. Default is TRUE

cutoff

cutoff value for numerically determining the support using support_npmsm

Examples

Run this code
#Write a function for evaluation times: observe at 0 and uniform inter-observation times.
eval_times <- function(n_obs, stop_time){
  cumsum( c( runif(1, 0, 0.5),  runif( n_obs-1, 0, 2*(stop_time-4)/(n_obs-1) ) ) )
}
#Use built_in function to simulate illness-death data
#from Weibull distributions for each transition
sim_dat <- sim_id_weib(n = 50, n_obs = 6, stop_time = 15, eval_times = eval_times,
                      start_state = "stable", shape = c(0.5, 0.5, 2), 
                      scale = c(5, 10, 10/gamma(1.5)))

#Visualise the data
visualise_msm(sim_dat)                       

Run the code above in your browser using DataLab