Teal module to fit Cox univariable or multi-variable models consistent with
COXT01
and COXT02
standard outputs, respectively.
Usage
tm_t_coxreg(
label,
dataname,
parentname = ifelse(inherits(arm_var, "data_extract_spec"),
teal.transform::datanames_input(arm_var), "ADSL"),
arm_var,
arm_ref_comp = NULL,
paramcd,
cov_var,
strata_var,
aval_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"AVAL"), "AVAL", fixed = TRUE),
cnsr_var = teal.transform::choices_selected(teal.transform::variable_choices(dataname,
"CNSR"), "CNSR", fixed = TRUE),
multivariate = TRUE,
conf_level = teal.transform::choices_selected(c(0.95, 0.9, 0.8), 0.95, keep_order =
TRUE),
pre_output = NULL,
post_output = NULL,
basic_table_args = teal.widgets::basic_table_args()
)
Arguments
- label
(
character
)
menu item label of the module in the teal app.- dataname
(
character
)
analysis data used in teal module.- parentname
(
character
)
parent analysis data used in teal module, usually this refers toADSL
.- arm_var
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for variable names that can be used asarm_var
. It defines the grouping variable(s) in the results table. If there are two elements selected forarm_var
, second variable will be nested under the first variable.- arm_ref_comp
optional, (
list
)
If specified it must be a named list with each element corresponding to an arm variable inADSL
and the element must be another list (possibly with delayedteal.transform::variable_choices()
or delayedteal.transform::value_choices()
with the elements namedref
andcomp
that the defined the default reference and comparison arms when the arm variable is changed.- paramcd
(
choices_selected
ordata_extract_spec
)
variable value designating the studied parameter.- cov_var
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for the covariates variables.- strata_var
(
choices_selected
ordata_extract_spec
)
names of the variables for stratified analysis.- aval_var
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for the analysis variable.- cnsr_var
(
choices_selected
ordata_extract_spec
)
object with all available choices and preselected option for the censoring variable.- multivariate
(
logical
)
IfFALSE
, the univariable approach is used (equivalent toCOXT01
standard) instead of the multi-variable model (equivalent toCOXT02
standard).- conf_level
(
choices_selected
)
object with all available choices and preselected option for the confidence level, each within range of (0, 1).- pre_output
optional, (
shiny.tag
)
with text placed before the output to put the output into context. For example a title.- post_output
optional, (
shiny.tag
)
with text placed after the output to put the output into context. For example theshiny::helpText()
elements are useful.- basic_table_args
-
optional, (
basic_table_args
)
object created byteal.widgets::basic_table_args()
with settings for the module table. The argument is merged with optionteal.basic_table_args
and with default module arguments (hard coded in the module body).For more details, see the vignette:
vignette("custom-basic-table-arguments", package = "teal.widgets")
.
Details
The Cox Proportional Hazards (PH) model is the most commonly used method to estimate the magnitude of the effect in survival analysis. It assumes proportional hazards: the ratio of the hazards between groups (e.g., two arms) is constant over time. This ratio is referred to as the "hazard ratio" (HR) and is one of the most commonly reported metrics to describe the effect size in survival analysis. For further information about the Cox Proportional Hazards Model, check "Statistical Analysis of Clinical Trials Data with R", NEST team.
This modules expects that the analysis data has the following variables:
AVAL |
time to event |
CNSR |
boolean or 0,1 is element in AVAL censored |
PARAMCD |
variable used to filter for endpoint (e.g. OS), after
filtering for paramcd one observation per patient is expected |
The arm variables, stratification and covariate variables are taken from the
ADSL
data.
Note
The likelihood ratio test is not supported for model including strata, Wald test will be substituted.
Multi-Variable is the default choice for backward compatibility.
Examples
## First example
## =============
## The example below is based on the usual approach involving creation of
## a random CDISC dataset and then running the application.
adsl <- tmc_ex_adsl
adtte <- tmc_ex_adtte
arm_ref_comp <- list(
ACTARMCD = list(
ref = "ARM B",
comp = c("ARM A", "ARM C")
),
ARM = list(
ref = "B: Placebo",
comp = c("A: Drug X", "C: Combination")
)
)
app <- init(
data = cdisc_data(
cdisc_dataset("ADSL", adsl),
cdisc_dataset("ADTTE", adtte)
),
modules = modules(
tm_t_coxreg(
label = "Cox Reg.",
dataname = "ADTTE",
arm_var = choices_selected(c("ARM", "ARMCD", "ACTARMCD"), "ARM"),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
value_choices(adtte, "PARAMCD", "PARAM"), "OS"
),
strata_var = choices_selected(
c("COUNTRY", "STRATA1", "STRATA2"), "STRATA1"
),
cov_var = choices_selected(
c("AGE", "BMRKR1", "BMRKR2", "REGION1"), "AGE"
),
multivariate = TRUE
)
)
)
#> [INFO] 2023-08-14 14:44:15.0555 pid:1183 token:[] teal.modules.clinical Initializing tm_t_coxreg
if (interactive()) {
shinyApp(app$ui, app$server)
}
## Second example
## ==============
## This time, a synthetic pair of ADTTE/ADSL is fabricated for a Cox regression
## where ties and pval_method matter.
## Dataset fabrication
## -------------------
adtte <- data.frame(
STUDYID = "LUNG",
AVAL = c(4, 3, 1, 1, 2, 2, 3, 1, 2),
CNSR = c(1, 1, 1, 0, 1, 1, 0, 0, 0),
ARMCD = factor(
c(0, 1, 1, 1, 1, 0, 0, 0, 0),
labels = c("ARM A", "ARM B")
),
SEX = factor(
c(0, 0, 0, 0, 1, 1, 1, 1, 1),
labels = c("F", "M")
),
INST = factor(c("A", "A", "B", "B", "A", "B", "A", "B", "A")),
stringsAsFactors = FALSE
)
adtte <- base::rbind(adtte, adtte, adtte, adtte)
adtte <- dplyr::as_tibble(adtte)
set.seed(1)
adtte$INST <- sample(adtte$INST)
adtte$AGE <- sample(seq(5, 75, 5), size = nrow(adtte), replace = TRUE)
adtte$USUBJID <- paste("sub", 1:nrow(adtte), adtte$INST, sep = "-")
adtte$PARAM <- adtte$PARAMCD <- "OS"
adsl <- subset(
adtte,
select = c("USUBJID", "STUDYID", "ARMCD", "SEX", "INST", "AGE")
)
## Teal application
## ================
## Note that the R code exported by `Show R Code` does not include the data
## preprocessing. You will need to create the dataset as above before
## running the exported R code.
arm_ref_comp <- list(ARMCD = list(ref = "ARM A", comp = c("ARM B")))
app <- init(
data = cdisc_data(
cdisc_dataset(
dataname = "ADSL",
x = adsl
),
cdisc_dataset(
dataname = "ADTTE",
x = adtte
)
),
modules = modules(
tm_t_coxreg(
label = "Cox Reg.",
dataname = "ADTTE",
arm_var = choices_selected(c("ARMCD"), "ARMCD"),
arm_ref_comp = arm_ref_comp,
paramcd = choices_selected(
value_choices(adtte, "PARAMCD", "PARAM"), "OS"
),
strata_var = choices_selected(c("INST"), NULL),
cov_var = choices_selected(c("SEX", "AGE"), "SEX"),
multivariate = TRUE
)
)
)
#> [INFO] 2023-08-14 14:44:15.2517 pid:1183 token:[] teal.modules.clinical Initializing tm_t_coxreg
if (interactive()) {
shinyApp(app$ui, app$server)
}