Learn R Programming

misty (version 0.7.1)

na.indicator: Missing Data Indicator Matrix

Description

This function creates a missing data indicator matrix \(R\) that denotes whether values are observed or missing, i.e., \(r = 0\) if a value is observed, and \(r = 1\) if a value is missing.

Usage

na.indicator(data, ..., na = 1, append = TRUE, name = ".i", as.na = NULL,
             check = TRUE)

Value

Returns a matrix or data frame with \(r = 1\) if a value is observed, and \(r = 0\)

if a value is missing.

Arguments

data

a data frame with incomplete data, where missing values are coded as NA.

...

an expression indicating the variable names in data, e.g., na.indicator(dat, x1, x2, x3). Note that the operators ., +, -, ~, :, ::, and ! can also be used to select variables, see 'Details' in the df.subset function.

na

an integer value specifying the value representing missing values, i.e., either na = 0 for 0 = missing and 1 = observed, or na = 1 (default) for 0 (observed) and 1 = missing.

append

logical: if TRUE (default), missing data indicator matrix is appended to the data frame specified in the argument data.

name

a character string indicating the name suffix of indicator variables By default, the indicator variables are named with the ending ".i" resulting in e.g. "x1.i" and "x2.i". Note that when selecting one single variable, the indicator variable is named x.i by default or named after the argument name.

as.na

a numeric vector indicating user-defined missing values, i.e. these values are converted to NA before conducting the analysis.

check

logical: if TRUE (default), argument specification is checked.

Author

Takuya Yanagida takuya.yanagida@univie.ac.at

References

Enders, C. K. (2010). Applied missing data analysis. Guilford Press.

Graham, J. W. (2009). Missing data analysis: Making it work in the real world. Annual Review of Psychology, 60, 549-576. https://doi.org/10.1146/annurev.psych.58.110405.085530

van Buuren, S. (2018). Flexible imputation of missing data (2nd ed.). Chapman & Hall.

See Also

as.na, na.as, na.auxiliary, na.coverage, na.descript, na.pattern, na.prop, na.test

Examples

Run this code
# Example 1: Create missing data indicator matrix
na.indicator(airquality)

# Example 2: Do not append missing data indicator matrix to the data frame
na.indicator(airquality, append = FALSE)

Run the code above in your browser using DataLab