## specify a variable and generate it in the simulation
single_var = specify(a = ~ 1 + rnorm(5)) %>%
generate(1) # generate a single repetition of the simulation
single_var
two_var = specify(a = ~ 1 + rnorm(5),
b = ~ x + 2) %>%
generate(1)
two_var
## Generates a_01 through a_10
autonumber_var = specify(a = ~ MASS::mvrnorm(5, rep(0, 10), Sigma = diag(10))) %>%
generate(1)
autonumber_var
# alternatively, you could use a two-sided formula for names
multi_name = specify(cbind(a, b, c) ~ MASS::mvrnorm(5, rep(0, 3), Sigma = diag(3))) %>%
generate(1)
multi_name
# Simple example of setting a metaparameter
simple_meta = specify(a = ~ 1 + rnorm(n)) %>%
define(n = c(5, 10)) %>% # without this line you would get an error!
generate(1)
simple_meta # has two rows now, one for each value of n
simple_meta$sim[[1]] # n = 5
simple_meta$sim[[2]] # n = 10
Run the code above in your browser using DataLab