Learn R Programming

Epi (version 2.58)

Lexis2msm: Convert a Lexis obejct to a data set suitable for input to the msm:msm function.

Description

The number of records in the resulting dataset will have a number of records that is normally nrec(Lx) + nid(Lx), that is one extra record for each person. If there are 'holes' in persons' follow-up, each hole will also generate an extra record in the result.

Usage

Lexis2msm(Lx,
       state = "state",
     verbose = FALSE)

Value

A data frame of class msmLexis with the timescales preserved and lex.id

preserved but with other lex. variables removed.

Has more records than the original Lexis object

Arguments

Lx

A Lexis object.

state

Character; the name of the state variable in the result.

verbose

If true, you will be reminded what the function did.

Author

Bendix Carstensen, http://bendixcarstensen.com

See Also

Lexis

Examples

Run this code
example(mcutLexis)
# we now have the Lexis object L3:
summary(L3)

# data frame for use with msm
msm3 <- Lexis2msm(L3)

# see the difference 
subset(  L3, lex.id %in% 1:3)
subset(msm3, lex.id %in% 1:3)
timeScales(msm3)

Run the code above in your browser using DataLab