Hamiltonian Monte Carlo with Missing Data

Statistics
Introduced by
Radford M. Neal (HMC, 1996/2011); missing-data treatment via Bayesian data augmentation (Tanner & Wong, 1987)
Year
1996–2011
Type
Bayesian computational sampler
Family
Bayesian / computational

What does it do?

Hamiltonian Monte Carlo with missing data extends the gradient-based HMC sampler to incomplete observations by treating the missing values as additional unknown quantities.

Model parameters and missing values are sampled jointly, so imputation uncertainty is carried through the posterior rather than fixed in advance. Gradient information lets proposals move through this joint space more efficiently than random-walk updates, although the benefit depends on the log-posterior being differentiable.

The intuition behind the method

HMC simulates a particle sliding on an energy surface defined by the negative log-posterior. When some data are missing, those unobserved values are simply added to the particle's position vector — they become extra dimensions of the same energy landscape. At every gradient step the sampler simultaneously nudges the model parameters and the plausible fill-in values for the gaps, so that by the time the chain converges you have a coherent posterior that naturally marginalises over all possible completions of the data, weighted by their probability under the model.

History

Hamiltonian Monte Carlo is attributed to Duane et al. (1987) in lattice field theory and was introduced to statistics by Neal (1996, 2011). The Bayesian treatment of missing data by data augmentation was introduced by Tanner and Wong (1987) and is covered in general terms in Gelman et al.'s Bayesian Data Analysis. The combination of treating missing values as sampled latent variables within HMC became practical with automatic differentiation in probabilistic programming systems such as Stan and PyMC.

When to use it

Use HMC with missing data when the analysis involves continuous or mixed-type outcomes with a meaningful amount of missingness, under a MAR or MCAR assumption, and when the full Bayesian model has a smooth, differentiable log-posterior. Hierarchical regression, latent-variable, and factor models are typical cases where gradient information is available. The method is most useful when missingness is related to model covariates in ways that complete-case analysis or single imputation would distort. Prefer a Gibbs sampler or Metropolis-Hastings when the likelihood is not differentiable, for example when custom link functions prevent automatic differentiation, or when missingness is MNAR and the mechanism cannot be modelled. If missingness is so sparse that complete-case analysis introduces negligible bias, the extra modelling effort is not justified.

Limitations and considerations

  • Requires a differentiable log-posterior; likelihoods with discrete latent structure break the gradient computation unless those components are marginalised out.
  • Each iteration is more expensive than in simpler samplers, and cost grows with the number of missing values added to the state vector.
  • The method assumes MAR (or MCAR). If missingness depends on the unobserved values, a separate missingness model must be specified; the sampler does not handle MNAR automatically.
  • Step-size and trajectory-length tuning is required unless an adaptive sampler such as NUTS is used.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Jointly samples model parameters and missing values, so imputation uncertainty propagates into every downstream estimate without a separate imputation and pooling step.
  • Gradient-driven proposals can explore the high-dimensional joint posterior more efficiently than random-walk alternatives when many values are missing.
  • Missing values are handled inside the same Bayesian model as the parameters, so the prior and the observed-data likelihood constrain every imputed draw.
  • Works with probabilistic programming languages such as Stan and PyMC that provide automatic differentiation and the NUTS sampler.
  • Handles hierarchical and latent-variable models in which an imputation model would otherwise have to be specified separately for each incomplete variable, as is needed in multiple imputation by chained equations (MICE).

Applications

  • Hierarchical regression with item-level missing covariates, where the missing values enter the same model as the group-level parameters.
  • Latent-variable and factor models in which some manifest indicators are partly observed.
  • Longitudinal random-effects models with intermittent missingness in the outcome.

How it works

How it works

1

Write out the joint model over observed data, missing data, and parameters. Missing values enter exactly like parameters: they are part of the Bayesian model, not an obstacle. Ignoring the missingness mechanism is justified under MAR or MCAR only if the mechanism is separable from the complete-data model parameters (the distinctness condition) and the model for the data is correctly specified. If missingness is MNAR, an explicit model for the missingness indicator is required.

Formula
p(y_{obs}, y_{mis}, \theta) = p(y_{obs}, y_{mis} \mid \theta)\, p(\theta)
2

Form the augmented state vector z that concatenates the model parameters theta and the missing-value block y_mis. The potential energy U(z) is the negative log-joint evaluated at z; its gradient with respect to z drives the HMC trajectory through both parameter space and imputation space simultaneously.

Formula
z = (\theta,\, y_{mis})
3

Introduce an auxiliary momentum variable with the same dimension as z and a mass matrix M, and define the Hamiltonian H(z, p) = U(z) + K(p), where K(p) = p'M^{-1}p/2. Run the leapfrog integrator for a fixed number of steps with step size epsilon. Each step first updates the momentum by a half-step using the gradient of U at the current position, then advances the position by a full step using the updated momentum, and finally completes the momentum update with a second half-step using the gradient at the new position. Informally, the gradient reflects the correlation structure of the joint posterior, so proposals for the missing values tend to move in directions that are compatible with the observed-data likelihood and the prior.

Formula
p \leftarrow p - \frac{\varepsilon}{2}\nabla_z U(z),\quad z \leftarrow z + \varepsilon\, M^{-1}p,\quad p \leftarrow p - \frac{\varepsilon}{2}\nabla_z U(z)
4

Apply the Metropolis accept-reject correction to account for discretisation error in the leapfrog integration. The acceptance probability is alpha = min(1, exp{-(H(z*, p*) - H(z, p))}), comparing the Hamiltonian at the proposed state with that at the current state. If the step size is too large, the energy error grows and acceptance falls. Adaptive variants such as NUTS tune the trajectory length and, in practice, the step size automatically, which removes most of the manual tuning.

Formula
\alpha = \min\!\left(1,\, \exp\{-(H(z^*, p^*) - H(z, p))\}\right),\quad H(z,p)=U(z)+\tfrac12 p^{\top}M^{-1}p
5

After discarding burn-in samples, summarise each parameter from the S retained draws, for example the posterior mean as the average of the draws theta^(s), together with medians and 95% credible intervals. For the missing values, the retained draws form a posterior (predictive) distribution for each missing entry; averaging them gives a point summary only and is not a Rubin-rules multiple-imputation pooled estimate. To capture imputation uncertainty, propagate the full set of draws into downstream quantities of interest.

Formula
E[\theta \mid y_{obs}] \approx \frac{1}{S}\sum_{s=1}^{S}\theta^{(s)}

Common pitfalls

  • Leaving the missing-value dimensions out of convergence diagnostics. Imputed draws can look well mixed while the parameter chains have not converged, or the reverse. Check R-hat and effective sample size for both imputed and parameter quantities before reporting, and rerun longer or reparameterise if they are unsatisfactory.
  • Assuming MAR without checking. If missingness depends on the unobserved value itself, the estimates are biased regardless of sampler quality.
  • Placing improper priors on the model parameters in regions where data are sparse. This can make the joint posterior improper, so the draws for the missing values are not meaningful.
  • Skipping posterior predictive checks on the observed-data margin, which can reveal model misspecification that inflates imputation error.
  • Reading the imputed-value posterior as if it were observed data. Its width expresses imputation uncertainty under the assumed model; report parameter credible intervals alongside it and examine sensitivity to priors and to the missingness assumption.

Frequently asked questions

How is this different from multiple imputation by chained equations (MICE)?

MICE imputes missing values iteratively using a sequence of conditional models and then analyzes each imputed dataset separately, combining results with Rubin's rules. HMC with missing data jointly samples parameters and missing values in a single principled model, so it does not need a separate combining step and propagates uncertainty through the same posterior. It is more coherent but requires a fully specified generative model and differentiable likelihoods.

Does this require me to model the missingness mechanism?

If missing data are MAR or MCAR, the missingness indicator can be ignored (ignorable missingness) and you only need to model the complete-data distribution. If data are MNAR, you must also specify a model for why values are missing, or results will be biased. HMC handles the sampling but does not diagnose the mechanism for you.

How do I check convergence when missing values are part of the state?

Include the imputed-value chains in the usual diagnostics: compute R-hat and effective sample size (ESS) for a representative subset of imputed values alongside the model parameters. Poor values for any component, including the imputed ones, indicate that the chain has not mixed, even when the parameter chains look acceptable.

Can I use NUTS (the No-U-Turn Sampler) here?

Yes. NUTS is the adaptive variant of HMC that selects trajectory length automatically and is the default sampler in Stan and PyMC. It works directly on the augmented state (parameters plus missing values) and typically requires little manual step-size tuning, which makes it the usual choice for practical use.

How much missingness is too much for this method?

There is no hard threshold. As the proportion of missing values rises, the posterior for the missing values is increasingly driven by the model and prior rather than by the observed data, and imputation uncertainty comes to dominate the estimates. Sensitivity analyses with different priors on the model parameters are important when missingness is high.

Related methods

Sources

  1. Neal, R. M. (2011). MCMC using Hamiltonian dynamics. In S. Brooks, A. Gelman, G. Jones & X.-L. Meng (Eds.), Handbook of Markov Chain Monte Carlo (pp. 113-162). CRC Press.

    ISBN: 978-1420079418
  2. Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A. & Rubin, D. B. (2013). Bayesian Data Analysis (3rd ed.). CRC Press. Chapter 18: Missing-data imputation.

    ISBN: 978-1439840955