NAControl-class {simFrame} | R Documentation |
Class "NAControl"
Description
Class for controlling the insertion of missing values in a simulation experiment.
Objects from the Class
Objects can be created by calls of the form new("NAControl", ...)
or
NAControl(...)
.
Slots
target
:Object of class
"OptCharacter"
; a character vector specifying the variables (columns) in which missing values should be inserted, orNULL
to insert missing values in all variables (except the additional ones generated internally).NArate
:Object of class
"NumericMatrix"
giving the missing value rates, which may be selected individually for the target variables. In case of a vector, the same missing value rates are used for all target variables. In case of a matrix, on the other hand, the missing value rates to be used for each target variable are given by the respective column.grouping
:Object of class
"character"
specifying a grouping variable (column) to be used for setting whole groups toNA
rather than individual values.aux
:Object of class
"character"
specifying auxiliary variables (columns) whose values are used as probability weights for selecting the values to be set toNA
in the respective target variables. If only one variable (column) is specified, it is used for all target variables.intoContamination
:Object of class
"logical"
indicating whether missing values should also be inserted into contaminated observations. The default is to insert missing values only into non-contaminated observations.
Extends
Class "VirtualNAControl"
, directly.
Class "OptNAControl"
, by class "VirtualNAControl",
distance 2.
Accessor and mutator methods
In addition to the accessor and mutator methods for the slots inherited from
"VirtualNAControl"
, the following are available:
getGrouping
signature(x = "NAControl")
: get slotgrouping
.setGrouping
signature(x = "NAControl")
: set slotgrouping
.getAux
signature(x = "NAControl")
: get slotaux
.setAux
signature(x = "NAControl")
: set slotaux
.getIntoContamination
signature(x = "NAControl")
: get slotintoContamination
.setIntoContamination
signature(x = "NAControl")
: set slotintoContamination
.
Methods
In addition to the methods inherited from
"VirtualNAControl"
, the following are available:
setNA
signature(x = "data.frame", control = "NAControl")
: set missing values.show
signature(object = "NAControl")
: print the object on the R console.
UML class diagram
A slightly simplified UML class diagram of the framework can be found in
Figure 1 of the package vignette An Object-Oriented Framework for
Statistical Simulation: The R Package simFrame
. Use
vignette("simFrame-intro")
to view this vignette.
Note
Since version 0.3, this control class now allows to specify an auxiliary variable with probability weights for each target variable.
The slot grouping
was named group
prior to version 0.2.
Renaming the slot was necessary since accessor and mutator functions were
introduced in this version and a function named getGroup
already
exists.
Author(s)
Andreas Alfons
References
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.
See Also
Examples
data(eusilcP)
eusilcP$age[eusilcP$age < 0] <- 0 # this actually occurs
sam <- draw(eusilcP[, c("id", "age", "eqIncome")], size = 20)
## 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)