Choosing default models
MICE creates a separate imputation model for each variable in the data. What kind of model it is depends on the type of the variable in question. A popular way to specify the kinds of models we want to use is set a default model for each of the four variable types.
You can do this by passing the defaultMethod
argument to mice()
, which should be a vector of length 4 containing the default imputation methods for:
- Continuous variables,
- Binary variables,
- Categorical variables (unordered factors),
- Factor variables (ordered factors).
In this exercise, you will take advantage of mice
's documentation to view the list of available methods and to pick the desired ones for the algorithm to use. Let's do some model selection!
This exercise is part of the course
Handling Missing Data with Imputations in R
Exercise instructions
- In the RDocumentation returned by
?mice
, there's a table containing the keyword for each method. - Impute
biopics
data withmice()
using the following default methods, in this order: classification and regression trees, linear discriminant analysis, predictive mean matching, proportional odds model. - Print
biopics_multiimp
to see which method was used for which variable.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Impute biopics using the methods specified in the instruction
biopics_multiimp <- ___(biopics, m = 20,
defaultMethod = ___)
# Print biopics_multiimp
print(biopics_multiimp)