delete_MNAR_one_group: Create MNAR values by deleting values in one of two groups

View source: R/delete_one_group.R

delete_MNAR_one_groupR Documentation

Create MNAR values by deleting values in one of two groups

Description

Create missing not at random (MNAR) values by deleting values in one of two groups in a data frame or a matrix

Usage

delete_MNAR_one_group(
  ds,
  p,
  cols_mis,
  cutoff_fun = median,
  prop = 0.5,
  use_lpSolve = TRUE,
  ordered_as_unordered = FALSE,
  n_mis_stochastic = FALSE,
  ...,
  miss_cols,
  stochastic
)

Arguments

ds

A data frame or matrix in which missing values will be created.

p

A numeric vector with length one or equal to length cols_mis; the probability that a value is missing.

cols_mis

A vector of column names or indices of columns in which missing values will be created.

cutoff_fun

Function that calculates the cutoff values in the cols_ctrl.

prop

Numeric of length one; (minimum) proportion of rows in group 1 (only used for unordered factors).

use_lpSolve

Logical; should lpSolve be used for the determination of groups, if cols_ctrl[i] is an unordered factor.

ordered_as_unordered

Logical; should ordered factors be treated as unordered factors.

n_mis_stochastic

Logical, should the number of missing values be stochastic? If n_mis_stochastic = TRUE, the number of missing values for a column with missing values cols_mis[i] is a random variable with expected value nrow(ds) * p[i]. If n_mis_stochastic = FALSE, the number of missing values will be deterministic. Normally, the number of missing values for a column with missing values cols_mis[i] is round(nrow(ds) * p[i]). Possible deviations from this value, if any exists, are documented in Details.

...

Further arguments passed to cutoff_fun.

miss_cols

Deprecated, use cols_mis instead.

stochastic

Deprecated, use n_mis_stochastic instead.

Details

The functions delete_MNAR_one_group and delete_MAR_one_group are sisters. The only difference between these two functions is the column that controls the generation of missing values. In delete_MAR_one_group a separate column cols_ctrl[i] controls the generation of missing values in cols_mis[i]. In contrast, in delete_MNAR_one_group the generation of missing values in cols_mis[i] is controlled by cols_mis[i] itself. All other aspects are identical for both functions. Therefore, further details can be found in delete_MAR_one_group.

Value

An object of the same class as ds with missing values.

References

Santos, M. S., Pereira, R. C., Costa, A. F., Soares, J. P., Santos, J., & Abreu, P. H. (2019). Generating Synthetic Missing Data: A Review by Missing Mechanism. IEEE Access, 7, 11651-11667

See Also

delete_MAR_one_group

Other functions to create MNAR: delete_MNAR_1_to_x(), delete_MNAR_censoring(), delete_MNAR_rank()

Examples

ds <- data.frame(X = 1:20, Y = 101:120)
delete_MNAR_one_group(ds, 0.2, "X")

missMethods documentation built on Sept. 16, 2022, 5:08 p.m.