pmatrix.simfs  R Documentation 
The transition probability matrix for semiMarkov multistate models fitted
to timetoevent data with flexsurvreg
. This has r,s
entry giving the probability that an individual is in state s at time
t, given they are in state r at time 0.
pmatrix.simfs( x, trans, t = 1, newdata = NULL, ci = FALSE, tvar = "trans", tcovs = NULL, M = 1e+05, B = 1000, cl = 0.95, cores = NULL )
x 
A model fitted with

trans 
Matrix indicating allowed transitions. See

t 
Time to predict state occupancy probabilities for. This must be a
single number, unlike 
newdata 
A data frame specifying the values of covariates in the
fitted model, other than the transition number. See

ci 
Return a confidence interval calculated by simulating from the
asymptotic normal distribution of the maximum likelihood estimates. This
is turned off by default, since two levels of simulation are required. If
turned on, users should adjust 
tvar 
Variable in the data representing the transition type. Not
required if 
tcovs 
Predictable timedependent covariates such as age, see

M 
Number of individuals to simulate in order to approximate the transition probabilities. Users should adjust this to obtain the required precision. 
B 
Number of simulations from the normal asymptotic distribution used to calculate confidence limits. Decrease for greater speed at the expense of accuracy. 
cl 
Width of symmetric confidence intervals, relative to 1. 
cores 
Number of processor cores used when calculating confidence limits bu repeated simulation. The default uses singlecore processing. 
This is computed by simulating a large number of individuals M
using
the maximum likelihood estimates of the fitted model and the function
sim.fmsm
. Therefore this requires a random sampling function
for the parametric survival model to be available: see the "Details"
section of sim.fmsm
. This will be available for all builtin
distributions, though users may need to write this for custom models.
Note the random sampling method for flexsurvspline
models is
currently very inefficient, so that looping over the M
individuals
will be very slow.
pmatrix.fs
is a more efficient method based on solving the
Kolmogorov forward equation numerically, which requires the multistate
model to be Markov. No error or warning is given if running
pmatrix.simfs
with a Markov model, but this is still invalid.
The transition probability matrix. If ci=TRUE
, there are
attributes "lower"
and "upper"
giving matrices of the
corresponding confidence limits. These are formatted for printing but may
be extracted using attr()
.
Christopher Jackson chris.jackson@mrcbsu.cam.ac.uk.
pmatrix.fs
,sim.fmsm
,totlos.simfs
,
msfit.flexsurvreg
.
# BOS example in vignette, and in msfit.flexsurvreg bexp < flexsurvreg(Surv(years, status) ~ trans, data=bosms3, dist="exp") tmat < rbind(c(NA,1,2),c(NA,NA,3),c(NA,NA,NA)) # more likely to be dead (state 3) as time moves on, or if start with # BOS (state 2) pmatrix.simfs(bexp, t=5, trans=tmat) pmatrix.simfs(bexp, t=10, trans=tmat) # these results should converge to those in help(pmatrix.fs), as M # increases here and ODE solving precision increases there, since with # an exponential distribution, the semiMarkov model is the same as the # Markov model.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.