| ie.setup | R Documentation |
Creates several new variables which help set up a dataset for modeling
with 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)
failure.time |
a numeric variable containing the event or censoring times for the terminating event |
event |
a binary (0/1) variable specifying whether observations had the terminating event (event=1) or were censored (event=0) |
ie.time |
intervening event times. For subjects having no intervening events, the corresponding values of ie.time must be NA. |
break.ties |
Occasionally intervening events are recorded as happening at exactly
the same time as the termination of follow-up for some subjects.
The |
a list with components 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
fh@fharrell.com
cph, coxph,
Surv, cr.setup,
predab.resample
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.