survival_timepoint {tern} | R Documentation |
Survival time point analysis
Description
The analyze function surv_timepoint()
creates a layout element to analyze patient survival rates and difference
of survival rates between groups at a given time point. The primary analysis variable vars
is the time variable.
Other required inputs are time_point
, the numeric time point of interest, and is_event
, a variable that
indicates whether or not an event has occurred. The method
argument is used to specify whether you want to analyze
survival estimations ("surv"
), difference in survival with the control ("surv_diff"
), or both of these
("both"
).
Usage
surv_timepoint(
lyt,
vars,
time_point,
is_event,
control = control_surv_timepoint(),
method = c("surv", "surv_diff", "both"),
na_str = default_na_str(),
nested = TRUE,
...,
table_names_suffix = "",
var_labels = "Time",
show_labels = "visible",
.stats = c("pt_at_risk", "event_free_rate", "rate_ci", "rate_diff", "rate_diff_ci",
"ztest_pval"),
.formats = NULL,
.labels = NULL,
.indent_mods = if (method == "both") {
c(rate_diff = 1L, rate_diff_ci = 2L,
ztest_pval = 2L)
} else {
c(rate_diff_ci = 1L, ztest_pval = 1L)
}
)
s_surv_timepoint(
df,
.var,
time_point,
is_event,
control = control_surv_timepoint()
)
a_surv_timepoint(
df,
.var,
time_point,
is_event,
control = control_surv_timepoint()
)
s_surv_timepoint_diff(
df,
.var,
.ref_group,
.in_ref_col,
time_point,
control = control_surv_timepoint(),
...
)
a_surv_timepoint_diff(
df,
.var,
.ref_group,
.in_ref_col,
time_point,
control = control_surv_timepoint(),
...
)
Arguments
lyt |
( |
vars |
( |
time_point |
( |
is_event |
( |
control |
(
|
method |
( |
na_str |
( |
nested |
( |
... |
additional arguments for the lower level functions. |
table_names_suffix |
( |
var_labels |
( |
show_labels |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
.ref_group |
( |
.in_ref_col |
( |
Value
-
surv_timepoint()
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_timepoint()
and/ors_surv_timepoint_diff()
to the table layout depending on the value ofmethod
.
-
s_surv_timepoint()
returns the statistics:-
pt_at_risk
: Patients remaining at risk. -
event_free_rate
: Event-free rate (%). -
rate_se
: Standard error of event free rate. -
rate_ci
: Confidence interval for event free rate.
-
-
a_surv_timepoint()
returns the corresponding list with formattedrtables::CellValue()
.
-
s_surv_timepoint_diff()
returns the statistics:-
rate_diff
: Event-free rate difference between two groups. -
rate_diff_ci
: Confidence interval for the difference. -
ztest_pval
: p-value to test the difference is 0.
-
-
a_surv_timepoint_diff()
returns the corresponding list with formattedrtables::CellValue()
.
Functions
-
surv_timepoint()
: Layout-creating function which can take statistics function arguments and additional format arguments. This function is a wrapper forrtables::analyze()
. -
s_surv_timepoint()
: Statistics function which analyzes survival rate. -
a_surv_timepoint()
: Formatted analysis function which is used asafun
insurv_timepoint()
whenmethod = "surv"
. -
s_surv_timepoint_diff()
: Statistics function which analyzes difference between two survival rates. -
a_surv_timepoint_diff()
: Formatted analysis function which is used asafun
insurv_timepoint()
whenmethod = "surv_diff"
.
Examples
library(dplyr)
adtte_f <- tern_ex_adtte %>%
filter(PARAMCD == "OS") %>%
mutate(
AVAL = day2month(AVAL),
is_event = CNSR == 0
)
# Survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 7
) %>%
build_table(df = adtte_f)
# Difference in survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 9,
method = "surv_diff",
.indent_mods = c("rate_diff" = 0L, "rate_diff_ci" = 2L, "ztest_pval" = 2L)
) %>%
build_table(df = adtte_f)
# Survival and difference in survival at given time points.
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
surv_timepoint(
vars = "AVAL",
var_labels = "Months",
is_event = "is_event",
time_point = 9,
method = "both"
) %>%
build_table(df = adtte_f)