WR_analysis: Perform Hierarchical Win Ratio Analysis

View source: R/WR_analysis.R

WR_analysisR Documentation

Perform Hierarchical Win Ratio Analysis

Description

Analyzes treatment-control pairwise comparisons across three prioritized outcome layers. The function computes layer-specific win, tie, and loss counts; sample sizes; Finkelstein-Schoenfeld statistics; and win ratio statistics based on permutation and large-sample variance formulas.

Usage

WR_analysis(dataset1, dataset2, dataset3)

Arguments

dataset1

Data frame containing pairwise scores for the first, highest-priority layer.

dataset2

Data frame containing pairwise scores through the second layer.

dataset3

Data frame containing pairwise scores through the third layer.

Value

A named list with four elements:

win.losses.count.summary

Counts and proportions of treatment wins, ties, and treatment losses by layer and overall.

sample.size.summary

Treatment, control, total, and pairwise comparison counts.

FS.analysis.summary

Finkelstein-Schoenfeld statistic, variance, z-score, and one-sided p-value.

WR.analysis.summary

Win ratio, log win ratio, variance estimates, confidence limits, and one-sided p-value.

References

Finkelstein, D. M., and Schoenfeld, D. A. (1999). Combining mortality and longitudinal measures in clinical trials. Statistics in Medicine, 18(11), 1341-1354.

Pocock, S. J., Ariti, C. A., Collier, T. J., and Wang, D. (2012). The win ratio: a new approach to the analysis of composite endpoints in clinical trials based on clinical priorities. European Heart Journal, 33(2), 176-182.

Yu, R. X., and Ganju, J. (2022). Sample size formula for a win ratio endpoint. Statistics in Medicine, 41(6), 950-963.

Examples

subjects <- data.frame(
  usubjid = c(1, 2, 1001, 1002),
  treatment = c(1, 1, 0, 0)
)
dataset1 <- merge(subjects, subjects, by = NULL)
names(dataset1) <- c("usubjid1", "treatment1", "usubjid2", "treatment2")
dataset1$score <- NA_real_
wr_rows <- dataset1$treatment1 == 1 & dataset1$treatment2 == 0
dataset1$score[wr_rows] <- c(1, 1, -1, -1)

dataset2 <- dataset1
dataset3 <- dataset1
WR_analysis(dataset1, dataset2, dataset3)$sample.size.summary

winratiosim documentation built on July 7, 2026, 1:07 a.m.