Skip to content

Instantly share code, notes, and snippets.

@jenniferthompson
Last active April 10, 2021 19:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenniferthompson/3985d60366be20ba0c23309271d4c143 to your computer and use it in GitHub Desktop.
Save jenniferthompson/3985d60366be20ba0c23309271d4c143 to your computer and use it in GitHub Desktop.
Try example code from `multistateutils` Example vignette
## Work through examples in multistateutils docs
library(mstate)
library(flexsurv)
library(multistateutils)
data(ebmt3)
tmat <- trans.illdeath(c('transplant', 'pr', 'rfs'))
tmat
long <- msprep(time=c(NA, 'prtime', 'rfstime'),
status=c(NA, 'prstat', 'rfsstat'),
data=ebmt3,
trans=tmat,
keep=c('age', 'dissub'))
models <- lapply(1:3, function(i) {
flexsurvreg(Surv(time, status) ~ age + dissub, data=long, dist='weibull')
})
newdata <- data.frame(age="20-40", dissub="AML")
## Consistently crashes R on macOS High Sierra
# predict_transitions(models, newdata, tmat, times=365)
pmatrix.simfs(models, tmat, newdata=newdata, t=365)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment