Skip to contents

Calculates the probability of winning (winP). In the referenced article Zou et al (2022) proposes a method for calculating probability of winning with a confidence interval an p-value testing.

Usage

win_prob(
  data,
  response = NULL,
  group = NULL,
  alpha = 0.05,
  beta = 0.2,
  group.ratio = 1,
  sample.size = FALSE,
  print.tables = FALSE,
  dec = 3
)

Arguments

data

A data frame containing the response and group variable.

response

The name of the response variable. Takes first column if empty.

group

The name of the group variable. Takes second column if empty.

alpha

The alpha level for the hypothesis test. Default is 0.05.

beta

The beta level for the sample size calculation. Default is 0.2.

group.ratio

The ratio of group sizes. Default is 1.

sample.size

Flag to include sample size calculation. Default is FALSE.

print.tables

Flag to print cumulative tables. Default is FALSE.

dec

Numeric for decimals to print. Default is 3.

Value

A list containing the win_prob statistics.

Examples

win_prob(data=stRoke::talos,response="mrs_6",group="rtreat")
#> $list_cum
#> $list_cum$Active
#>   mrs_6 rtreat Freq       prop overall_rank rank    win_frac
#> 1     0 Active   14 0.17721519        175.0 72.5 0.847107438
#> 2     1 Active   29 0.36708861        113.5 51.0 0.516528926
#> 3     2 Active   22 0.27848101         49.0 25.5 0.194214876
#> 4     3 Active    9 0.11392405         15.0 10.0 0.041322314
#> 5     4 Active    3 0.03797468          7.0  4.0 0.024793388
#> 6     6 Active    2 0.02531646          2.5  1.5 0.008264463
#> 
#> $list_cum$Placebo
#>    mrs_6  rtreat Freq       prop overall_rank  rank   win_frac
#> 7      0 Placebo   37 0.30578512        175.0 103.0 0.91139241
#> 8      1 Placebo   43 0.35537190        113.5  63.0 0.63924051
#> 9      2 Placebo   35 0.28925620         49.0  24.0 0.31645570
#> 10     3 Placebo    2 0.01652893         15.0   5.5 0.12025316
#> 11     4 Placebo    2 0.01652893          7.0   3.5 0.04430380
#> 12     6 Placebo    2 0.01652893          2.5   1.5 0.01265823
#> 
#> 
#> $group_levels
#> [1] "Active"  "Placebo"
#> 
#> $sum_a
#> [1] 79
#> 
#> $sum_b
#> [1] 121
#> 
#> $winP_a
#> [1] 0.3996757
#> 
#> $winP_b
#> [1] 0.6003243
#> 
#> $var_win_frac_a
#> [1] 0.07609113
#> 
#> $var_win_frac_b
#> [1] 0.06806341
#> 
#> $var_win_prob
#> [1] 0.001525686
#> 
#> $se_win_prob
#> [1] 0.03906004
#> 
#> $conf.int
#> [1] 0.6124886 0.3724300
#> 
#> $test_stat
#> [1] 2.498962
#> 
#> $p_val
#> [1] 0.01245577
#> 
#> $nnt
#> [1] -9.967675
#> 
#> $ss_n
#> [1] NA
#> 
#> $param.record
#> $param.record$data
#>      rtreat mrs_1 mrs_6 hypertension diabetes   civil
#> 38   Active     1     1           no       no partner
#> 434  Active     1     1          yes       no partner
#> 588  Active     2     2          yes       no partner
#> 42   Active     0     0          yes       no partner
#> 160 Placebo     1     1          yes       no partner
#> 174  Active     0     1          yes       no   alone
#> 11  Placebo     2     1          yes      yes   alone
#> 601 Placebo     1     1           no       no partner
#> 412  Active     0     0          yes       no partner
#> 88  Placebo     1     1          yes      yes partner
#> 56  Placebo     0     0           no       no   alone
#> 235 Placebo     2     1          yes      yes   alone
#> 205  Active     3     3           no       no partner
#> 62   Active     2     2          yes       no   alone
#> 593 Placebo     2     2           no       no   alone
#> 143  Active     2     1          yes       no partner
#> 520  Active     2     2           no      yes partner
#> 144 Placebo     1     0          yes       no partner
#> 383  Active     2     3           no       no   alone
#> 347 Placebo     1     0          yes      yes partner
#> 346  Active     1     2          yes       no partner
#> 318 Placebo     2     2           no       no partner
#> 231 Placebo     2     2           no       no partner
#> 190  Active     1     1          yes       no partner
#> 287 Placebo     2     2          yes       no partner
#> 633 Placebo     1     1           no       no partner
#> 228 Placebo     4     3          yes       no partner
#> 409  Active     1     2          yes       no partner
#> 603 Placebo     2     1           no       no   alone
#> 628 Placebo     1     2           no       no partner
#> 91   Active     1     0          yes       no partner
#> 537 Placebo     4     4           no       no partner
#> 75  Placebo     1     2          yes       no partner
#> 282 Placebo     1     0           no       no partner
#> 249  Active     1     1           no       no   alone
#> 72   Active     2     3          yes       no partner
#> 222  Active     2     2          yes       no partner
#> 258 Placebo     0     1           no       no partner
#> 134  Active     4     4           no       no partner
#> 117  Active     1     1           no      yes partner
#> 377  Active     2     1           no       no partner
#> 583 Placebo     3     2          yes       no partner
#> 552  Active     3     1          yes       no   alone
#> 124 Placebo     2     2          yes      yes partner
#> 189 Placebo     1     0           no      yes partner
#> 521 Placebo     1     2          yes      yes   alone
#> 429  Active     2     1           no       no partner
#> 203 Placebo     1     1          yes       no partner
#> 172  Active     1     2           no       no partner
#> 402 Placebo     2     2          yes       no partner
#> 574 Placebo     1     1          yes       no partner
#> 271  Active     4     3           no       no partner
#> 50  Placebo     3     2           no       no   alone
#> 264  Active     4     2           no       no   alone
#> 571  Active     2     0          yes       no partner
#> 239  Active     3     3          yes       no   alone
#> 262 Placebo     2     1          yes       no partner
#> 236 Placebo     1     1           no       no partner
#> 94  Placebo     1     1           no       no partner
#> 275 Placebo     0     0           no       no partner
#> 26  Placebo     2     4           no       no   alone
#> 476 Placebo     1     1           no       no   alone
#> 427  Active     2     3          yes       no   alone
#> 359 Placebo     1     2          yes       no   alone
#> 341  Active     4     3          yes       no   alone
#> 457  Active     1     1          yes      yes partner
#> 485 Placebo     0     0           no       no partner
#> 171 Placebo     2     2           no       no partner
#> 97  Placebo     2     1          yes       no partner
#> 635 Placebo     1     2           no       no   alone
#> 472 Placebo     1     0          yes       no partner
#> 408  Active     1     1          yes      yes partner
#> 158 Placebo     0     0           no       no partner
#> 63  Placebo     1     0           no      yes   alone
#> 557  Active     2     2           no       no partner
#> 73   Active     1     1          yes       no partner
#> 425 Placebo     2     0          yes       no partner
#> 423 Placebo     2     2          yes      yes partner
#> 272  Active     2     1          yes       no   alone
#> 122  Active     1     0           no       no partner
#> 370  Active     0     1           no       no partner
#> 274 Placebo     0     0           no       no partner
#> 407  Active     0     0           no       no partner
#> 482 Placebo     1     1           no       no partner
#> 586  Active     6     6          yes      yes partner
#> 20  Placebo     1     2           no       no   alone
#> 568  Active     1     0           no       no partner
#> 331 Placebo     1     1           no       no   alone
#> 133 Placebo     1     1           no       no partner
#> 563  Active     4     4          yes       no partner
#> 349 Placebo     1     2          yes      yes   alone
#> 381 Placebo     1     1          yes       no partner
#> 549 Placebo     1     1           no       no   alone
#> 34   Active     1     1           no       no   alone
#> 33  Placebo     0     0          yes       no   alone
#> 531 Placebo     2     2          yes       no   alone
#> 389  Active     1     0           no       no   alone
#> 64   Active     1     1          yes      yes   alone
#> 428  Active     2     1          yes       no partner
#> 403 Placebo     2     2          yes       no   alone
#> 343 Placebo     1     0           no       no partner
#> 294  Active     2     2           no       no   alone
#> 76  Placebo     3     1           no       no   alone
#> 166 Placebo     1     0          yes       no partner
#> 209 Placebo     0     1          yes       no partner
#> 626  Active     2     2          yes       no   alone
#> 481  Active     5     3           no       no partner
#> 376  Active     2     2          yes      yes partner
#> 67   Active     3     2           no       no partner
#> 130 Placebo     2     1           no       no partner
#> 250  Active     2     1          yes       no partner
#> 609  Active     2     2           no       no partner
#> 545 Placebo     3     2          yes       no partner
#> 226 Placebo     2     1           no       no partner
#> 276 Placebo     1     2           no       no partner
#> 305 Placebo     0     0          yes       no partner
#> 202 Placebo     1     0          yes       no   alone
#> 245 Placebo     1     1           no       no partner
#> 131  Active     3     1           no       no partner
#> 505  Active     2     1           no       no partner
#> 546 Placebo     2     2          yes       no   alone
#> 639 Placebo     1     1          yes      yes partner
#> 219  Active     2     1          yes       no partner
#> 244 Placebo     2     2          yes       no   alone
#> 348 Placebo     0     0           no       no partner
#> 280 Placebo     0     0          yes       no partner
#> 504 Placebo     2     2          yes       no partner
#> 51  Placebo     1     1           no       no   alone
#> 493  Active     6     6           no       no   alone
#> 167 Placebo     0     1          yes       no partner
#> 58  Placebo     1     0           no       no partner
#> 169  Active     0     0           no       no partner
#> 293  Active     1     0           no       no partner
#> 334 Placebo     6     6           no       no partner
#> 28   Active     2     2          yes       no partner
#> 1   Placebo     0     0          yes       no partner
#> 463  Active     2     1          yes       no   alone
#> 445 Placebo     1     2          yes       no   alone
#> 320 Placebo     1     2          yes      yes   alone
#> 500 Placebo     0     0           no       no   alone
#> 175 Placebo     1     2          yes       no partner
#> 201 Placebo     0     0          yes       no partner
#> 142  Active     2     0           no       no partner
#> 278  Active     0     1          yes       no   alone
#> 181 Placebo     0     0           no       no partner
#> 193 Placebo     2     1          yes       no   alone
#> 321  Active     2     0           no       no partner
#> 598  Active     0     1           no       no partner
#> 217 Placebo     0     0          yes       no partner
#> 13   Active     1     1          yes       no partner
#> 242 Placebo     2     0          yes       no partner
#> 513 Placebo     1     1           no       no partner
#> 518 Placebo     2     2          yes       no partner
#> 304 Placebo     2     2           no       no partner
#> 587 Placebo     1     2           no       no   alone
#> 497 Placebo     0     1          yes       no partner
#> 296 Placebo     0     0          yes       no partner
#> 526  Active     1     1           no       no partner
#> 2   Placebo     2     1           no       no partner
#> 627  Active     2     2           no      yes partner
#> 126 Placebo     2     1          yes       no partner
#> 420 Placebo     2     0          yes       no partner
#> 392  Active     2     2          yes       no partner
#> 522 Placebo     3     2          yes       no   alone
#> 312  Active     4     4           no      yes partner
#> 9   Placebo     1     1           no       no partner
#> 29  Placebo     2     2           no       no   alone
#> 7   Placebo     1     1          yes       no partner
#> 49  Placebo     2     1           no      yes partner
#> 439 Placebo     3     2           no       no   alone
#> 46   Active     0     0          yes       no   alone
#> 80   Active     1     1           no       no partner
#> 237 Placebo     0     0          yes       no partner
#> 306 Placebo     2     0           no       no   alone
#> 345 Placebo     0     0          yes       no partner
#> 153  Active     2     2           no       no partner
#> 98  Placebo     1     0          yes       no partner
#> 44  Placebo     2     1          yes       no partner
#> 458  Active     3     2           no       no partner
#> 585 Placebo     1     1          yes       no partner
#> 211 Placebo     3     2           no      yes partner
#> 610  Active     1     1           no       no   alone
#> 310 Placebo     0     0           no       no   alone
#> 541  Active     4     2          yes       no partner
#> 161 Placebo     1     1           no       no partner
#> 641 Placebo     1     1           no       no partner
#> 538 Placebo     1     1           no       no partner
#> 281 Placebo     1     0           no       no partner
#> 301  Active     3     2          yes       no partner
#> 356  Active     3     2           no       no   alone
#> 59   Active     3     3           no       no   alone
#> 302 Placebo     1     0          yes       no partner
#> 116  Active     1     0           no       no partner
#> 547 Placebo     2     2           no       no partner
#> 22  Placebo     2     1           no       no partner
#> 517 Placebo     4     3          yes       no partner
#> 344 Placebo     1     1          yes       no partner
#> 48  Placebo     2     0          yes       no   alone
#> 100 Placebo     1     0          yes       no   alone
#> 93  Placebo     6     6          yes       no   alone
#> 
#> $param.record$response
#> [1] "mrs_6"
#> 
#> $param.record$group
#> [1] "rtreat"
#> 
#> $param.record$alpha
#> [1] 0.05
#> 
#> $param.record$beta
#> [1] 0.2
#> 
#> $param.record$group.ratio
#> [1] 1
#> 
#> $param.record$sample.size
#> [1] FALSE
#> 
#> $param.record$print.tables
#> [1] FALSE
#> 
#> $param.record$dec
#> [1] 3
#> 
#> 
#> attr(,"class")
#> [1] "win_Prop" "list"