| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/etm2msdata.R |
| 3 |
\name{etm2msdata} |
| 4 |
\alias{etm2msdata} |
| 5 |
\alias{tra2trans} |
| 6 |
\title{Converts between etm and msdata format} |
| 7 |
\usage{ |
| 8 |
etm2msdata(etmdata, id, tra, covs) |
| 9 |
} |
| 10 |
\arguments{ |
| 11 |
\item{etmdata}{Multi-state data in \code{etm} format} |
| 12 |
|
| 13 |
\item{id}{Column name identifying the subject id} |
| 14 |
|
| 15 |
\item{tra}{Transition matrix in \code{etm} format} |
| 16 |
|
| 17 |
\item{covs}{Vector of column names containing covariates to be included} |
| 18 |
} |
| 19 |
\description{ |
| 20 |
Converts multi-state data back and forth between etm and msdata formats. |
| 21 |
Covariates have to be dealt with separately. |
| 22 |
} |
| 23 |
\details{ |
| 24 |
\code{msdata2etm} will convert from \code{msdata} format to \code{etm} |
| 25 |
format; \code{etm2msdata} will convert from \code{etm} format to |
| 26 |
\code{msdata} format. Both \code{msdata2etm} and \code{etm2msdata} work with |
| 27 |
basic time-fixed covariates. Time-dependent covariates are not supported. |
| 28 |
The function \code{msdata2etm} will work for transition-specific covariates, |
| 29 |
but the result does not really make much sense when used in etm. |
| 30 |
} |
| 31 |
\examples{ |
| 32 |
|
| 33 |
# Transition matrix for illness-death model |
| 34 |
tmat <- trans.illdeath() |
| 35 |
# Data in wide format, for transition 1 this is dataset E1 of |
| 36 |
# Therneau & Grambsch (T&G) |
| 37 |
tg <- data.frame(id=1:6,illt=c(1,1,6,6,8,9),ills=c(1,0,1,1,0,1), |
| 38 |
dt=c(5,1,9,7,8,12),ds=c(1,1,1,1,1,1), |
| 39 |
x1=c(1,1,1,0,0,0),x2=c(6:1)) |
| 40 |
# Data in long format using msprep |
| 41 |
tglong <- msprep(time=c(NA,"illt","dt"),status=c(NA,"ills","ds"), |
| 42 |
data=tg,keep=c("x1","x2"),trans=tmat, id="id") |
| 43 |
# Same thing in etm format |
| 44 |
tra <- trans2tra(tmat) |
| 45 |
tgetm <- msdata2etm(tglong, id="id") |
| 46 |
tgetm <- msdata2etm(tglong, id="id", covs=c("x1", "x2")) # with covariates |
| 47 |
# And back |
| 48 |
etm2msdata(tgetm, id="id", tra=tra) |
| 49 |
etm2msdata(tgetm, id="id", tra=tra, covs=c("x1", "x2")) # with covariates |
| 50 |
} |
| 51 |
\author{ |
| 52 |
Hein Putter \email{[email protected]} |
| 53 |
} |
| 54 |
\keyword{datagen} |