Learn R Programming

simFrame (version 0.5.4)

NAControl-class: Class "NAControl"

Description

Class for controlling the insertion of missing values in a simulation experiment.

Arguments

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.

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. 10.18637/jss.v037.i03.

See Also

"'>VirtualNAControl", setNA

Examples

Run this code
# NOT RUN {
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)
# }

Run the code above in your browser using DataLab