Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

etm2msdata

Converts between etm and msdata format


Description

Converts multi-state data back and forth between etm and msdata formats. Covariates have to be dealt with separately.

Usage

etm2msdata(etmdata, id, tra, covs)

Arguments

etmdata

Multi-state data in etm format

id

Column name identifying the subject id

tra

Transition matrix in etm format

covs

Vector of column names containing covariates to be included

Details

msdata2etm will convert from msdata format to etm format; etm2msdata will convert from etm format to msdata format. Both msdata2etm and etm2msdata work with basic time-fixed covariates. Time-dependent covariates are not supported. The function msdata2etm will work for transition-specific covariates, but the result does not really make much sense when used in etm.

Author(s)

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 (T&G)
tg <- data.frame(id=1:6,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, id="id")
# Same thing in etm format
tra <- trans2tra(tmat)
tgetm <- msdata2etm(tglong, id="id")
tgetm <- msdata2etm(tglong, id="id", covs=c("x1", "x2")) # with covariates
# And back
etm2msdata(tgetm, id="id", tra=tra)
etm2msdata(tgetm, id="id", tra=tra, covs=c("x1", "x2")) # with covariates

mstate

Data Preparation, Estimation and Prediction in Multi-State Models

v0.3.1
GPL (>= 2)
Authors
Hein Putter [aut, cre], Liesbeth C. de Wreede [aut], Marta Fiocco [aut], Ronald B. Geskus [ctb], Edouard F. Bonneville [ctb], Damjan Manevski [ctb]
Initial release
2020-12-17

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.