R: Convert a Lexis obejct to a data set suitable for input to...

Lexis2msm {Epi} | R Documentation

## 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)

### 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.

### 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

### Author(s)

Bendix Carstensen, http://bendixcarstensen.com

### See Also

`Lexis`

### Examples

    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)

[Package Epi version 2.47 Index]