Create a data structures suitable for use with packages mstate or etm.
The mstate
package requires input in the form of a stacked
dataset with specific variable names. This is provided by
msdata.Lexis
. The resulting dataframe contains the same
information as the result of a call to stack.Lexis
.
The etm
package requires input (almost) in the form of a
Lexis
object, but with specific column names etc. This is
provided by etm.Lexis
.
msdata(obj, ...) ## S3 method for class 'Lexis' msdata(obj, time.scale = timeScales(obj)[1], ... ) ## S3 method for class 'Lexis' etm( data, time.scale = timeScales(data)[1], cens.name = "cens", s = 0, t = "last", covariance = TRUE, delta.na = TRUE, ... )
obj |
A |
data |
A |
time.scale |
Name or number of timescale in the |
cens.name |
Name of the code for censoring used by |
s |
Passed on to |
t |
Passed on to |
covariance |
Passed on to |
delta.na |
Passed on to |
... |
Further arguments. |
msdata.Lexis
returns 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 mstate
package.
etm.Lexis
transforms the Lexis
object into a dataframe
suitable for analysis by the function etm
from the etm
package, and actually calls this function, so returns an object of
class etm
.
Bendix Carstensen, b@bxc.dk, http://bendixcarstensen.com
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[1:1000,] ) dmi <- cutLexis( dml, cut=dml$doins, new.state="Ins", pre="DM" ) summary( dmi ) # Use the interface to the mstate package if( require(mstate) ) { ms.dmi <- msdata.Lexis( dmi ) # Check that all the transitions and person-years got across. with( ms.dmi, rbind( table(status,trans), tapply(Tstop-Tstart,trans,sum) ) ) } # Use the etm package directly with a Lexis object if( require(etm) ) { dmi <- subset(dmi,lex.id<1000) etm.D <- etm.Lexis( dmi, time.scale=3 ) str( etm.D ) plot( etm.D, col=rainbow(5), lwd=2, lty=1, xlab="DM duration" ) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.