NAControl-class: Class "NAControl"

Description Objects from the Class Slots Extends Accessor and mutator methods Methods UML class diagram Note Author(s) References See Also Examples

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, or NULL 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 to NA 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 to NA 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 slot grouping.

setGrouping

signature(x = "NAControl"): set slot grouping.

getAux

signature(x = "NAControl"): get slot aux.

setAux

signature(x = "NAControl"): set slot aux.

getIntoContamination

signature(x = "NAControl"): get slot intoContamination.

setIntoContamination

signature(x = "NAControl"): set slot intoContamination.

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

"VirtualNAControl", setNA

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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)

aalfons/simFrame documentation built on Nov. 27, 2021, 7:51 a.m.