CommencerCommencer gratuitement

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:

  1. Continuous variables,
  2. Binary variables,
  3. Categorical variables (unordered factors),
  4. 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!

Cet exercice fait partie du cours

Handling Missing Data with Imputations in R

Afficher le cours

Instructions

  • In the RDocumentation returned by ?mice, there's a table containing the keyword for each method.
  • Impute biopics data with mice() 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.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Impute biopics using the methods specified in the instruction
biopics_multiimp <- ___(biopics, m = 20, 
                         defaultMethod = ___)

# Print biopics_multiimp
print(biopics_multiimp)
Modifier et exécuter le code