rgtsummarysurvival

gtsummary of Cox model with two period splitted data (after survSplit)


When summirizing results from a multivariable Cox model using step function (piecewise time varing HR, data splitted with survSplit into 2 periods) using tbl_regression I get modified patients and events number.

How can I keep original N and Event N for the covariates not concerned by time varying effect ?

Here's an example :

m1 <- coxph(formula = Surv(time, status) ~ trt + prior + karno, data = veteran)

tbl_regression(m1, exponentiate=T) %>% add_n(location = "level") %>% add_nevent(location = "level") %>% bold_p(t = 0.05)

tbl_regression(m1, exponentiate=T) %>% add_n(location = "level") %>% add_nevent(location = "level") %>% bold_p(t = 0.05)

vet2 <- survSplit(Surv(time, status) ~ ., data= veteran, cut=c(90, 180), episode= "tgroup", id="id")

m2 <- coxph(formula = Surv(tstart, time, status) ~ trt + prior + karno:strata(tgroup), data = vet2) tbl_regression(m2, exponentiate=T) %>% add_n(location = "level") %>% add_nevent(location = "level") %>% bold_p(t = 0.05)


Solution

  • When posting to Stackoverflow, it's best to provide a minimal reproducible example we can all run on our machines.

    Typically, these time-varying covariate structures duplicate rows in your data frame, which is likely why you're seeing additional counts. I know that if you utilize the native time-varying structures in the survival package, the multi-row structure is accounted for and correct counts are returned.

    The easiest way to get what you're after would be to build two tables: one with your time varying components and one a vanilla Cox model. You can then use tbl_merge() to merge the tables together and modify_column_hide() to hide the estimates from the vanilla Cox model.