winratiosim provides simulation tools for two-arm
clinical trials with a hierarchical win ratio endpoint. It simulates
time-to-event, recurrent event, and continuous outcomes; applies
prioritized pairwise win/loss scoring; and summarizes operating
characteristics for the win ratio and Finkelstein-Schoenfeld tests.
The package implements the simulation workflow used in:
Lee, S. Y. (2025). A note on the sample size formula for a win ratio endpoint. Statistics in Medicine, 44, e70165. https://doi.org/10.1002/sim.70165
After CRAN acceptance, install with:
install.packages("winratiosim")The development version can be installed from GitHub:
# install.packages("remotes")
remotes::install_github("yain22/winratiosim")library(winratiosim)
result <- winratiosim(
nsim = 10,
N = 400,
Randomization.ratio = c(1, 1),
alpha.JFM = 0,
theta.JFM = 1,
lambda_trt = 0.13,
lambda_ctl = 0.15,
ann.icr_trt = 0.32,
ann.icr_ctl = 0.55,
xbase_trt = 45,
xfinal_trt = 52.5,
xbase_ctl = 45,
xfinal_ctl = 45,
sd.delta.x_trt = 20,
sd.delta.x_ctl = 20,
censorrate_trt = 0.2,
censorrate_ctl = 0.2,
nc = 1,
seed = 20250518
)
result$df_WR.analysis.summaryFor publication-scale operating characteristics, increase
nsim substantially and set nc to the number of
worker processes you want to use.
After installation, open the package vignette for a longer worked example:
vignette("winratiosim", package = "winratiosim")power_fs <- mean(result$df_FS.analysis.summary$p_value_FS < 0.025,
na.rm = TRUE)
power_wr <- mean(result$df_WR.analysis.summary$LB_R_w > 1,
na.rm = TRUE)
binom.conf.exact(
x = sum(result$df_WR.analysis.summary$LB_R_w > 1, na.rm = TRUE),
n = sum(!is.na(result$df_WR.analysis.summary$LB_R_w))
)