Learn R Programming

Epi (version 1.1.20)

stack.Lexis: Functions to facilitate analysis of multistate models.

Description

stack.Lexis produces a stacked object suited for analysis of several transitions simultaneously.

Usage

## S3 method for class 'Lexis':
stack(x, ...)
tmat( x, ... )
## S3 method for class 'Lexis':
tmat(x, ...)

Arguments

x
A Lexis object.
...
Not used.

Value

  • tmat.Lexis returns a square transition matrix, classified by the levels of lex.Cst and lex.Xst, it has a 1 for every transition occurring and NA in all oter entries. stack.Lexis returns a dataframe to be used for analysis of multistate data when all transitions are modelled together, for example if some parameters are required to be the same for different transitions. The dataframe has same variables as the original Lexis object, but with each record duplicated as many times as there are possible exits from the current state, lex.Cst. Two variables are added: lex.Fail, an indicator of wheter an event for the transition names in lex.Tr has occurred or not. lex.Tr is a factor with levels made up of combinations of the levels of lex.Cst and lex.Xst that do occur together in x, joined by a "->".

See Also

splitLexis cutLexis Lexis

Examples

Run this code
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 )
ls.dmi <- stack( dmi )
str( ls.dmi )
# Check that all the transitions and person-years got across.
with( ls.dmi, rbind( table(lex.Fail,lex.Tr),
                     tapply(lex.dur,lex.Tr,sum) ) )

Run the code above in your browser using DataLab