| mstate.Lexis {Epi} | R Documentation |
The mstate package requires input in the form of a stacked
dataset with specific variable names. This is provided by this
function. The resulting dataframe contains the same information as the
result of a call to stack.Lexis.
mstate.Lexis(obj, time.scale = timeScales(obj)[1])
obj |
A Lexis object. |
time.scale |
Name or number of timescale in the Lexis object. |
A dataframe with the Lexis specific variables stripped, and
with the following added: id, Tstart, Tstop,
from, to, trans, status, which are used in
the function mstate from the mstate package.
Bendix Carstensen, bxc@steno.dk, www.biostat.ku.dk/~bxc
data(DMlate)
str(DMlate)
dml <- Lexis( entry=list(Per=dodm, Age=dodm-dobth, DMdur=0 ),
exit=list(Per=dox),
exit.status=factor(!is.na(dodth),labels=c("DM","Dead")),
data=DMlate )
dmi <- cutLexis( dml, cut=dml$doins, new.state="Ins", pre="DM" )
summary( dmi )
ms.dmi <- mstate.Lexis( dmi )
summary( dmi )
# Check that all the transitions and person-years got across.
with( ms.dmi, rbind( table(status,trans),
tapply(Tstop-Tstart,trans,sum) ) )