## Not run:
# #############################################################################
# # EXAMPLE 1: Imputation of grouped data
# #############################################################################
#
# data(data.ma06)
# data <- data.ma06
#
# # define the variable "FC_imp" which should contain the variables to be imputed
# data$FC_imp <- NA
# V <- ncol(data)
# # variables not to be used for imputation
# vars_elim <- c("id" , "FC","FC_low","FC_upp")
#
# # define imputation methods
# impM <- rep("norm" , V)
# names(impM) <- colnames(data)
# impM[ vars_elim ] <- ""
# impM[ "FC_imp" ] <- "grouped"
#
# # define predictor matrix
# predM <- 1 - diag( 0 , V)
# rownames(predM) <- colnames(predM) <- colnames(data)
# predM[vars_elim, ] <- 0
# predM[,vars_elim] <- 0
#
# # define lower and upper boundaries of the grouping intervals
# low <- list("FC_imp" = data$FC_low )
# upp <- list("FC_imp" = data$FC_upp )
#
# # perform imputation
# imp <- mice::mice( data , imputationMethod = impM , predictorMatrix = predM ,
# m=1 , maxit=3 , allow.na=TRUE , low=low , upp=upp)
# head( mice::complete(imp))
# ## End(Not run)
Run the code above in your browser using DataLab