Compute subject-specific or overall transition probabilities with standard errors
Source:R/probtrans.R
probtrans.Rd
This function computes subject-specific or overall transition probabilities in multi-state models. If requested, also standard errors are calculated.
Arguments
- object
msfit object containing estimated cumulative hazards for each of the transitions in the multi-state model and, if standard errors are requested, (co)variances of these cumulative hazards for each pair of transitions
- predt
A positive number indicating the prediction time. This is either the time at which the prediction is made (if
direction
="forward"
) or the time for which the prediction is to be made (ifdirection
="fixedhorizon"
)- direction
One of
"forward"
(default) or"fixedhorizon"
, indicating whether prediction is forward or for a fixed horizon- method
A character string specifying the type of variances to be computed (so only needed if either
variance
orcovariance
isTRUE
). Possible values are"aalen"
or"greenwood"
- variance
Logical value indicating whether standard errors are to be calculated (default is
TRUE
)- covariance
Logical value indicating whether covariances of transition probabilities for different states are to be calculated (default is
FALSE
)
Value
An object of class "probtrans"
, which is a list of which item
[[s]] contains a data frame with the estimated transition probabilities (and
standard errors if variance
=TRUE
) from state s. If
covariance
=TRUE
, item varMatrix
contains an array of
dimension K^2 x K^2 x (nt+1) (with K the number of states and nt the
distinct transition time points); the time points correspond to those in the
data frames with the estimated transition probabilities. Finally, there are
items trans
, method
, predt
, direction
, recording
the transition matrix, and the method, predt and direction arguments used in
the call to probtrans. Plot and summary methods have been defined for
"probtrans"
objects.
References
Andersen PK, Borgan O, Gill RD, Keiding N (1993). Statistical Models Based on Counting Processes. Springer, New York.
Putter H, Fiocco M, Geskus RB (2007). Tutorial in biostatistics: Competing risks and multi-state models. Statistics in Medicine 26, 2389–2430.
Therneau TM, Grambsch PM (2000). Modeling Survival Data: Extending the Cox Model. Springer, New York.
de Wreede LC, Fiocco M, and Putter H (2010). The mstate package for estimation and prediction in non- and semi-parametric multi-state and competing risks models. Computer Methods and Programs in Biomedicine 99, 261–274.
de Wreede LC, Fiocco M, and Putter H (2011). mstate: An R Package for the Analysis of Competing Risks and Multi-State Models. Journal of Statistical Software, Volume 38, Issue 7.
Author
Liesbeth de Wreede and Hein Putter H.Putter@lumc.nl
Examples
# transition matrix for illness-death model
tmat <- trans.illdeath()
# data in wide format, for transition 1 this is dataset E1 of
# Therneau & Grambsch (2000)
tg <- data.frame(illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1),
dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1),
x1=c(1,1,1,0,0,0),x2=c(6:1))
# data in long format using msprep
tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"),
data=tg,keep=c("x1","x2"),trans=tmat)
# events
events(tglong)
#> $Frequencies
#> to
#> from healthy illness death no event total entering
#> healthy 0 4 2 0 6
#> illness 0 0 4 0 4
#> death 0 0 0 6 6
#>
#> $Proportions
#> to
#> from healthy illness death no event
#> healthy 0.0000000 0.6666667 0.3333333 0.0000000
#> illness 0.0000000 0.0000000 1.0000000 0.0000000
#> death 0.0000000 0.0000000 0.0000000 1.0000000
#>
table(tglong$status,tglong$to,tglong$from)
#> , , = 1
#>
#>
#> 2 3
#> 0 2 4
#> 1 4 2
#>
#> , , = 2
#>
#>
#> 2 3
#> 0 0 0
#> 1 0 4
#>
# expanded covariates
tglong <- expand.covs(tglong,c("x1","x2"))
# Cox model with different covariate
cx <- coxph(Surv(Tstart,Tstop,status)~x1.1+x2.2+strata(trans),
data=tglong,method="breslow")
summary(cx)
#> Call:
#> coxph(formula = Surv(Tstart, Tstop, status) ~ x1.1 + x2.2 + strata(trans),
#> data = tglong, method = "breslow")
#>
#> n= 16, number of events= 10
#>
#> coef exp(coef) se(coef) z Pr(>|z|)
#> x1.1 1.4753 4.3723 1.2557 1.175 0.240
#> x2.2 0.8571 2.3563 0.8848 0.969 0.333
#>
#> exp(coef) exp(-coef) lower .95 upper .95
#> x1.1 4.372 0.2287 0.3731 51.24
#> x2.2 2.356 0.4244 0.4160 13.35
#>
#> Concordance= 0.781 (se = 0.077 )
#> Likelihood ratio test= 2.93 on 2 df, p=0.2
#> Wald test = 2.32 on 2 df, p=0.3
#> Score (logrank) test = 2.86 on 2 df, p=0.2
#>
# new data, to check whether results are the same for transition 1 as
# those in appendix E.1 of Therneau & Grambsch (2000)
newdata <- data.frame(trans=1:3,x1.1=c(0,0,0),x2.2=c(0,1,0),strata=1:3)
HvH <- msfit(cx,newdata,trans=tmat)
# probtrans
pt <- probtrans(HvH,predt=0)
# predictions from state 1
pt[[1]]
#> time pstate1 pstate2 pstate3 se1 se2 se3
#> 1 0 1.0000000 0.00000000 0.000000000 0.00000000 0.00000000 0.00000000
#> 2 1 0.9299816 0.06204689 0.007971491 0.08750408 0.08250577 0.02915069
#> 3 5 0.9299816 0.00000000 0.070018378 0.08750408 0.00000000 0.08750408
#> 4 6 0.6776902 0.25229141 0.070018378 0.22689332 0.21903899 0.08750408
#> 5 7 0.6776902 0.12614570 0.196164083 0.22689332 0.12638316 0.14680748
#> 6 8 0.4757726 0.12614570 0.398081646 0.23614089 0.12638316 0.19877253
#> 7 9 0.0000000 0.47577265 0.524227350 0.00000000 0.53115171 0.53115171
#> 8 12 0.0000000 0.00000000 1.000000000 0.00000000 0.00000000 0.00000000