Simulate Normalized Weights
sim_weights(n, ...)
number of weights to simulate.
vectors of length 2 indicating the lower and upper bound (respectively) of the un-normalized weights. At least one set of bounds must be equal to each other (e.g. c(1, 1)) and be the largest set of bounds in the set specified.
A tibble with weights for each argument supplied to ...
. Each
column represents the weights, and each row (total of n
rows) is a
set of random weights across groups. Column names are obtained from the
argument names of ...
, if supplied.
The weights are normalized relative to a set of bounds which are equal to each other (e.g. c(1, 1)), and also are the largest set of bounds in the set specified. See Example.
w <- sim_weights(1e4, a = c(1, 1), b = c(.4, .6), c = c(.2, .3))
# ratio of b to a is between c(.4, .6) / c(1, 1)
summary(w$b / w$a)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.4000 0.4429 0.4911 0.4940 0.5432 0.6000
# ratio of c to a is between c(.2, .3) / c(1, 1)
summary(w$c / w$a)
#> Min. 1st Qu. Median Mean 3rd Qu. Max.
#> 0.2000 0.2236 0.2476 0.2486 0.2728 0.3000
# Weights can be used to add uncertainty to the benefit/risk analysis
set.seed(1132)
ilogit <- function(x) 1 / (1 + exp(-x))
out <- mcda(
benefit("CV", function(x) ilogit(x), weight = w$a),
risk("DVT", function(x) ilogit(- .5 * x), weight = w$b),
risk("MI", function(x) ilogit(- .5 * x), weight = w$c),
br_group(
label = "PBO",
CV = rnorm(1e4, .1),
DVT = rnorm(1e4, .1),
MI = rnorm(1e4, .1)
),
br_group(
label = "TRT",
CV = rnorm(1e4, 2),
DVT = rnorm(1e4, 1),
MI = rnorm(1e4, 0.5)
)
)