The EM Algorithm

Canonical reference: Casella & Berger, Statistical Inference ref/casella-berger

The expectation–maximization (EM) algorithm computes maximum likelihood (or MAP) estimates when the model involves latent variables or missing data. The observed-data likelihood requires summing or integrating over what is unobserved and is often intractable to maximize directly, while the complete-data likelihood — the one that would apply if the latent quantities were known — is easy. EM trades the hard maximization for a sequence of easy ones.

Page-local notation: is the observed data, the unobserved latent or missing data, and the parameter (scalar or vector). The observed-data likelihood is

with a sum replacing the integral for discrete .

The two steps

Starting from an initial value , alternate:

E step. Compute the expected complete-data log-likelihood, taking the expectation over the latent data given the observed data and the current parameters:

M step. Maximize that expectation and update:

Iterate until the parameters or the log-likelihood barely change. In the common case where the complete-data model is an exponential family, the E step reduces to computing the expected sufficient statistics and the M step often has a closed form. For MAP estimation, add the log prior to in the M step; everything else is unchanged.

Why the likelihood never decreases

Write for the conditional density of the latent data. Then , and taking expectations under gives

By Gibbs’ inequality (a consequence of Jensen’s inequality), . Any that improves beyond its value at therefore improves by at least as much, and the M step chooses exactly such a . Every EM iteration satisfies

with equality only when the maximized no longer changes.

What EM converges to — and what it does not

Monotone likelihood increase is not a guarantee of finding the MLE. The precise picture:

  • Under regularity conditions the sequence converges to a stationary point of the observed-data likelihood — usually a local maximum, but saddle points are possible. The original 1977 convergence analysis was flawed; the corrected analysis is due to Wu (1983).
  • Global maxima are not guaranteed. Multimodal likelihoods mean the solution depends on ; random or informed multiple starts are standard practice.
  • Singular solutions exist in some families. In a normal mixture the likelihood is unbounded: a component centered on a single observation with variance shrinking to zero drives it to infinity. EM can walk toward such degenerate solutions, so mixture fits need constraints or inspection.
  • Convergence is linear and can be slow, especially when the missing information is large. The monotone, derivative-free steps are the benefit; speed is the cost. General-purpose optimizers on the observed-data likelihood are the alternative when derivatives are available.

Worked example: a two-component Gaussian mixture

Observations come from a mixture of two normals with weight on component 1. The latent indicates which component generated ; knowing the would reduce estimation to two independent normal-theory problems. The E step computes each point’s responsibility for component 1,

where is the normal density, and the M step is a responsibility-weighted refit with :

A simulated sample (, true , , , seed 42; computations in Python) run from a dispersed start (, means at , ):

00.5000.0764.7982.3612.361
10.4820.8013.9561.9731.531
20.4770.6314.0831.8891.311
30.4710.4714.1881.7391.157
50.4470.2044.2401.4441.056
100.3944.1261.0781.105
200.3804.0721.0141.150
450.3794.0691.0121.152

The log-likelihood increased at every one of the 45 iterations (checked programmatically), quickly at first and then in tiny increments — the typical EM pattern. Two observations: the converged log-likelihood () exceeds the log-likelihood at the true parameter values (), because the MLE fits this particular sample, not the population; and responsibilities are soft assignments — EM with hard assignments () reduces to -means-like alternating classification, which does not share the monotonicity guarantee for the mixture likelihood.

Variants and applications

  • ECM (expectation–conditional maximization) splits the M step into simpler conditional maximizations when the joint maximization is awkward.
  • MCEM approximates an intractable E step by Monte Carlo; the exact monotonicity property then holds only approximately.
  • MM (minorize–maximize) algorithms generalize the construction: EM is the special case where minorizes .

In quantitative psychology the main application is marginal maximum likelihood: the latent variable is integrated out of the likelihood and EM handles the integration iteratively. In IRT the latent trait plays the role of ; in CDM it is the attribute profile, with up to latent classes. Other standard uses include finite mixtures generally, missing-data problems, and hidden Markov models (where EM is known as the Baum–Welch algorithm).