sim_weights | R Documentation |
Simulate Normalized Weights
sim_weights(n, ...)
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. |
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.
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.
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) # ratio of c to a is between c(.2, .3) / c(1, 1) summary(w$c / w$a) # 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) ) )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.