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!
Deze oefening maakt deel uit van de cursus
Handling Missing Data with Imputations in R
Oefeninstructies
- In the RDocumentation returned by
?mice, there's a table containing the keyword for each method. - Impute
biopicsdata withmice()using the following default methods, in this order: classification and regression trees, linear discriminant analysis, predictive mean matching, proportional odds model. - Print
biopics_multiimpto see which method was used for which variable.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Impute biopics using the methods specified in the instruction
biopics_multiimp <- ___(biopics, m = 20,
defaultMethod = ___)
# Print biopics_multiimp
print(biopics_multiimp)