sim_gen_cont: Generation Component for contamination

Description Usage Arguments See Also Examples

View source: R/03-sim_gen_cont.R

Description

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

Usage

1
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

1
2
3
sim_base_lm() %>% 
  sim_gen_cont(gen_norm(name = "e"), nCont = 0.05, type = "unit", areaVar = "idD") %>%
  as.data.frame

saeSim documentation built on Feb. 7, 2022, 5:07 p.m.