calcWINS.data.frame {hce}R Documentation

Win statistics calculation using a data frame

Description

Win statistics calculation using a data frame

Usage

## S3 method for class 'data.frame'
calcWINS(
  x,
  AVAL,
  TRTP,
  ref,
  alpha = 0.05,
  WOnull = 1,
  SE_WP_Type = c("biased", "unbiased"),
  ...
)

Arguments

x

a data frame containing subject-level data.

AVAL

variable in the data with ordinal analysis values.

TRTP

the treatment variable in the data.

ref

the reference treatment group.

alpha

2-sided significance level. The default is 0.05.

WOnull

the null hypothesis. The default is 1.

SE_WP_Type

biased or unbiased standard error for win probability. The default is biased.

...

additional parameters.

Details

When SE_WP_Type = "unbiased", the calculations for win proportion, net benefit, and win odds utilize the unbiased standard error from Brunner-Konietschke (2025) paper which is a reformulation of the original formula proposed by Bamber (1975).

Value

a list containing win statistics and their confidence intervals. It contains the following named data frames:

References

The theory of win statistics is covered in the following papers:

See Also

calcWINS(), calcWINS.hce(), calcWINS.formula().

Examples

calcWINS(x = COVID19b, AVAL = "GROUP", TRTP = "TRTP", ref = "Placebo")
## Biased vs unbiased
n0 <- 5; n1 <- 7; p0 <- 0.2; p1 <- 0.5; x <- 1:20; delta <- 0.5
WP0 <- (p1 - p0)/2 + 0.5
DAT <- NULL
for(i in x){
  dat <- data.frame(AVAL = c(rbinom(n1, size = 1, p1), rbinom(n0, size = 1, p0)), 
  TRTP = c(rep("A", n1), rep("P", n0)))
  CL1 <- calcWINS(x = dat, AVAL = "AVAL", TRTP = "TRTP", ref = "P")$WP
  CL1$Type <- "biased"
  CL2 <- calcWINS(x = dat, AVAL = "AVAL", TRTP = "TRTP", 
                  ref = "P", SE_WP_Type = "unbiased")$WP
  CL2$Type <- "unbiased"
  DAT <- rbind(DAT, CL1, CL2)
}
WP <- DAT$WP[DAT$Type == "unbiased"]
plot(x, WP, pch = 19, xlab = "Simulations", ylab = "Win Probability", ylim = c(0., 1.1))
points(x + delta, WP, pch = 19)
arrows(x, DAT$LCL[DAT$Type == "unbiased"], 
       x, DAT$UCL[DAT$Type == "unbiased"], angle = 90, code = 3, length = 0.05, "green")
arrows(x + delta, DAT$LCL[DAT$Type == "biased"], 
       x + delta, DAT$UCL[DAT$Type == "biased"], angle = 90, code = 3, length = 0.05, col = "red")
abline(h = c(WP0, 1), col = "blue", lty = 3)
legend("bottomleft", legend = c("True WP", "Biased", "Unbiased"), 
                    col = c(4, 2, 3), lty = c(3, 1, 1 ), cex = 0.75)

[Package hce version 0.8.0 Index]