The bunsen package aims to provide an easy-to-use interface for estimating marginal or unconditional Hazard Ratio (HR) and Restricted Mean Survival Time (RMST) when adjusting prognostic covariates in clinical trials.
We introduce bunsen package for marginal HR and RMST estimation and variance for time-to-event endpoints in clinical trials. We included multiple features in current package:
library(bunsen)
data('oak')
<- coxph(Surv(OS, os.status) ~ trt+btmb+pdl1, data=oak)
cox_event
<- coxph(Surv(OS, 1-os.status) ~trt+btmb+pdl1, data=oak)
cox_censor
=get_marginal_effect(trt = 'trt',cox_event,cox_censor,M=10000,data=oak,seed = 1)
result# Calculating point estimate in local clustermq using multiprocess...
# Submitting 4 worker jobs (ID: cmq7488) ...
# Running 4 calculations (8 objs/120.1 Kb common; 1 calls/chunk) ...
# Master: [8.6 secs 0.8% CPU]; Worker: [avg 19.1% CPU, max 303.9 Mb]
# Calculating SE in clustermq using bootstrap N = 1000...
# Submitting 100 worker jobs (ID: cmq9642) ...
# Running 1,000 calculations (14 objs/354.8 Kb common; 1 calls/chunk) ...
# Master: [16.0 secs 8.4% CPU]; Worker: [avg 48.5% CPU, max 307.7 Mb]
result# Call:
# Surv(OS, os.status) ~ trt + btmb + pdl1
# Marginal treatment effect calculated by N = 10000 simulations
# Number of sample: 578
# coef exp(coef) se(coef) 2.5% 97.5%
# trt -0.442910 0.642165 0.103905 -0.654306 -0.245416
# clustermq setting:
# number of remote workers = 100 , each worker has 1 core(s)
# Point estimate: parallel computation (clustermq)
# SE (bootstrap): parallel computation
# 95%CI estimated by bootstrap
summary(result)
# Call:
# Surv(OS, os.status) ~ trt + btmb + pdl1
# Marginal treatment effect calculated by N = 10000 simulations
# Treatment variable: trt ------ Number of sample: 578
# Number of events in cox_event: 423
# Number of events in cox_censor: 155
# Random seed = 1
# Original treatment effect:
# coef exp(coef) se(coef) z Pr(>|z|)
# trt -0.452408 0.636095 0.098428 -4.596346 0.000004
# Marginal treatment effect:
# coef exp(coef) se(coef) z Pr(>|z|)
# trt -0.442910 0.642165 0.103905 -4.262646 0.000020
# 95% CI of Marginal treatment effect (bootstrap): -0.654 , -0.245
library(bunsen)
data('oak')
=26
tau
=oak$OS
time
=oak$os.status
status
=oak$trt
trt
=oak[,c('btmb','pdl1')]
covariates
=get_rmst_estimate(time, status, trt, covariates, tau, SE = "delta")
result
result# Call:
# Surv(time, status) ~ btmb + pdl1 + strata(trt)
# Restricted survival time: 26
# coef se(coef) 2.5% 97.5%
# trt 3.265971 0.716351 1.861923 4.670019
# Method for SE calculation: delta
=get_rmst_estimate(time, status, trt, covariates, tau, SE = "boot", seed = 2025)
result
result
# Call:
# Surv(time, status) ~ btmb + pdl1 + strata(trt)
# Restricted survival time: 26
# coef se(coef) 2.5% 97.5%
# trt 3.265971 0.715191 1.994362 4.699867
# Method for SE calculation: bootNumber of bootstrap: 1000 , random seed = 2025
bunsen is developed based on three key papers: