Follow-up intervals in a Lexis object are divided into two sub-intervals: one before and one after an intermediate event. The intermediate event may denote a change of state, in which case the entry and exit status variables in the split Lexis object are modified.
1 2 3 4 5 6 7 8
A numeric vector with the times of the intermediate event.
If a time is missing (
The timescale that
The state to which a transition occur at time
Name of the timescale defined as "time since entry to
Should states that are not precursor states be split according to whether the intermediate event has occurred.
a logical flag that determines the changes to exit status. See details.
an optional vector of states to be considered
as "less severe" than
logical indicating whether the
cutLexis function allows a number of different ways
of specifying the cutpoints and of modifying the status variable.
cut argument is a dataframe it must have columns
new.state. The values of
lex.id must be unique.
In this case it is assumed that each row represents a cutpoint (on the
timescale indicated in the argument
timescale). This cutpoint will
be applied to all records in
data with the corresponding
This makes it possible to apply
cutLexis to a split
new.state argument is supplied, the status variable is
only modified at the time of the cut point. However, it is often
useful to modify the status variable after the cutpoint when an
important event occurs. There are three distinct ways of doing this.
progressive=TRUE argument is given, then a "progressive"
model is assumed, in which the status can either remain the same or
increase during follow-up, but never decrease. This assumes that the
lex.Xst are either numeric or
ordered factors. In this case, if
new.state=X, then any exit status with a value less than
X is replaced with
X. The Lexis object
must already be progressive, so that there are no rows for which the
exit status is less than the entry status. If
lex.Xst are factors they must be ordered factors if
progressive=TRUE is given.
As an alternative to the
progressive argument, an explicit
vector of precursor states, that are considered less severe than the
new state, may be given. If
precursor.states=c(Y,Z) then any exit status of
Z in the second interval is replaced with
X and all
other values for the exit status are retained.
countLexis function is a variant of
the cutpoint marks a recurrent event, and the status variable is used
to count the number of events that have occurred. Times given in
represent times of new events. Splitting with
countLexis increases the status variable by 1. If the current
X and the exit status is
Y before cutting,
then after cutting the entry status is
the first and second intervals, respectively, and the exit status is
Y+1 respectively. Moreover the values of the status
is increased by 1 for all intervals for all intervals after the cut
for the person in question. Hence, a call to
needed for as many times as the person with most events. But also it
is immaterial in what order the cutpoints are entered.
Lexis object, for which each follow-up interval
containing the cutpoint is split in two: one before
and one after the cutpoint. An extra time-scale is added; the time
since the event at
cut. This is
NA for any follow-up
prior to the intermediate event.
cutLexis function superficially resembles the
splitLexis function. However, the
splits on a vector of common cut-points for all rows of the Lexis
object, whereas the
cutLexis function splits on a single time
point, which may be distinct for each row, modifies the status
variables, adds a new timescale and updates the attribute
"time.since". This attribute is a character vector of the same length
as the "time.scales" attribute, whose value is '""' if the
corresponding timescale is defined for any piece of follow-up, and if
the corresponding time scale is defined by say
cutLexis(obj,new.state="A",new.scale=TRUE), it has the value
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
# 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 cut <- c(33,47,29,50) cutLexis(xx, cut, new.state=3, precursor=1) cutLexis(xx, cut, new.state=3, precursor=2) cutLexis(xx, cut, new.state=3, precursor=1:2) # The same as the last example cutLexis(xx, cut, new.state=3) # The same example with a factor status variable yy <- Lexis(entry = list(age=c(17,24,33,29),per=c(1920,1933,1930,1929)), duration = c(23,57,12,15), entry.status = factor(rep("alpha",4), levels=c("alpha","beta","gamma")), exit.status = factor(c("alpha","beta","alpha","beta"), levels=c("alpha","beta","gamma"))) cutLexis(yy,c(33,47,29,50),precursor="alpha",new.state="gamma") cutLexis(yy,c(33,47,29,50),precursor=c("alpha","beta"),new.state="aleph") ## Using a dataframe as cut argument rl <- data.frame( lex.id=1:3, cut=c(19,53,26), timescale="age", new.state=3 ) rl cutLexis( xx, rl ) cutLexis( xx, rl, precursor=1 ) cutLexis( xx, rl, precursor=0:2 ) ## It is immaterial in what order splitting and cutting is done xs <- splitLexis( xx, breaks=seq(0,100,10), time.scale="age" ) xs xsC <- cutLexis(xs, rl, precursor=0 ) xC <- cutLexis( xx, rl, pre=0 ) xC xCs <- splitLexis( xC, breaks=seq(0,100,10), time.scale="age" ) xCs str(xCs)