Skip to contents

Imputed a dataset with missing values using adversarial random forests (ARF). Calls adversarial_rf, forde and expct/forge.

Usage

impute(
  x,
  m = 1,
  expectation = ifelse(m == 1, TRUE, FALSE),
  num_trees = 100L,
  min_node_size = 10L,
  round = TRUE,
  finite_bounds = "local",
  epsilon = 1e-14,
  verbose = FALSE,
  ...
)

Arguments

x

Input data.

m

Number of multiple imputations. The default is single imputation (m=1).

expectation

Return expected value instead of multiple imputations. By default, for single imputation (m=1), the expected value is returned.

num_trees

Number of trees in ARF.

min_node_size

Minimum node size in ARF.

round

Round imputed values to their respective maximum precision in the original data set?

finite_bounds

Impose finite bounds on all continuous variables? See forde.

epsilon

Slack parameter on empirical bounds; see forde.

verbose

Print progress for adversarial_rf?

...

Extra parameters to be passed to adversarial_rf, forde and expct/forge.

Value

Imputed data. A single data table is returned for m=1 and a list of data table for m > 1.

Examples

# Generate some missings
iris_na <- iris
for (j in 1:ncol(iris)) {
  iris_na[sample(1:nrow(iris), 5), j] <- NA
}

# Single imputation
iris_imputed <- arf::impute(iris_na, m = 1)

# Multiple imputation
iris_imputed <- arf::impute(iris_na, m = 20)

if (FALSE) { # \dontrun{
# Parallelization with doParallel
doParallel::registerDoParallel(cores = 4)

# ... or with doFuture
doFuture::registerDoFuture()
future::plan("multisession", workers = 4)
} # }