# Simple example of setting a metaparameter
simple_meta = specify(a = ~ 1 + rnorm(n)) %>%
define(n = c(5, 10)) %>%
generate(1)
simple_meta # $sim has a 5-row tibble and a 10-row tibble
multi_meta = specify(a = ~ mu + rnorm(n)) %>%
define(n = c(5, 10),
mu = seq(-1, 1, length.out = 3)) %>%
generate(1)
multi_meta # generates simulations for all combos of n and mu
# define can handle lists which can contain multiple matrices, etc.
meta_list_out = specify(a = ~ MASS::mvrnorm(n, rep(0, 2), Sigma = S)) %>%
define(n = c(10, 20, 30),
S = list(independent = diag(2), correlated = diag(2) + 2)) %>%
generate(1)
meta_list_out # generates S_index column
# define can also take arguments as a list using the .list argument
meta_list_out_2 = specify(a = ~ MASS::mvrnorm(n, rep(0, 2), Sigma = S)) %>%
define(.list = list(n = c(10, 20, 30),
S = list(independent = diag(2), correlated = diag(2) + 2))) %>%
generate(1)
Run the code above in your browser using DataLab