Analysis based on multivariable Cox models is usually not performed for the Clinical Study Report (CSR) or regulatory documents, serving exploratory purposes only (e.g. for publication). In practice, the model usually includes only the main effects (without interaction terms). It produces the estimates for each of the covariates included in the model. The analysis follows the same principles (i.e. stratified vs. unstratified analysis and tie handling) as the general Cox model analysis also used in COXT01. Since there is usually no pre-specified hypothesis testing for such analysis, the p-values must be interpreted with caution.
The summarize_coxreg function fits, tidies and arranges a Cox regression model in a table layout using the rtables framework. For a multivariable Cox regression model, argument multivar must be set to TRUE. Arguments variables and control can be specified to set up the model (see ?summarize_coxreg for more details and customization options). All variables specified within variables must be present in the data used when building the table.
To see the same model as a data.frame object, these two arguments (as well as the data) can be passed to the fit_coxreg_multivar function, and the resulting list tidied using broom::tidy().
variables <-list(time ="AVAL",event ="EVENT",arm ="ARM",covariates =c("SEX", "AGE"))lyt <-basic_table() %>%summarize_coxreg(variables = variables, multivar =TRUE) %>%append_topleft("Effect/Covariate Included in the Model")result <-build_table(lyt = lyt, df = anl)result
Effect/Covariate Included in the Model Hazard Ratio 95% CI p-value
——————————————————————————————————————————————————————————————————————————————
Treatment:
Planned Arm (reference = B: Placebo) 0.2643
A: Drug X 0.96 (0.66, 1.42) 0.8536
C: Combination 1.27 (0.88, 1.83) 0.2010
Covariate:
Sex (reference = F)
M 1.09 (0.80, 1.48) 0.5987
Age
All 0.99 (0.97, 1.01) 0.5104
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
The estimation of interaction terms is not supported.
Interaction terms are not included in the GDSR. For this reason and because we must take precautions when fitting such models, this functionality has not been translated in fit_coxreg_multivar. Please remove interaction terms or, if required by the study, refer to the survival::coxph function. Aside from this, using tern the developer must add the necessary variables to the analysis dataset during pre-processing based on ADVS or ADSUB. An example can be found in DMT01.
This option is not supported.
See the Multivariable Cox Regression with Interaction Term tab for more details.
This option is not supported.
See the Multivariable Cox Regression with Interaction Term tab for more details.
Additional controls can be customized using control_coxreg (see ?control_coxreg) such as the ties calculation method and the confidence level. Stratification variables can be added via the strata element of the variables list.
Effect/Covariate Included in the Model Hazard Ratio 90% CI
————————————————————————————————————————————————————————————————————
Treatment:
Planned Arm Code (reference = ARM A)
ARM B 1.03 (0.74, 1.42)
ARM C 1.30 (0.96, 1.77)
Covariate:
Sex (reference = F)
M 1.08 (0.83, 1.40)
Age
All 0.99 (0.98, 1.01)
Experimental use!
WebR is a tool allowing you to run R code in the web browser. Modify the code below and click run to see the results. Alternatively, copy the code and click here to open WebR in a new tab.
See the Multivariable Cox Regression with Interaction Term tab.
Code
library(dplyr)library(tern)library(broom)adtte <- random.cdisc.data::cadtte# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adtte <-df_explicit_na(adtte)anl <- adtte %>%filter( PARAMCD =="OS", SEX %in%c("F", "M"), RACE %in%c("ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE") ) %>%mutate(ARM =droplevels(relevel(ARM, "B: Placebo")),SEX =droplevels(SEX),RACE =droplevels(RACE) ) %>%mutate(EVENT =1- CNSR) %>%var_relabel(ARM ="Planned Arm",SEX ="Sex",RACE ="Race",AGE ="Age" )
Warning: `datanames<-()` was deprecated in teal.data 0.6.1.
ℹ invalid to use `datanames()<-` or `names()<-` on an object of class
`teal_data`. See ?names.teal_data
shinylive allow you to modify to run shiny application entirely in the web browser. Modify the code below and click re-run the app to see the results. The performance is slighly worse and some of the features (e.g. downloading) might not work at all.
---title: COXT02subtitle: Multivariable Cox Regression---------------------------------------------------------------------------{{< include ../../_utils/envir_hook.qmd >}}```{r setup, echo = FALSE, warning = FALSE, message = FALSE}library(dplyr)library(tern)library(broom)adtte <- random.cdisc.data::cadtte# Ensure character variables are converted to factors and empty strings and NAs are explicit missing levels.adtte <- df_explicit_na(adtte)anl <- adtte %>% filter( PARAMCD == "OS", SEX %in% c("F", "M"), RACE %in% c("ASIAN", "BLACK OR AFRICAN AMERICAN", "WHITE") ) %>% mutate( ARM = droplevels(relevel(ARM, "B: Placebo")), SEX = droplevels(SEX), RACE = droplevels(RACE) ) %>% mutate(EVENT = 1 - CNSR) %>% var_relabel( ARM = "Planned Arm", SEX = "Sex", RACE = "Race", AGE = "Age" )``````{r include = FALSE}webr_code_labels <- c("setup")```{{< include ../../_utils/webr_no_include.qmd >}}## OutputAnalysis based on multivariable Cox models is usually not performed for the Clinical Study Report (CSR) or regulatory documents, serving exploratory purposes only (e.g. for publication). In practice, the model usually includes only the main effects (without interaction terms). It produces the estimates for each of the covariates included in the model. The analysis follows the same principles (i.e. stratified vs. unstratified analysis and tie handling) as the general Cox model analysis also used in `COXT01`. Since there is usually no pre-specified hypothesis testing for such analysis, the p-values must be interpreted with caution.::::: panel-tabset## Multivariable Cox RegressionThe `summarize_coxreg` function fits, tidies and arranges a Cox regression model in a table layout using the `rtables` framework. For a multivariable Cox regression model, argument `multivar` must be set to `TRUE`. Arguments `variables` and `control` can be specified to set up the model (see `?summarize_coxreg` for more details and customization options). All variables specified within `variables` must be present in the data used when building the table.To see the same model as a `data.frame` object, these two arguments (as well as the data) can be passed to the `fit_coxreg_multivar` function, and the resulting list tidied using `broom::tidy()`.::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant1, test = list(result_v1 = "result")}variables <- list( time = "AVAL", event = "EVENT", arm = "ARM", covariates = c("SEX", "AGE"))lyt <- basic_table() %>% summarize_coxreg(variables = variables, multivar = TRUE) %>% append_topleft("Effect/Covariate Included in the Model")result <- build_table(lyt = lyt, df = anl)result``````{r include = FALSE}webr_code_labels <- c("variant1")```{{< include ../../_utils/webr.qmd >}}:::## Multivariable Cox Regression <br/> with Interaction TermThe estimation of interaction terms is not supported.Interaction terms are not included in the GDSR. For this reason and because we must take precautions when fitting such models, this functionality has not been translated in `fit_coxreg_multivar`. Please remove interaction terms or, if required by the study, refer to the `survival::coxph` function. Aside from this, using `tern` the developer must add the necessary variables to the analysis dataset during pre-processing based on ADVS or ADSUB. An example can be found in `DMT01`.## Multivariable Cox Regression <br/> Specifying CovariatesThis option is not supported.See the *Multivariable Cox Regression with Interaction Term* tab for more details.## Multivariable Cox Regression <br/> Specifying Covariates from ADSUBThis option is not supported.See the *Multivariable Cox Regression with Interaction Term* tab for more details.## Multivariable Cox Regression <br/> Setting Strata, Ties, Alpha Level, StatisticsAdditional controls can be customized using `control_coxreg` (see `?control_coxreg`) such as the ties calculation method and the confidence level. Stratification variables can be added via the `strata` element of the `variables` list.::: {.panel-tabset .nav-justified group="webr"}## {{< fa regular file-lines sm fw >}} Preview```{r variant2, test = list(result_v2 = "result")}variables <- list( time = "AVAL", event = "EVENT", arm = "ARMCD", covariates = c("SEX", "AGE"), strata = "RACE")control <- control_coxreg( conf_level = 0.9, ties = "efron")lyt <- basic_table() %>% summarize_coxreg( variables = variables, control = control, multivar = TRUE, .stats = c("hr", "ci") ) %>% append_topleft("Effect/Covariate Included in the Model")result <- build_table(lyt = lyt, df = anl)result``````{r include = FALSE}webr_code_labels <- c("variant2")```{{< include ../../_utils/webr.qmd >}}:::## Multivariable Cox Regression <br/> with Selection Process for CovariatesSee the *Multivariable Cox Regression with Interaction Term* tab.## Data Setup```{r setup}#| code-fold: show```:::::{{< include ../../_utils/save_results.qmd >}}## `teal` App::: {.panel-tabset .nav-justified}## {{< fa regular file-lines fa-sm fa-fw >}} Preview```{r teal, opts.label = c("skip_if_testing", "app")}library(teal.modules.clinical)## Data reproducible codedata <- teal_data()data <- within(data, { ADSL <- random.cdisc.data::cadsl ADTTE <- random.cdisc.data::cadtte})datanames <- c("ADSL", "ADTTE")datanames(data) <- datanamesjoin_keys(data) <- default_cdisc_join_keys[datanames]## Reusable Configuration For ModulesADTTE <- data[["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") ))## Setup Appapp <- init( data = data, 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("SEX", "STRATA1", "STRATA2"), NULL ), cov_var = choices_selected( c("AGE", "SEX", "RACE"), c("AGE", "SEX") ), multivariate = TRUE ) ))shinyApp(app$ui, app$server)```{{< include ../../_utils/shinylive.qmd >}}:::{{< include ../../repro.qmd >}}