# NOT RUN {
#################
## Simple Example
data(iris)
ampIris <- amputeData(iris)
miceObj <- miceRanger(
ampIris
, m = 1
, maxiter = 1
, verbose=FALSE
, num.threads = 1
, num.trees=5
)
# }
# NOT RUN {
##################
## Run in parallel
data(iris)
ampIris <- amputeData(iris)
library(doParallel)
cl <- makeCluster(2)
registerDoParallel(cl)
# Perform mice
miceObjPar <- miceRanger(
ampIris
, m = 2
, maxiter = 2
, parallel = TRUE
, verbose = FALSE
)
stopCluster(cl)
registerDoSEQ()
############################
## Complex Imputation Schema
data(iris)
ampIris <- amputeData(iris)
# Define variables to impute, as well as their predictors
v <- list(
Sepal.Width = c("Sepal.Length","Petal.Width","Species")
, Sepal.Length = c("Sepal.Width","Petal.Width")
, Species = c("Sepal.Width")
)
# Specify mean matching for certain variables.
vs <- c(
Sepal.Width = "meanMatch"
, Sepal.Length = "value"
, Species = "meanMatch"
)
# Different mean matching candidates per variable.
mmc <- c(
Sepal.Width = 4
, Species = 10
)
miceObjCustom <- miceRanger(
ampIris
, m = 1
, maxiter = 1
, vars = v
, valueSelector = vs
, meanMatchCandidates = mmc
, verbose=FALSE
)
# }
Run the code above in your browser using DataCamp Workspace