Calculates posterior quantiles and probabilities on benefit-risk scores.

pbrisk(x, q, reference = NULL, direction = c("upper", "lower"))

qbrisk(x, p, reference = NULL)

Arguments

x

output from a call to brisk::br() or brisk::mcda().

q

vector of quantiles.

reference

a string indicating which group is the reference group which is used to subtract scores from other groups.

direction

the direction of the posterior probability to compute.

p

a vector of probabilities from which to compute posterior quantiles.

Value

A tibble with the quantile and posterior probability of the benefit-risk score for each group.

Examples

set.seed(1132)
out <- br(
  benefit("CV", function(x) x, weight = 1),
  risk("DVT", function(x) - .5 * x, weight = 1),

  br_group(
    label = "PBO",
    CV = rnorm(1e4, .1),
    DVT = rnorm(1e4, .1)
  ),
  br_group(
    label = "TRT",
    CV = rnorm(1e4, 2),
    DVT = rnorm(1e4, 1)
  )
)

pbrisk(out, q = c(.03, .04))
#> # A tibble: 4 × 4
#>   label     q  prob direction
#>   <chr> <dbl> <dbl> <chr>    
#> 1 PBO    0.03 0.512 upper    
#> 2 PBO    0.04 0.509 upper    
#> 3 TRT    0.03 0.903 upper    
#> 4 TRT    0.04 0.902 upper    
pbrisk(out, q = c(.03, .04), direction = "lower")
#> # A tibble: 4 × 4
#>   label     q   prob direction
#>   <chr> <dbl>  <dbl> <chr>    
#> 1 PBO    0.03 0.488  lower    
#> 2 PBO    0.04 0.491  lower    
#> 3 TRT    0.03 0.0974 lower    
#> 4 TRT    0.04 0.0985 lower    
pbrisk(out, q = c(.03, .04), reference = "PBO")
#> # A tibble: 2 × 5
#>   label     q  prob direction reference
#>   <chr> <dbl> <dbl> <chr>     <chr>    
#> 1 TRT    0.03 0.815 upper     PBO      
#> 2 TRT    0.04 0.813 upper     PBO      

qbrisk(out, p = c(.025, .975))
#> # A tibble: 4 × 3
#>   label     p quantile
#>   <chr> <dbl>    <dbl>
#> 1 PBO   0.025   -2.09 
#> 2 PBO   0.975    2.22 
#> 3 TRT   0.025   -0.742
#> 4 TRT   0.975    3.68 
qbrisk(out, p = c(.025, .975), reference = "PBO")
#> # A tibble: 2 × 4
#>   label     p quantile reference
#>   <chr> <dbl>    <dbl> <chr>    
#> 1 TRT   0.025    -1.65 PBO      
#> 2 TRT   0.975     4.53 PBO