5  Multiple imputation with mice

In Chapter 4 we multiply imputed just one variable (blood pressure) by hand. In real data, it is usual for several variables to have missing values. R’s mice package performs multiple imputation for such data, covering imputation, analysis, and pooling.

5.1 Data used

From adults (NHANES ages 20–79, including actual missing values), we select 3000 people so that things run quickly in the browser.

The analysis we want is a regression of systolic blood pressure on age, BMI, sex, income (poverty ratio), and total cholesterol. Complete-case analysis can use only 2358 (79%) of the 3000 people.

5.2 The three steps in mice

Argument Meaning
m = 10 Number of imputed datasets
maxit = 10 Number of iterations (how many passes through the “chained equations” described below)
seed = 1 Random seed. Always specify it so the results are reproducible

with() analyses each of the m datasets, and pool() combines them with the Rubin’s rules from Chapter 4.

5.3 Comparing with complete-case analysis

In this example, the coefficients are very similar for both. For many coefficients, multiple imputation gives slightly smaller standard errors (because it can use the observed information of the 642 people discarded by complete-case analysis). Only for BMI is it slightly larger, because the uncertainty of imputing BMI itself is added. In real data, the fact that the two methods do not differ much is itself reassurance that “bias due to missingness is probably not large”.

5.4 What happens inside: chained equations

mice uses a method called MICE (Multivariate Imputation by Chained Equations).

  1. First, fill in missing values provisionally with random observed values
  2. Re-impute BMI with a model predicting it from all other variables (with their current filled-in values)
  3. Next, re-impute blood pressure from all other variables (using the BMI values imputed in step 2)
  4. Re-impute each variable with missing values in turn — cholesterol, income, …
  5. Repeat steps 2–4 maxit times. The final state is one “complete dataset”
  6. Do this m times (with different random numbers)

You can check the method used for each variable and the variables used to predict it.

5.5 Predictive mean matching (pmm)

The default method for continuous variables is pmm (predictive mean matching).

  1. Use regression to compute predicted values for the people with missing values (with the coefficients redrawn as in Chapter 4)
  2. From among those observed, select a few people whose predicted values are close (5 by default)
  3. Pick one of them at random and impute that person’s actual value

Because only actually observed values are imputed, impossible values (negative income, out-of-range values) do not appear.

The poverty ratio takes values from 0 to 5 (capped at 5), but imputing with norm (normal linear regression) produces negative values and values above 5. With pmm they stay within the range of observed values.

TipDefault method by variable type
Variable Default method
Numeric pmm (predictive mean matching)
Factor with 2 categories logreg (logistic regression)
Unordered factor with 3+ categories polyreg (multinomial logistic regression)
Ordered factor polr (proportional odds model)

It is important to make categorical variables factors. If left numeric, they are imputed with pmm.

5.6 Extracting the imputed data

WarningThings you must not do
  • Average the imputed datasets into one and then analyse: this is the same as single imputation, and the standard errors are too small
  • Analyse only the first dataset complete(imp, 1): this is also single imputation
  • Analyse each of the m datasets and pool with pool()

5.7 Checking with data whose true values are known

Using the same data as in Chapters 3 and 4, with 40% of blood pressure in full made missing, we check the results of mice (pmm).

The complete-case mean (125.6) was more than 3 mmHg too high, but multiple imputation with mice gives 121.7 (95% confidence interval 120.7–122.8), which contains the pre-missingness mean of 122.3.

5.8 Try it

NotePractice
  1. Using the results in imp, analyse and pool lm(BPSysAve ~ Age + Gender) (no need to redo the imputation)
  2. If m in mice() is changed from 10 to 20, how much do the pooled results change?
  1. Imputed data can be reused for various analyses. However, analysing relationships not included in the imputation model (such as interactions) leads to bias (Chapter 6)
  2. Both estimates and standard errors change only in about the 2nd–3rd decimal place. In this example missingness is small, so m = 10 is sufficient (Chapter 7)
ImportantChapter summary
  • mice has three steps: mice() → with() → pool(). Always specify seed
  • Missing values in several variables are imputed one variable at a time in turn with chained equations
  • The default for continuous variables is pmm. Because only observed values are imputed, impossible values do not appear
  • Make categorical variables factors
  • Do not average the imputed datasets or use only one. Always pool with pool()