Teal module to fit Cox univariate or multivariate 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 univariate approach is used (equivalent toCOXT01
standard) instead of the multivariate 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.
Multivariate 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.
library(scda)
synthetic_cdisc_data_latest <- synthetic_cdisc_data("latest")
ADSL <- synthetic_cdisc_data_latest$adsl
ADTTE <- synthetic_cdisc_data_latest$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,
code = "synthetic_cdisc_data_latest <- synthetic_cdisc_data('latest')
ADSL <- synthetic_cdisc_data_latest$adsl"
),
cdisc_dataset("ADTTE", ADTTE,
code = "synthetic_cdisc_data_latest <- synthetic_cdisc_data('latest')
ADTTE <- synthetic_cdisc_data_latest$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] 2022-10-14 09:10:28.9758 pid:3139 token:[] teal.modules.clinical Initializing tm_t_coxreg
if (FALSE) {
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] 2022-10-14 09:10:29.1329 pid:3139 token:[] teal.modules.clinical Initializing tm_t_coxreg
if (FALSE) {
shinyApp(app$ui, app$server)
}