Description Usage Arguments Details Value Methods Note Author(s) References See Also Examples
Generic function for inserting missing values into data.
1 2 3 4 |
x |
the data in which missing values should be inserted. |
control |
a control object inheriting from the virtual class
|
i |
an integer giving the element or row of the slot |
... |
if |
In order to extend the framework by a user-defined control class
"MyNAControl"
(which must extend
"VirtualNAControl"
), a method
setNA(x, control, i)
with signature 'data.frame, MyNAControl'
needs to be implemented.
A data.frame
containing the data with missing values.
x = "data.frame", control = "character"
set missing values
using a control class specified by the character string control
.
The slots of the control object may be supplied as additional arguments.
x = "data.frame", control = "missing"
set missing values using
a control object of class "NAControl"
. Its slots may be supplied as
additional arguments.
x = "data.frame", control = "NAControl"
set missing values as
defined by the control object control
.
Since version 0.3, setNA
no longer checks if auxiliary variable(s)
with probability weights are numeric and contain only finite positive values
(sample
still throws an error in these cases). This has been
removed to improve computational performance in simulation studies.
Andreas Alfons
Alfons, A., Templ, M. and Filzmoser, P. (2010) An Object-Oriented Framework for Statistical Simulation: The R Package simFrame. Journal of Statistical Software, 37(3), 1–36. doi: 10.18637/jss.v037.i03.
"NAControl"
, "VirtualNAControl"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | data(eusilcP)
eusilcP$age[eusilcP$age < 0] <- 0 # this actually occurs
sam <- draw(eusilcP[, c("id", "age", "eqIncome")], size = 20)
## using control objects
# missing completely at random
mcarc <- NAControl(target = "eqIncome", NArate = 0.2)
setNA(sam, mcarc)
# missing at random
marc <- NAControl(target = "eqIncome", NArate = 0.2, aux = "age")
setNA(sam, marc)
# missing not at random
mnarc <- NAControl(target = "eqIncome",
NArate = 0.2, aux = "eqIncome")
setNA(sam, mnarc)
## supply slots of control object as arguments
# missing completely at random
setNA(sam, target = "eqIncome", NArate = 0.2)
# missing at random
setNA(sam, target = "eqIncome", NArate = 0.2, aux = "age")
# missing not at random
setNA(sam, target = "eqIncome", NArate = 0.2, aux = "eqIncome")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.