cutLexis {Epi}R Documentation

Cuts follow-up at a specified date for each person.

Description

The follow-up of a person is divided into the period before and after an intermediate event, typically disease recurrenece or something like that. This event is assigned a new state.

Usage

  cutLexis( data,
             cut,
       timescale = timeScales(data)[1],
       new.state = max(as.integer(c(factor(data$lex.Cst),factor(data$lex.Xst)))+1),
          na.cut = Inf,
            precursor = ifelse( is.character(new.state), "0", 0 ),
           count = missing(new.state) & missing(precursor) )
  

Arguments

data A Lexis object.
cut Numerical vector with the times of intermediate event. NAs are allowed, in which cases the original record is retained. A dataframe with columns lex.id, cut, and optionally new.state can be supplied instead. This will be matched to data. The cut column may be named as one of the timescales in data, in which case the argument timescale is ignored. If a column new.state is in the dataframe cut, the new.state argumant is ignored.
timescale The timescale that cut refers to.
new.state What value should the new state have? A vector is allowed, in which case its should have the same length as cut.
na.cut What value should be substituted for the NAs in cut. The default is Inf which results in the orginal records being kept.
precursor States considered precursororings (non-events). If lex.Cst is one of these, it will be updated to new.state if entry(timescale) is after cut. If lex.Xst is one of these, it will be updated to new.state if exit(timescale) is after cut.
count Logical. If TRUE, states are assumed to be numerical, and each cut date will increment the state by 1. This is for the situation where state is counting the number of previous events (indicated by cut dates. Defaults to missing(new.state) & missing(precursor). If TRUE, the arguments new.state and precursor are ignored.

Details

The precursor parameter is used to decide whether an exitsing status (lex.Cst or lex.Xst) should be updated to new.state or not, when the corresponding entry or exit time is after cut. Note that values of cut prior to the entry time is allowed, in which both lex.Cst and lex.Xst will updated according to the mentioned rule.

Value

A Lexis object, where the follow-up of each person is cut at the time as given in cut. lex.Cst, lex.Xst are returned as factors in the returned Lexis object.

Author(s)

Bendix Carstensen, Steno Diabetes Center, bxc@steno.dk

See Also

splitLexis

Examples

data( nickel )
nic <- Lexis( data=nickel,
             entry=list(age=agein),
              exit=list(age=ageout,cal=ageout+dob,tfh=ageout-age1st),
# Lung cancer deaths and other deaths are coded 1 and 2
       exit.status=( (icd > 0) + (icd %in% c(162,163)) ) )
  str( nic )
  tab.Lexis( nic )
nicc <- cutLexis( nic, 50, "age" )
tab.Lexis( nicc )

# A small artificial example
xx <- Lexis( entry=list(age=c(17,24,33,29),per=c(1920,1933,1930,1929)),
             duration=c(23,57,12,15), exit.status=c(1,2,1,2) )
xx
cutLexis(xx,c(33,47,29,50),precursor=1)
cutLexis(xx,c(33,47,29,50),precursor=2)
cutLexis(xx,c(33,47,29,50),precursor=1:2)
cutLexis(xx,c(33,47,29,50),precursor=2,new.state="nova")
cutLexis(xx,c(33,47,29,50),precursor=0:1,new.state="nova")

# Supply a dataframe with transitions for a subset
rl <- data.frame( lex.id=1:3, age=c(19,30,25), new.state=c("one","two","two") )
rl
cutLexis( xx, rl )
cutLexis( xx, rl, precursor=1 )
cutLexis( xx, rl, precursor=0:2 )

# Use the count argument
cutLexis( xx, c(33,47,29,50), count=TRUE )
  

[Package Epi version 1.0.3 Index]