| impute_new {mixgb} | R Documentation | 
Impute new data with a saved mixgb imputer object
Description
Impute new data with a saved mixgb imputer object
Usage
impute_new(
  object,
  newdata,
  initial.newdata = FALSE,
  pmm.k = NULL,
  m = NULL,
  verbose = FALSE
)
Arguments
| object | A saved imputer object created by  | 
| newdata | A data.frame or data.table. New data with missing values. | 
| initial.newdata | Whether to use the information from the new data to initially impute the missing values of the new data. By default, this is set to  | 
| pmm.k | The number of donors for predictive mean matching. If  | 
| m | The number of imputed datasets. If  | 
| verbose | Verbose setting for mixgb. If  | 
Value
A list of m imputed datasets for new data.
Examples
set.seed(2022)
n <- nrow(nhanes3)
idx <- sample(1:n, size = round(0.7 * n), replace = FALSE)
train.data <- nhanes3[idx, ]
test.data <- nhanes3[-idx, ]
params <- list(max_depth = 3, subsample = 0.7, nthread = 2)
mixgb.obj <- mixgb(data = train.data, m = 2, xgb.params = params, nrounds = 10, save.models = TRUE)
# obtain m imputed datasets for train.data
train.imputed <- mixgb.obj$imputed.data
train.imputed
# use the saved imputer to impute new data
test.imputed <- impute_new(object = mixgb.obj, newdata = test.data)
test.imputed