Description Usage Arguments Value Author(s) References See Also Examples
Cumulative transitionspecific intensity/hazard functions for fullyparametric multistate or competing risks models, using a piecewiseconstant approximation that will allow prediction using the functions in the mstate package.
1 2 3 4 5 6 7 8 9  msfit.flexsurvreg(
object,
t,
newdata = NULL,
variance = TRUE,
tvar = "trans",
trans,
B = 1000
)

object 
Output from The model should have been fitted to data consisting of one row for each observed transition and additional rows corresponding to censored times to competing transitions. This is the "long" format, or counting process format, as explained in the flexsurv vignette. The model should contain a categorical covariate indicating the transition.
In Alternatively, if the parameters (including covariate effects) are assumed to be different between different transitions, then a list of transitionspecific models can be formed. This list has one component for each permitted transition in the multistate model. This is more computationally efficient, particularly for larger models and datasets. See the example below, and the vignette. 
t 
Vector of times. These do not need to be the same as the observed
event times, and since the model is parametric, they can be outside the
range of the data. A grid of more frequent times will provide a better
approximation to the cumulative hazard trajectory for prediction with

newdata 
A data frame specifying the values of covariates in the fitted model, other than the transition number. This must be specified if there are other covariates. The variable names should be the same as those in the fitted model formula. There must be either one value per covariate (the typical situation) or n values per covariate, a different one for each of the n allowed transitions. 
variance 
Calculate the variances and covariances of the transition
cumulative hazards ( 
tvar 
Name of the categorical variable in the model formula that
represents the transition number. The values of this variable should
correspond to elements of 
trans 
Matrix indicating allowed transitions in the multistate
model, in the format understood by mstate: a matrix of integers whose
r,s entry is i if the ith transition type (reading across
rows) is r,s, and has 
B 
Number of simulations from the normal asymptotic distribution used to calculate variances. Decrease for greater speed at the expense of accuracy. 
An object of class "msfit"
, in the same form as the objects
used in the mstate package. The msfit
method
from mstate returns the equivalent cumulative intensities for Cox
regression models fitted with coxph
.
C. H. Jackson chris.jackson@mrcbsu.cam.ac.uk
Liesbeth C. de Wreede, Marta Fiocco, Hein Putter (2011). mstate: An R Package for the Analysis of Competing Risks and MultiState Models. Journal of Statistical Software, 38(7), 130. https://www.jstatsoft.org/v38/i07
Mandel, M. (2013). "Simulation based confidence intervals for functions with complicated derivatives." The American Statistician 67(2):7681
flexsurv provides alternative functions designed
specifically for predicting from parametric multistate models without
calling mstate. These include pmatrix.fs
and
pmatrix.simfs
for the transition probability matrix, and
totlos.fs
and totlos.simfs
for expected total
lengths of stay in states. These are generally more efficient than going
via mstate.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58  ## 3 state illnessdeath model for bronchiolitis obliterans
## Compare clockreset / semiMarkov multistate models
## Simple exponential model (reduces to Markov)
bexp < flexsurvreg(Surv(years, status) ~ trans,
data=bosms3, dist="exp")
tmat < rbind(c(NA,1,2),c(NA,NA,3),c(NA,NA,NA))
mexp < msfit.flexsurvreg(bexp, t=seq(0,12,by=0.1),
trans=tmat, tvar="trans", variance=FALSE)
## Cox semiparametric model within each transition
bcox < coxph(Surv(years, status) ~ strata(trans), data=bosms3)
if (require("mstate")){
mcox < mstate::msfit(bcox, trans=tmat)
## Flexible parametric splinebased model
bspl < flexsurvspline(Surv(years, status) ~ trans + gamma1(trans),
data=bosms3, k=3)
mspl < msfit.flexsurvreg(bspl, t=seq(0,12,by=0.1),
trans=tmat, tvar="trans", variance=FALSE)
## Compare fit: exponential model is OK but the spline is better
plot(mcox, lwd=1, xlim=c(0, 12), ylim=c(0,4))
cols < c("black","red","green")
for (i in 1:3){
lines(mexp$Haz$time[mexp$Haz$trans==i], mexp$Haz$Haz[mexp$Haz$trans==i],
col=cols[i], lwd=2, lty=2)
lines(mspl$Haz$time[mspl$Haz$trans==i], mspl$Haz$Haz[mspl$Haz$trans==i],
col=cols[i], lwd=3)
}
legend("topright", lwd=c(1,2,3), lty=c(1,2,1),
c("Cox", "Exponential", "Flexible parametric"), bty="n")
}
## Fit a list of models, one for each transition
## More computationally efficient, but only valid if parameters
## are different between transitions.
## Not run:
bexp.list < vector(3, mode="list")
for (i in 1:3) {
bexp.list[[i]] < flexsurvreg(Surv(years, status) ~ 1, subset=(trans==i),
data=bosms3, dist="exp")
}
## The list of models can be passed to this and other functions,
## as if it were a single multistate model.
msfit.flexsurvreg(bexp.list, t=seq(0,12,by=0.1), trans=tmat)
## End(Not run)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.