Learn R Programming

saeSim (version 0.11.0)

sim_gen: 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 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

Run this code
# NOT RUN {
# 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")
# }

Run the code above in your browser using DataLab