View source: R/extract_time_to_event.R
| extract_time_to_event | R Documentation |
Creates a list of event times that can be passed to downstream
visualization or analysis functions such as competing.risk.time or
intercurrent.event.time in cifplot() and cifpanel().
Event types are specified by event 1, event 2, censoring, or user-specified codes.
extract_time_to_event(
formula,
data,
weights = NULL,
subset.condition = NULL,
na.action = na.omit,
which.event = c("event2", "event1", "censor", "censoring", "user_specified"),
code.event1 = 1,
code.event2 = 2,
code.censoring = 0,
code.user.specified = NULL,
read.unique.time = TRUE,
drop.empty = TRUE
)
formula |
A model formula specifying the outcome and (optionally) |
data |
A data frame containing variables in |
weights |
Optional numeric case weights or the name of a weight column. Rows with missing weights are excluded consistently with curve estimation. |
subset.condition |
Optional expression (as a character string) defining a
subset of |
na.action |
Function to handle missing values (default: |
which.event |
One of |
code.event1, code.event2, code.censoring |
Integer codes representing the
event and censoring categories. Defaults are |
code.user.specified |
When |
read.unique.time |
Logical if |
drop.empty |
Logical if |
This function is typically used internally by plotting and model functions, but can also be called directly to inspect the per-stratum event-time structure of a data frame.
A named list of numeric vectors, where each element corresponds to a stratum and contains the event times of the selected type.
stable
polyreg() for log-odds product modeling of CIFs; cifcurve() for KM/AJ estimators; cifplot() for display of a CIF; cifpanel() for display of multiple CIFs; ggsurvfit::ggsurvfit, patchwork::patchwork and modelsummary::modelsummary for display helpers.
data(diabetes.complications)
output <- extract_time_to_event(Event(t,epsilon) ~ fruitq,
data = diabetes.complications,
which.event = "event2")
cifplot(Event(t,epsilon) ~ fruitq,
data = diabetes.complications,
outcome.type="competing-risk",
add.conf=FALSE,
add.risktable=FALSE,
add.censor.mark=FALSE,
add.competing.risk.mark=TRUE,
competing.risk.time=output,
label.y="CIF of diabetic retinopathy",
label.x="Years from registration")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.