mcutLexis {Epi} | R Documentation |
A generalization of cutLexis
to the case where different
events may occur in any order (but at most once for each).
mcutLexis( L0, timescale = 1, wh, new.states = NULL, precursor.states = NULL, seq.states = TRUE, new.scales = NULL, ties.resolve = FALSE )
L0 |
A Lexis object. |
timescale |
Which time scale do the variables in |
wh |
Which variables contain the event dates. Character or integer vector |
new.states |
Names of the events forming new states. If
|
precursor.states |
Which states are precursor states. See
|
seq.states |
Should the sequence of events be kept track of? That
is, should A-B be considered different from B-A. If May also be supplied as character: |
new.scales |
Should we construct new time scales indicating the time since each of the event occurrences. |
ties.resolve |
Should tied event times be resolved by adding
random noise to tied event dates. If |
A Lexis
object with extra states created by
occurrence of a number of intermediate events.
Bendix Carstensen, http://BendixCarstensen.com
cutLexis
,
addCov.Lexis
,
Lexis
,
splitLexis
# A dataframe of times set.seed(563248) dd <- data.frame( id = 1:10, doN = round(runif(10,-30, 0),1), doE = round(runif(10, 0,20),1), doX = round(runif(10, 50,60),1), doD = round(runif(10, 50,60),1), # these are the event times doA = c(NA,20,NA,27,35,NA,52, 5,43,80), doB = c(25,NA,37,40,NA,NA,15,23,36,61) ) # set up a Lexis object with time from entry to death/exit Lx <- Lexis( entry = list(time=doE, age=doE-doN), exit = list(time=pmin(doX,doD)), exit.status = factor(doD<doX,labels=c("OK","D")), data = dd ) summary( Lx ) # cut the follow-up at dates doA and doB L2 <- mcutLexis( Lx, "time", wh=c("doA","doB"), new.states = c("A","B"), precursor.states = "OK", seq.states = TRUE, new.scales = c("tfA","tfB") ) summary( L2 ) L2 # show the states boxes( L2, boxpos=list(x=c(10,50,50,90,50,90), y=c(50,90,50,90,10,10)), show.R=FALSE, show.BE=TRUE ) L3 <- mcutLexis( Lx, "time", wh=c("doA","doB"), new.states = c("A","B"), precursor.states = "OK", seq.states = FALSE, new.scales = c("tfA","tfB") ) summary( L3 ) boxes( L3, boxpos=list(x=c(10,50,50,90,50), y=c(50,90,50,50,10)), show.R=FALSE, show.BE=TRUE )