kaplan_meier {junco} | R Documentation |
Survival time analysis
Description
The analyze function kaplan_meier()
creates a layout element to analyze
survival time by calculating survival time median, 2 quantiles, each with
their confidence intervals, 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
a_kaplan_meier(
df,
.var,
...,
.stats = NULL,
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_kaplan_meier(df, .var, is_event, control = control_surv_time())
Arguments
df |
( |
.var |
( |
... |
additional arguments for the lower level functions. |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
is_event |
( |
control |
(
|
Value
-
a_kaplan_meier()
returns the corresponding list with formattedrtables::CellValue()
.
-
s_kaplan_meier()
returns the following statistics:-
quantiles_lower
: Lower quantile estimate and confidence interval for it. -
median_ci_3d
: Median survival time and confidence interval for it. -
quantiles_upper
: Upper quantile estimate and confidence interval for it. -
range_with_cens_info
: Survival time range with censoring information.
-
Functions
-
a_kaplan_meier()
: Formatted analysis function which is used asafun
-
s_kaplan_meier()
: Statistics function which analyzes survival times using Kaplan-Meier.
Note
These functions have been forked from the tern
package file survival_time.R
.
Here we have the additional features:
Additional statistics
quantiles_lower
,quantiles_upper
,range_with_cens_info
are returned.
Examples
library(dplyr)
library(tern)
adtte_f <- tern::tern_ex_adtte |>
filter(PARAMCD == "OS") |>
mutate(
AVAL = tern::day2month(AVAL),
is_event = CNSR == 0
)
df <- adtte_f |> filter(ARMCD == "ARM A")
a_kaplan_meier(
df,
.var = "AVAL",
is_event = "is_event"
)
basic_table() |>
split_cols_by(var = "ARMCD") |>
add_colcounts() |>
analyze(
vars = "AVAL",
afun = a_kaplan_meier,
var_labels = "Kaplan-Meier estimate of time to event (months)",
show_labels = "visible",
extra_args = list(
is_event = "is_event",
control = control_surv_time(conf_level = 0.9, conf_type = "log-log")
)
) |>
build_table(df = adtte_f)