Learn R Programming

saeSim (version 0.11.0)

sim_gen_cont: Generation Component for contamination

Description

One of the components which can be added to a sim_setup. It is applied after functions added with sim_gen.

Usage

sim_gen_cont(simSetup, generator, nCont, type, areaVar = NULL, fixed = TRUE)

Arguments

simSetup

a sim_setup.

generator

generator function used to generate random numbers.

nCont

gives the number of contaminated observations. Values between 0 and 1 will be treated as probability. If type is 'unit' and length is larger than 1, the expected length is the number of areas. If type is 'area' and length is larger than 1 the values are interpreted as area positions; i.e. c(1, 3) is interpreted as the first and 3rd area in the data is contaminated.

type

"unit" or "area" - unit- or area-level contamination.

areaVar

character with variable name(s) identifying areas.

fixed

TRUE fixes the observations which will be contaminated. FALSE will result in a random selection of observations or areas.

See Also

sim_gen

Examples

Run this code
# NOT RUN {
sim_base_lm() %>% 
  sim_gen_cont(gen_norm(name = "e"), nCont = 0.05, type = "unit", areaVar = "idD") %>%
  as.data.frame
# }

Run the code above in your browser using DataLab