sim_gen {saeSim} | R Documentation |
Generation component
Description
One of the components which can be added to a sim_setup
.
Usage
sim_gen(simSetup, generator)
sim_gen_generic(simSetup, ...)
Arguments
simSetup |
a |
generator |
generator function used to generate random numbers. |
... |
arguments passed to |
Details
Potentially you can define a generator
yourself. Take care that it has one argument, named dat
, and returns a data.frame
. sim_gen_generic
is a shortcut to gen_generic
.
See Also
gen_norm
, gen_v_norm
, gen_v_sar
, sim_agg
, , sim_comp_pop
, sim_sample
, sim_gen_x
, sim_gen_e
, sim_gen_v
, sim_gen_vc
, sim_gen_ec
Examples
# Data setup for a mixed model
sim_base() %>% sim_gen_x() %>% sim_gen_v() %>% sim_gen_e()
# Adding contamination in the model error
sim_base() %>% sim_gen_x() %>% sim_gen_v() %>% sim_gen_e() %>% sim_gen_ec()
# Simple user defined generator:
gen_myVar <- function(dat) {
dat["myVar"] <- rnorm(nrow(dat))
dat
}
sim_base() %>% sim_gen_x() %>% sim_gen(gen_myVar)
# And a chi-sq(5) distributed 'random-effect':
sim_base() %>% sim_gen_generic(rchisq, df = 5, groupVars = "idD", name = "re")
[Package saeSim version 0.11.0 Index]