msfit_subjects: Compute subject-specific transition hazards for multiple...

View source: R/msfit_subjects.R

msfit_subjectsR Documentation

Compute subject-specific transition hazards for multiple subjects at once

Description

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).

Usage

msfit_subjects(object, newdata, trans)

Arguments

object

A coxph object describing the fit of the multi-state model, must contain a 'strata()' term.

newdata

A data.frame containing K rows per subject in the data, with K the number of transitions possible in the model. The following named columns must be present:

id:

Unique identifier of the subject this row relates to, must be numeric or character;

trans:

Transition number in the 'transMat' trans this row relates to;

"variables":

The subject-specific covariates (appearing in the coxph formula), ordered according to transition number in trans.

Note that newdata must contain a column containing the variable which was used to determine the stratum of a transition in object (usually this is 'trans').

trans

Transition matrix describing the states and transitions in the multi-state model. See trans in msprep for more detailed information

Details

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))

Value

An object of class "msfit.subjects", which is a list containing

intensities

A 4-dimensional array containing the estimated cumulative intensity increments at times. The first and second dimensions pertain to the to/from states of the transitions, the third to the times and the fourth to the unique subject ids.

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 newdata.

trans

The transition matrix used.

Looking for an 'msfit' object for a single subject? See msfit_subjects_to_msfit.

Author(s)

Daniel Gomon

References

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.

See Also

plot.msfit.subjects, msfit_subjects_to_msfit

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)
# 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)


hputter/mstate documentation built on July 17, 2025, 2:04 a.m.