pmatrix.fs {flexsurv} | R Documentation |
Transition probability matrix from a fully-parametric, time-inhomogeneous Markov multi-state model
Description
The transition probability matrix for time-inhomogeneous Markov multi-state
models fitted to time-to-event 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
.
Usage
pmatrix.fs(
x,
trans = NULL,
t = 1,
newdata = NULL,
condstates = NULL,
ci = FALSE,
tvar = "trans",
sing.inf = 1e+10,
B = 1000,
cl = 0.95,
tidy = FALSE,
...
)
Arguments
x |
A model fitted with
|
trans |
Matrix indicating allowed transitions. See
|
t |
Time or vector of times to predict state occupancy probabilities for. |
newdata |
A data frame specifying the values of covariates in the
fitted model, other than the transition number. See
|
condstates |
xInstead of the unconditional probability of being in state This is used, for example, in competing risks situations, e.g. if the competing states are death or recovery from a disease, and we want to compute the probability a patient has died, given they have died or recovered. If these are absorbing states, then as |
ci |
Return a confidence interval calculated by simulating from the
asymptotic normal distribution of the maximum likelihood estimates. Turned
off by default, since this is computationally intensive. If turned on,
users should increase |
tvar |
Variable in the data representing the transition type. Not
required if |
sing.inf |
If there is a singularity in the observed hazard, for
example a Weibull distribution with |
B |
Number of simulations from the normal asymptotic distribution used to calculate variances. Decrease for greater speed at the expense of accuracy. |
cl |
Width of symmetric confidence intervals, relative to 1. |
tidy |
If TRUE then return the results as a tidy data frame |
... |
Arguments passed to |
Details
This is computed by solving the Kolmogorov forward differential equation
numerically, using the methods in the deSolve
package. The
equation is
\frac{dP(t)}{dt} = P(t) Q(t)
where P(t)
is the transition probability matrix for time t
, and
Q(t)
is the transition hazard or intensity as a function of t
.
The initial condition is P(0) = I
.
Note that the package msm has a similar method pmatrix.msm
.
pmatrix.fs
should give the same results as pmatrix.msm
when
both of these conditions hold:
the time-to-event distribution is exponential for all transitions, thus the
flexsurvreg
model was fitted withdist="exp"
and the model is time-homogeneous.the msm model was fitted with
exacttimes=TRUE
, thus all the event times are known, and there are no time-dependent covariates.
msm only allows exponential or piecewise-exponential time-to-event distributions, while flexsurvreg allows more flexible models. msm however was designed in particular for panel data, where the process is observed only at arbitrary times, thus the times of transition are unknown, which makes flexible models difficult.
This function is only valid for Markov ("clock-forward") multi-state
models, though no warning or error is currently given if the model is not
Markov. See pmatrix.simfs
for the equivalent for semi-Markov
("clock-reset") models.
Value
The transition probability matrix, if t
is of length 1. If t
is longer, return a list of matrices, or a data frame if tidy
is TRUE.
If ci=TRUE
, each element has attributes "lower"
and
"upper"
giving matrices of the corresponding confidence limits.
These are formatted for printing but may be extracted using attr()
.
Author(s)
Christopher Jackson chris.jackson@mrc-bsu.cam.ac.uk.
See Also
pmatrix.simfs
, totlos.fs
,
msfit.flexsurvreg
.
Examples
# BOS example in vignette, and in msfit.flexsurvreg
bexp <- flexsurvreg(Surv(Tstart, Tstop, 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.fs(bexp, t=c(5,10), trans=tmat)