Intervening Event Setup
Creates several new variables which help set up a dataset for modeling
coxph when there is a single binary time-dependent
covariable which turns on at a given time, and stays on. This is
typical when analyzing the impact of an intervening event.
ie.setup creates a
Surv object using the start time, stop time
format. It also creates a binary indicator for the intervening event,
and a variable called
subs that is useful when
attach-ing a dataframe.
subs has observation numbers duplicated for subjects having an
intervening event, so those subject's baseline covariables (that are
not time-dependent) can be duplicated correctly.
ie.setup(failure.time, event, ie.time, break.ties=FALSE)
- a numeric variable containing the event or censoring times for the terminating event
- a binary (0/1) variable specifying whether observations had the terminating event (event=1) or were censored (event=0)
- intervening event times. For subjects having no intervening events, the corresponding values of ie.time must be NA.
- Occasionally intervening events are recorded as happening at exactly
the same time as the termination of follow-up for some subjects.
Survfunction will not allow this. To randomly break the ties by subtracting a random number from such
- a list with components
S, ie.status, subs, reps.
Survobject containing start and stop times for intervals of observation, along with event indicators.
ie.statusis one if the intervening event has occurred at the start of the interval, zero otherwise.
subsis a vector of subscripts that can be used to replicate other variables the same way
repsspecifies how many times each original observation was replicated.
S, ie.status, subsare all the same length (at least the number of rows for
Sis) and are longer than the original
repsis the same length as the original
subsvector is suitable for passing to
calibrate, which pass this vector under the name
predab.resampleso that bootstrapping can be done by sampling with replacement from the original subjects rather than from the individual records created by
failure.time <- c(1 , 2, 3) event <- c(1 , 1, 0) ie.time <- c(NA, 1.5, 2.5) z <- ie.setup(failure.time, event, ie.time) S <- z$S S ie.status <- z$ie.status ie.status z$subs z$reps attach(input.data.frame[z$subs,]) #replicates all variables f <- cph(S ~ age + sex + ie.status) # Instead of duplicating rows of data frame, could do this: attach(input.data.frame) z <- ie.setup(failure.time, event, ie.time) s <- z$subs age <- age[s] sex <- sex[s] f <- cph(S ~ age + sex + ie.status)