survival_time {tern} | R Documentation |
Survival time analysis
Description
The analyze function surv_time()
creates a layout element to analyze survival time by calculating survival time
median, median confidence interval, quantiles, and range (for all, censored, or event patients). The primary
analysis variable vars
is the time variable and the secondary analysis variable is_event
indicates whether or
not an event has occurred.
Usage
surv_time(
lyt,
vars,
is_event,
control = control_surv_time(),
ref_fn_censor = TRUE,
na_str = default_na_str(),
nested = TRUE,
...,
var_labels = "Time to Event",
show_labels = "visible",
table_names = vars,
.stats = c("median", "median_ci", "quantiles", "range"),
.stat_names = NULL,
.formats = list(median_ci = "(xx.x, xx.x)", quantiles = "xx.x, xx.x", range =
"xx.x to xx.x", quantiles_lower = "xx.x (xx.x - xx.x)", quantiles_upper =
"xx.x (xx.x - xx.x)", median_ci_3d = "xx.x (xx.x - xx.x)"),
.labels = list(median_ci = "95% CI", range = "Range"),
.indent_mods = list(median_ci = 1L)
)
s_surv_time(df, .var, ..., is_event, control = control_surv_time())
a_surv_time(
df,
labelstr = "",
...,
.stats = NULL,
.stat_names = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
Arguments
lyt |
( |
vars |
( |
is_event |
( |
control |
(
|
ref_fn_censor |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
var_labels |
( |
show_labels |
( |
table_names |
( |
.stats |
( Options are: |
.stat_names |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
labelstr |
( |
Value
-
surv_time()
returns a layout object suitable for passing to further layouting functions, or tortables::build_table()
. Adding this function to anrtable
layout will add formatted rows containing the statistics froms_surv_time()
to the table layout.
-
s_surv_time()
returns the statistics:-
median
: Median survival time. -
median_ci
: Confidence interval for median time. -
median_ci_3d
: Median with confidence interval for median time. -
quantiles
: Survival time for two specified quantiles. -
quantiles_lower
: quantile with confidence interval for the first specified quantile. -
quantiles_upper
: quantile with confidence interval for the second specified quantile. -
range_censor
: Survival time range for censored observations. -
range_event
: Survival time range for observations with events. -
range
: Survival time range for all observations.
-
-
a_surv_time()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
-
surv_time()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
. -
s_surv_time()
: Statistics function which analyzes survival times. -
a_surv_time()
: Formatted analysis function which is used asafun
insurv_time()
.
Examples
library(dplyr)
adtte_f <- tern_ex_adtte %>%
filter(PARAMCD == "OS") %>%
mutate(
AVAL = day2month(AVAL),
is_event = CNSR == 0
)
df <- adtte_f %>% filter(ARMCD == "ARM A")
basic_table() %>%
split_cols_by(var = "ARMCD") %>%
add_colcounts() %>%
surv_time(
vars = "AVAL",
var_labels = "Survival Time (Months)",
is_event = "is_event",
control = control_surv_time(conf_level = 0.9, conf_type = "log-log")
) %>%
build_table(df = adtte_f)
a_surv_time(
df,
.df_row = df,
.var = "AVAL",
is_event = "is_event"
)