*! version 1.0 14jan2025

Title

winprob - Compute the win probability for single outcome

Syntax

winprob
groupvar
scorevar
[if] [in],
[options]

options

Options
direction(string) Specify the direction of comparison.

citype(multiauc##citypes:citype) specify the
transformation method to use when constructing the confidence interval.

alpha(real) specify the two-sided type 1 error level.

test0(real) Specify the null hypothesis probability to test.
The default is 0.50.

winfrac(varname) Specify a variable to save the win fractions.

replace Replace the variable specified in winfrac().

citypes

Options
normal uses asymptotic Normal (Wald-type) method for large
samples.

logit uses a logit transformation. This is the default and
recomended in most cases..

Description

winprob performs a non-parametric test for the win probability (also ]
called the Wilcoxon-Mann-Whitney test probability, c-statistic, AUC,
probabilistic index). The command returns the point estimate and associated
confidence interval, standard error and hypothesis test for the win probability.

groupvar is the binary (0/1) indicator for each of two groups (for
example, placebo and treatment in the context of a randomized controlled trial).
The win probability is formulated to compare values of scorevar in
groupvar==1 compared to those in groupvar==0.

scorevar is score or value to be compared. The values can be binary,
ordinal or continuous in nature, but they must be a numeric type.

direction() specifies the direction of comparison of scores. If higher
values of scorevar are "better" or preferred to lower scores, then specify
direction(>), meaning the quantity computed is
WinProb = Prob[scorevar(groupvar==1) >=
scorevar(groupvar==0)].
If lower scores are preferred, then specify direction(<), then the
quantity computed is
WinProb = Prob[scorevar(groupvar==1) <=
scorevar(groupvar==0)].
By default, higher scores are considered "better" than lower scores.

citype() specified how the confidence interval is constructed.
The default and preferred method is the logit transformation.

winfrac() specifies the name of a new variable in which to save win
fractions which are the basis for how the win probability is estimated. If the
variable already exists, then replace must also be specified. The
existing variable will be dropped and replaced.

test0() specifies the null hypothesis test value for the win probability.
By default, this is 0.5, indicating no differences between groups.

alpha() specifies the two-sided type 1 error rate. By default, this
is 0.05.

Examples

Compute the win probability of foreign cars having higher prices than
domestic cars.

. sysuse auto

. winprob foreign price

Stored results

The following results are stored in r():

Scalars

r(winp) win probability

r(winp_ll) lower limit of confidence interval

r(winp_ul) upper limit of confidence interval

r(se_winp) standard error of win probability

r(logit_se) logit-based standard error of win probability
(only if logit confidence intervals are requested)

r(alpha) two-sided alpha level

r(test0) null hypothesis test value

r(p) two-sided p-value of test

r(t) test statistic based on t-distribution
(only if logit confidence intervals are requested)

r(t_df) test statistic degrees-of-freedom
(only if logit confidence intervals are requested)

r(z) test statistic based on standard Normal distribution
(only if Normal confidence intervals are requested)

Macros

r(citype) Method of construction of confidence interval.

Author

Leonardo Guizzetti

leonardo.guizzetti@gmail.com

Acknowledgements

Thanks to Guangyong Zou for the inpsiration to write this program.

References

Zou G. Confidence interval estimation for treatment effects in cluster
randomization trials based on ranks. Statistics in Medicine.
2021;40(14):3227-3250. doi:10.1002/sim.8918

Zou G, Zou L, Qiu S. Parametric and nonparametric methods for confidence
intervals and sample size planning for win probability in parallel-group
randomized trials with Likert item and Likert scale data.
Pharmaceutical Statistics. 2023; 22(3): 418-439. doi:10.1002/pst.2280