View source: R/msfit_subjects.R
msfit_subjects | R Documentation |
This function computes subject-specific or overall cumulative transition
hazards for each of the possible transitions in the multi-state model.
Contrary to msfit
, this function allows to
calculate hazards for multiple subjects at once, but does not allow
to calculate (co)variances (yet).
msfit_subjects(object, newdata, trans)
object |
A |
newdata |
A
Note that newdata must contain a column containing the variable which was
used to determine the stratum of a transition in |
trans |
Transition matrix describing the states and transitions in the
multi-state model. See |
The data frame needs to have one row for each transition in the multi-state
model, per subject: (n_subjects x n_transitions) rows in total.
Contrary to msfit
, it is not necessary to
manually specify the strata
variable,
as long as the strata can be determined from the data using the formula
used in object
. For details refer to de Wreede, Fiocco & Putter (2010).
So far,
the results have been checked only for the "breslow"
method of
dealing with ties in coxph
, so this is
recommended.
The goal of this function is to determine the subject specific intensity matrices
dA_i(t)
, which can be further used to determine transition probabilities
through the product integral
P_i(s,t) = \prod_{(s,t]}(I + dA_i(u))
An object of class "msfit.subjects"
, which is a list containing
intensities |
A 4-dimensional |
times |
The unique times at which the intensity increments were determined. |
ids |
The unique id's used to represent the individual subjects, taken
from the 'id' column in |
trans |
The transition matrix used. |
Looking for an 'msfit' object for a single subject? See
msfit_subjects_to_msfit
.
Daniel Gomon
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.
plot.msfit.subjects
, msfit_subjects_to_msfit
# 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)
# 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")
#Fit on multiple subjects at once, by providing 'id' column.
#cx was fit using strata(trans), so only having a 'trans' column suffices
newdata <- data.frame(id=rep(1:3, each = 3),x1.1=c(0,0,0,1,0,1,0,1,0),
x2.2=c(0,1,0,0,0,0,1,0,1), trans = rep(1:3, 3))
msf_subj <- msfit_subjects(cx,newdata,trans=tmat)
#Extract an 'msfit' object for subject 1
msf_subj1 <- msfit_subjects_to_msfit(msf_subj, 1)
#Can now use standard 'msfit' plotting capabilities
plot(msf_subj1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.