Usage
s_coxph_pairwise(
df,
.ref_group,
.in_ref_col,
.var,
is_event,
strat = NULL,
control = control_coxph()
)
a_coxph_pairwise(
df,
.ref_group,
.in_ref_col,
.var,
is_event,
strat = NULL,
control = control_coxph()
)
coxph_pairwise(
lyt,
vars,
...,
var_labels = "CoxPH",
show_labels = "visible",
table_names = vars,
.stats = c("pvalue", "hr", "hr_ci"),
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
Arguments
- df
(
data frame
)
data set containing all analysis variables.- .ref_group
(
data frame
orvector
)
the data corresponding to the reference group.- .in_ref_col
(
logical
)TRUE
when working with the reference level,FALSE
otherwise.- .var
(
string
)
single variable name that is passed byrtables
when requested by a statistics function.- is_event
(
logical
)TRUE
if event,FALSE
if time to event is censored.- strat
(
character
orNULL
) variable names indicating stratification factors.- control
-
(
list
)
parameters for comparison details, specified by using
the helper functioncontrol_coxph()
. Some possible parameter options are:pval_method
: (string
)
p-value method for testing hazard ratio = 1. Default method is "log-rank" which comes fromsurvival::survdiff()
, can also be set to "wald" or "likelihood" that comes fromsurvival::coxph()
.ties
: (string
)
specifying the method for tie handling. Default is "efron", can also be set to "breslow" or "exact". See more insurvival::coxph()
conf_level
: (proportion
)
confidence level of the interval for HR.
- lyt
(
layout
)
input layout where analyses will be added to.- vars
(
character
)
variable names for the primary analysis variable to be iterated over.- ...
additional arguments for the lower level functions.
- var_labels
character for label.
- show_labels
label visibility: one of "default", "visible" and "hidden".
- table_names
(
character
)
this can be customized in case that the samevars
are analyzed multiple times, to avoid warnings fromrtables
.- .stats
(
character
)
statistics to select for the table.- .formats
(named
character
orlist
)
formats for the statistics.- .labels
(named
character
)
labels for the statistics (without indent).- .indent_mods
(named
integer
)
indent modifiers for the labels.
Value
The statistics are:
pvalue
: p-value to test HR = 1.hr
: hazard ratio.hr_ci
: confidence interval for hazard ratio.n_tot
: total number of observationsn_tot_events
: total number of events
Functions
s_coxph_pairwise()
: Statistics Function which analyzes HR, CIs of HR and p-value with coxph model.a_coxph_pairwise()
: Formatted Analysis function which can be further customized by callingrtables::make_afun()
on it. It is used asafun
inrtables::analyze()
.coxph_pairwise()
: Analyze Function which adds the pairwise coxph analysis to the input layout. Note that additional formatting arguments can be used here.
Examples
library(scda)
library(dplyr)
ADTTE <- synthetic_cdisc_data("latest")$adtte
ADTTE_f <- ADTTE %>%
filter(PARAMCD == "OS") %>%
mutate(is_event = CNSR == 0)
df <- ADTTE_f %>%
filter(ARMCD == "ARM A")
df_ref_group <- ADTTE_f %>%
filter(ARMCD == "ARM B")
# Internal function - s_coxph_pairwise
if (FALSE) {
s_coxph_pairwise(df, df_ref_group, .in_ref_col = FALSE, .var = "AVAL", is_event = "is_event")
}
# Internal function - a_coxph_pairwise
if (FALSE) {
a_coxph_pairwise(df, df_ref_group, .in_ref_col = FALSE, .var = "AVAL", is_event = "is_event")
}
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
coxph_pairwise(
vars = "AVAL",
is_event = "is_event",
var_labels = "Unstratified Analysis"
) %>%
build_table(df = ADTTE_f)
#> ARM A ARM B ARM C
#> (N=134) (N=134) (N=132)
#> —————————————————————————————————————————————————————————————
#> Unstratified Analysis
#> p-value (log-rank) 0.0334 <0.0001
#> Hazard Ratio 1.39 2.75
#> 95% CI (1.03, 1.90) (2.05, 3.70)
basic_table() %>%
split_cols_by(var = "ARMCD", ref_group = "ARM A") %>%
add_colcounts() %>%
coxph_pairwise(
vars = "AVAL",
is_event = "is_event",
var_labels = "Stratified Analysis",
strat = "SEX",
control = control_coxph(pval_method = "wald")
) %>%
build_table(df = ADTTE_f)
#> ARM A ARM B ARM C
#> (N=134) (N=134) (N=132)
#> ———————————————————————————————————————————————————————————
#> Stratified Analysis
#> p-value (wald) 0.0487 <0.0001
#> Hazard Ratio 1.36 2.73
#> 95% CI (1.00, 1.86) (2.02, 3.69)