| contaminate {simFrame} | R Documentation |
Generic function for contaminating data.
contaminate(x, control, ...) ## S4 method for signature 'data.frame, ContControl': contaminate(x, control, i)
x |
the data to be contaminated. |
control |
a control object of a class inheriting from the virtual class
"VirtualContControl" or a character string specifying such a control
class (the default being "DCARContControl"). |
i |
an integer giving the element of the slot epsilon of
control to be used as contamination level. |
... |
if control is a character string or missing, the slots of
the control object may be supplied as additional arguments. |
In order to extend the framework by a user-defined control class
"MyContControl" (which must extend "VirtualContControl"), a
method contaminate(x, control, i) with signature
'data.frame, MyContControl' needs to be implemented.
A data.frame containing the contaminated data. In addition, the
column ".contaminated", which consists of logicals indicating the
contaminated observations, is added to the data.frame.
Andreas Alfons, alfons@statistik.tuwien.ac.at
DCARContControl, DARContControl,
ContControl, VirtualContControl
## distributed completely at random
data(eusilc)
sam <- draw(eusilc[, c("id", "eqIncome")], size = 20)
contaminate(sam, target = "eqIncome", epsilon = 0.05,
dots = list(mean = 5e+05, sd = 10000))
## distributed at random
require(MASS)
mu <- rep(0, 2)
Sigma <- matrix(c(1, 0.5, 0.5, 1), 2, 2)
foo <- generate(size = 10, distribution = mvrnorm,
dots = list(mu = mu, Sigma = Sigma))
contaminate(foo, "DARContControl", target = "V2",
epsilon = 0.2, fun = function(x) x * 100)