Thebunsen package aims to provide an easy-to-useinterface for estimatingmarginal or unconditional Hazard Ratio(HR) and Restricted Mean Survival Time (RMST) when adjustingprognostic covariates in clinical trials.
We introducebunsen package for marginal HR and RMSTestimation and variance for time-to-event endpoints in clinical trials.We included multiple features in current package:

library(bunsen)data('oak')cox_event<-coxph(Surv(OS, os.status)~ trt+btmb+pdl1,data=oak)cox_censor<-coxph(Surv(OS,1-os.status)~trt+btmb+pdl1,data=oak)result=get_marginal_effect(trt ='trt',cox_event,cox_censor,M=10000,data=oak,seed =1)# 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 bootstrapsummary(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.245library(bunsen)data('oak')tau=26time=oak$OSstatus=oak$os.statustrt=oak$trtcovariates=oak[,c('btmb','pdl1')]result=get_rmst_estimate(time, status, trt, covariates, tau,SE ="delta")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: deltaresult=get_rmst_estimate(time, status, trt, covariates, tau,SE ="boot",seed =2025)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 = 2025bunsen is developed based on three key papers: