cph or
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)
Surv function will not allow this. To randomly break the ties
by subtracting a random number from such tied intervening event times,
specify
break.ties=TRUE. The random number is uniform between zero and
the minimum difference between any two untied
failure.times.
S, ie.status, subs, reps.
S is a
Surv
object containing start and stop times for intervals of observation,
along with event indicators.
ie.status is one if the intervening
event has occurred at the start of the interval, zero otherwise.
subs
is a vector of subscripts that can be used to replicate other
variables the same way
S was replicated.
reps specifies how many
times each original observation was replicated.
S, ie.status, subs are
all the same length (at least the number of rows for
S is) and are longer than the original
failure.time vector.
reps
is the same length as the original
failure.time vector.
The
subs vector is suitable for passing to
validate.lrm or
calibrate,
which pass this vector under the name
cluster on to
predab.resample so that bootstrapping can be
done by sampling with replacement from the original subjects rather than
from the individual records created by
ie.setup.
Frank Harrell
Department of Biostatistics
Vanderbilt University
f.harrell@vanderbilt.edu
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 ## Not run: 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) ## End(Not run)