data(wine, package = "clusterMI")
require(parallel)
set.seed(123456)
ref <- wine$cult
nb.clust <- 3
wine.na <- wine
wine.na$cult <- NULL
wine.na <- prodna(wine.na)
# \donttest{
nnodes <- 2 # parallel::detectCores()
B <- 100 # Number of iterations
m <- 5 # Number of imputed data sets
# variables selection for incomplete variable "alco"
listvar <- "alco"
res.varsel <- varselbest(data.na = wine.na,
nb.clust = nb.clust,
listvar = listvar,
B = B,
nnodes = nnodes)
# frequency of selection
propselect <- res.varsel$proportion[listvar, ]
#predictormatrix with the default threshold value
predictmat <- res.varsel$predictormatrix
# r optimal and associated predictor matrix
res.chooser <- chooser(res.varsel = res.varsel)
thresh <- res.chooser[[listvar]]$r
is.selected <- propselect>=thresh
predictmat[listvar, names(is.selected)] <- as.numeric(is.selected)
# imputation
res.imp.select <- imputedata(data.na = wine.na, method = "FCS-homo",
nb.clust = nb.clust, predictmat = predictmat, m = m)
# }
Run the code above in your browser using DataLab