## In a clinical study, suppose patients are given a placebo in the
## first 5 weeks, then they begin treatment 1 at 5 weeks, and
## a combination of treatments 1 and 2 from 10 weeks.
## Suppose a multi-state model x has been fitted for the patients'
## progress, with treat1 and treat2 as time dependent covariates.
## Cut points for when treatment covariate changes
times <- c(0, 5, 10)
## Indicators for which treatments are active at the three cut points
covariates <- list( list (treat1=0, treat2=0), list(treat1=1, treat2=0),
list(treat1=1, treat2=1) )
## Calculate transition probabilities from the start of the study to 15 weeks
pmatrix.piecewise.msm(x, 0, 15, times, covariates)
Run the code above in your browser using DataLab