Skip to content

[Feature Request]: tbl_coxph #159

@reesnj

Description

@reesnj

Feature description

Suggestion for a new function tbl_coxph which computes the pairwise cox proportional hazards test and returns a gtsummary object of the results as below. This could rely on the get_cox_pairwise_df() function for computation and simply work on formatting these results into a table? Or it could compute the results itself if that is easier.

Image

Example

library(NEST.TLGs)
library(tidyverse)
adam_db <- syntheticadam::get_data("adtte")

# data pre-processing ----------------------------------------------------------

arm_var <- "TRT01P"

df_ttet01 <- adam_db$adtte |>
  dplyr::filter(PARAMCD == "PFS" & ANL01FL == "Y") |>
  mutate(is_event = CNSR == 0,
         is_not_event = CNSR == 1,
         first_event = ifelse(CNSR == 0, EVNTDESC, NA_character_))

# Set the treatment arm variable as a factor with levels in desired order
df_ttet01[[arm_var]] <- factor(df_ttet01[[arm_var]], levels = c(
  "Placebo",
  "Xanomeline Low Dose",
  "Xanomeline High Dose"
))

# Build Cox PH Model --------------------------------------------------------------------

coxph_formula <- as.formula(sprintf("Surv(AVAL, is_event) ~ %s", arm_var))

df_coxph <- df_ttet01 |>
  get_cox_pairwise_df(
    model_formula = coxph_formula,
    arm = arm_var
    )

As you can see, this code generates the necessary statistics but does not format this in a gtsummary object.

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions