Imputing missing data in Stata

Learn how Stata handles missing data through multiple imputation: setting up mi data, checking patterns with misstable, and choosing an imputation model.

3 min read6 viewsImputing missing data in Stata
— · 0 votes
Contents
  1. Setting up mi data first
  2. Which command fills the gaps
  3. Reading the imputation model
  4. Questions about imputation in Stata
  5. How do I impute missing data in Stata?
  6. What is the difference between mi impute and the ice command?
  7. How many imputed datasets should I create?
  8. Can mi impute handle categorical variables?

Imputing missing data in Stata means creating several plausible values for each gap and analyzing the results together, rather than deleting incomplete records. Stata builds this workflow into its mi commands, which separate the original data, the imputed copies, and the combined estimates. The page explains how to set up the data, which command fills the gaps, and how to read the output with confidence.

Setting up mi data first

Multiple imputation in Stata begins with mi set, which declares the dataset as imputed data and adds a marker for each observation. You choose a style such as wide or mlong, and that choice fixes how the imputed copies are stored. Run misstable summarize before imputing to see which variables have gaps and how the patterns look. Skipping this step leaves you imputing variables whose missingness you have not examined.

Which command fills the gaps

The mi impute command creates the filled-in copies, and it offers a separate subcommand for each variable type. Continuous variables take a regression model, binary variables take logistic regression, and categorical variables take multinomial or ordered models. The older ice command does similar work through a user-written package, and it remains in use for some survey designs. Match the imputation model to the variable, because a model built for the wrong type distorts the filled values.

Reading the imputation model

An imputation model in Stata is a set of regressions that predict each incomplete variable from the observed ones. Include the outcome and any design variables in that model, since leaving them out biases the later estimates. A model that is too small loses relationships, and a model with too many predictors can fail to converge. Inspect the output for convergence warnings before you accept the imputed data.

Questions about imputation in Stata

How do I impute missing data in Stata?

You impute missing data in Stata by declaring the data with mi set, checking patterns with misstable summarize, then running mi impute for each incomplete variable. After that, mi estimate combines the results across the imputed copies. Each step keeps the original values untouched while the filled copies sit alongside them. Running the steps in that order keeps the analysis reproducible.

What is the difference between mi impute and the ice command?

The mi impute command is part of official Stata and works inside the mi data structure, while ice is a user-written command that creates imputations outside it. Both produce multiple filled datasets from a set of prediction models. The mi route integrates with mi estimate and mi set, and ice suits workflows that already depend on its options. Choose based on how the rest of your analysis is built.

How many imputed datasets should I create?

The number of imputed datasets depends on how much information is missing and how precise your estimates must be. More copies reduce simulation noise in the combined result, at the cost of computing time. A small fraction of missing values needs fewer copies than a large fraction. Report the number you used so readers can judge the result.

Can mi impute handle categorical variables?

Yes, mi impute handles categorical variables through subcommands such as mi impute mlogit for unordered categories and mi impute ologit for ordered ones. Binary variables take mi impute logit. Each subcommand fits a model suited to that variable type. Using the right subcommand keeps the filled values within the real category set.

Read next

Latest articles