Skip to contents

Multiple correlated distributions

Usage

rmulti(
  n = 100,
  dist = c(A = "norm", B = "norm"),
  params = list(),
  r = 0,
  empirical = FALSE,
  as.matrix = FALSE
)

Arguments

n

the number of samples required

dist

A named vector of the distributions of each variable

params

A list of lists of the arguments to pass to each distribution function

r

the correlations among the variables (can be a single number, vars\*vars matrix, vars\*vars vector, or a vars\*(vars-1)/2 vector)

empirical

logical. If true, params specify the sample parameters, not the population parameters

as.matrix

logical. If true, returns a matrix

Value

a tbl of vars vectors

Examples

dist <- c(A = "norm", 
          B = "pois", 
          C = "binom")
params <- list(A = list(mean = 100, sd = 10),
               B = list(lambda = 5),
               C = list(size = 10, prob = 0.5))
x <- rmulti(100, dist, params, c(0.2, 0.4, 0.6), empirical = TRUE)
get_params(x)
#>     n var    A    B    C   mean    sd
#> 1 100   A 1.00 0.20 0.42 100.00 10.00
#> 2 100   B 0.20 1.00 0.66   4.99  2.32
#> 3 100   C 0.42 0.66 1.00   4.97  1.58