Generation component

Share:

Description

One of the components which can be added to a sim_setup.

Usage

1
2
3
sim_gen(simSetup, generator)

sim_gen_generic(simSetup, ...)

Arguments

simSetup

a sim_setup.

generator

generator function used to generate random numbers.

...

arguments passed to gen_generic.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# 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")