Why EM Works
The ELBO view: monotone improvement and its variants.
EM looks like a heuristic: guess the hidden variables, refit, repeat. It is in fact coordinate ascent on a single function, the evidence lower bound, and that one observation explains why the likelihood never falls, where the iterates can end up, why EM sometimes crawls, and how to build versions that run on data streams, on Monte Carlo samples and on posteriors you cannot compute.
What you’ll learn
- Prove the decomposition and derive EM as coordinate ascent on .
- State Wu's convergence theorem with its conditions, and explain why the limit can be a saddle point and why the iterates need not converge.
- Derive EM's linear rate from the fraction of missing information, , and compute it in an exact example.
- Compare generalized, incremental, online, Monte Carlo, stochastic-approximation and variational EM: what each step computes and what guarantee survives.
One function, two coordinates
Write for all the observed data, for all the latent variables and . For any distribution over , define the evidence lower bound (ELBO), also called the negative variational free energy:
does not depend on , so it equals its own average under . Then use inside the average:
Add and subtract and regroup:
The KL divergence is nonnegative and zero only when the two distributions agree (Gibbs' inequality, a consequence of Jensen's inequality), which gives the bound and the equality case.
Now EM is coordinate ascent on (Neal & Hinton, 1998):
- E-step, maximize over with fixed. Since is fixed, maximizing means minimizing the KL term, so and the gap closes.
- M-step, maximize over with fixed. The entropy does not involve , so this maximizes .
Monotonicity is one line: . The gain in likelihood is the M-step's gain in plus the KL gap that reopens once the parameters move.
Immediately after an M-step (and before the next E-step), which statement is true in general?
- , so
- The likelihood rose by exactly the M-step's increase in
- has not decreased, and the KL gap is generally positive again, so the likelihood rose by at least the gain in
- The KL gap shrank, because the M-step moved toward
Show the answer
C. has not decreased, and the KL gap is generally positive again, so the likelihood rose by at least the gain in
The M-step changes , so the posterior moves away from , which was computed at . The gap reopens, and the gain in . The next E-step closes it again.
Where EM converges
Monotonicity gives convergence of the values whenever is bounded above, but says nothing about the limit. Boyles (1983) gave an example in which a generalized EM sequence fails to converge under the conditions stated by Dempster, Laird & Rubin, and Wu (1983) supplied conditions that work, by applying Zangwill's global convergence theorem to the EM map.
Read the theorem for what it leaves out:
- "Stationary" includes saddle points and local minima. Compactness and continuity cannot tell a maximum from a saddle; in practice a small perturbation usually pushes EM off a saddle, but EM can sit on one exactly.
- The values may converge while the iterates wander. When the likelihood has a continuum of maximizers (as it does in non-identified models), can drift along the ridge. Under mild conditions the iterates approach a compact, connected set of stationary points, which need not be a single point (Boyles, 1983; Wu, 1983).
- Compactness fails for mixtures. A component collapsing onto a data point sends , so the level sets of a Gaussian mixture likelihood are not compact. The theorem applies after constraining the variances or adding a prior (Gaussian Mixture Models in Depth).
Think first You start EM for a -component Gaussian mixture with all components identical: equal weights, the same mean and the same covariance. What happens, and does it contradict the theorem?
Every responsibility equals , so the M-step gives every component the same weighted mean and covariance: those of a single Gaussian fitted to all the data. The components stay identical forever. This fixed point is a stationary point of (the gradient with respect to each mean is times the single-Gaussian gradient, which vanishes at the single-Gaussian MLE), typically a saddle point, and EM converges to it in one step, exactly as the theorem allows. Random or k-means initialization breaks the symmetry.
How fast: the fraction of missing information
Write EM as a map, , with a fixed point in the interior. Near it, , so the speed is set by the Jacobian . Three information matrices at , all conditional on the observed , enter:
Because for every , averaging the Hessians over the posterior gives the missing information principle (Orchard & Woodbury, 1972; Louis, 1982): observed information = complete information − missing information, .
The M-step solves at . Differentiate this identity in at the fixed point (subscripts 1 and 2 mark derivatives in the first and second arguments of ):
The first block is minus the complete information. For the second, is the posterior mean of the complete-data score ; differentiating the posterior in produces the covariance of given , which by the information identity for equals the missing information:
Solve for and use . The local rate of convergence is the spectral radius, the largest fraction of missing information over directions in parameter space:
In that example, 90% of the values are missing. Starting with an error , how many EM iterations does it take to bring the error below ?
Show the answer
132 iterations
The error after iterations is , and needs , so 132 iterations. With 30% missing it takes 12. EM's linear rate is harmless when little is missing and painful when most of the information sits in the hidden variables.
For mixtures the missing information is the uncertainty in the labels. When components are well separated, responsibilities are near 0 or 1, and EM converges in a handful of iterations; Ma, Xu & Jordan (2000) showed that, for large samples near the true parameters, the rate tends to zero as the overlap vanishes, so EM becomes asymptotically superlinear. Overlapping components make EM crawl, as in the widget above. Xu & Jordan (1996) showed that for Gaussian mixtures each EM step is the gradient multiplied by an explicit matrix, : a preconditioned gradient method that respects the constraints on weights and covariances automatically.
When EM is too slow, the same quantities help: Louis's formula computes from complete-data quantities, enabling Newton or quasi-Newton steps near the optimum and standard errors at the end; parameter expansion (PX-EM; Liu, Rubin & Wu, 1998) enlarges the model to reduce the effective missing information.
Variants: when a step is too expensive
The decomposition says which relaxations are safe. Any step that does not decrease , in either coordinate, keeps the likelihood bounded below by a non-decreasing quantity; steps that replace expectations by random estimates trade monotonicity for cheapness and need stochastic-approximation step sizes.
| Variant | E-step | M-step | What survives |
|---|---|---|---|
| Generalized EM | exact | any that increases | monotone ascent; Wu's theorem under closedness |
| ECM (Meng & Rubin, 1993) | exact | a cycle of conditional maximizations, each over a block of parameters | monotone ascent; same limit points as EM under mild conditions |
| Incremental EM (Neal & Hinton, 1998) | refresh the posterior of one point or block, update running sufficient statistics | full, from the statistics | each partial step increases ; often much faster in wall-clock time |
| Online EM (Cappé & Moulines, 2009) | posterior of one new observation, blended into the statistics with step | with Robbins–Monro steps, convergence to stationary points of the KL divergence from the data distribution to the model, at the rate of the MLE | |
| Monte Carlo EM (Wei & Tanner, 1990) | average over draws , often by MCMC | exact on the Monte Carlo | not monotone; the sample size must grow as iterates approach the optimum |
| Stochastic EM | a single imputed draw of | complete-data MLE | a Markov chain that fluctuates around the MLE rather than converging to it |
| SAEM (Delyon, Lavielle & Moulines, 1999) | simulate , then | maximize | convergence to stationary points under conditions, the attractive ones being local maxima |
| Variational EM | best within a tractable family | exact on | monotone in , but is only a bound; see below |
ONLINE-EM for a Gaussian mixture on a stream x_1, x_2, ...
# running expected sufficient statistics, initialized from a start (pi, mu, Sigma):
# s0[k] = pi_k, s1[k] = pi_k mu_k, s2[k] = pi_k (Sigma_k + mu_k mu_k^T)
for t = 1, 2, ...:
r = responsibilities of x_t under the current (pi, mu, Sigma) # E-step, one point
for k = 1..K:
s0[k] += g_t * (r[k] - s0[k])
s1[k] += g_t * (r[k] * x_t - s1[k])
s2[k] += g_t * (r[k] * x_t x_t^T - s2[k])
pi_k = s0[k]; mu_k = s1[k] / s0[k]; Sigma_k = s2[k] / s0[k] - mu_k mu_k^T # M-step
# step sizes with sum g_t = infinity and sum g_t^2 < infinity, e.g. g_t = t^(-0.6)For complete-data models in the exponential family, EM only needs the expected sufficient statistics, so a stochastic-approximation average of them replaces the full E-step. The weights stay normalized automatically because each sums to one.
Statistical guarantees and open problems
Wu's theorem is about optimization on a fixed sample. A different question is statistical: started near the truth, does sample EM reach an estimate as good as the MLE? Balakrishnan, Wainwright & Yu (2017) separate the two by comparing sample EM with the population EM operator , defined like but with the expectation over infinitely many data. If the model is correct, the true parameter is a fixed point of .
Assume is a contraction with factor on a ball , and that with probability at least the sample operator stays uniformly close to it on the ball:
Use and the triangle inequality. If , the iterate stays in the ball, so the bound can be repeated:
Unroll the recursion. The optimization error decays geometrically, and what remains is the statistical error ; for many models is of order up to logarithmic factors.
Their examples include the symmetric mixture in . If the signal-to-noise ratio exceeds a large enough constant , population EM contracts with factor on the ball of radius around ; with samples, sample EM started anywhere in that ball reaches an error of order (times a factor depending on and ) with probability at least .
Over-specified models behave differently. Fitting a two-component mixture to data from a single Gaussian makes the Fisher information singular at the truth. Dwivedi, Ho, Khamaru, Wainwright, Jordan & Yu (2020) showed that with unbalanced mixture weights EM still converges geometrically, to within of the truth, but with balanced weights its convergence is exponentially slower and its fixed point is only -accurate. The global picture for mixtures, including bad local maxima that no amount of data removes, is in Gaussian Mixture Models in Depth.
Key takeaways
- For any , . EM is coordinate ascent on : the E-step closes the KL gap, the M-step raises , and the likelihood cannot fall.
- Fisher's identity, , makes interior fixed points of EM stationary points of . Wu's theorem: under compactness and continuity, limit points are stationary (possibly saddles) and converges.
- EM converges linearly with rate , the fraction of missing information; with a fraction of a Gaussian sample missing, the error shrinks by exactly per iteration.
- Generalized, ECM and incremental EM keep monotonicity; online, Monte Carlo and stochastic-approximation EM trade it for cheap noisy steps; variational EM maximizes , which biases the parameters.
- A contraction of the population EM operator near the truth turns into a statistical guarantee for sample EM: geometric convergence to within of . Singular, over-specified models are slower on both counts.
Check yourself
In the interactive lesson these are scored with your confidence, and what you miss comes back for review.
In the coordinate-ascent view of EM, what does the E-step do to the evidence lower bound ?
- It maximizes over with fixed, closing the KL gap so that
- It maximizes over with fixed
- It minimizes to tighten the bound from below
- It leaves unchanged and only computes the gradient
Show the answer
A. It maximizes over with fixed, closing the KL gap so that
With fixed, is constant, so maximizing over is minimizing the KL term, which the posterior makes zero.
Under Wu's conditions, what can you conclude about an EM sequence ?
- It converges to the global maximizer of the likelihood
- It converges to a local maximizer of the likelihood
- Its limit points are stationary points of (possibly saddle points), and converges monotonically
- It converges to a single point whenever the likelihood is bounded
Show the answer
C. Its limit points are stationary points of (possibly saddle points), and converges monotonically
The theorem guarantees stationarity of limit points and monotone convergence of the values. Convergence of the iterates themselves needs more (for example isolated stationary points and ), and nothing rules out saddle points; EM started with identical mixture components sits on one forever.
Near its limit, EM's error shrinks by a factor of about 0.95 per iteration. What does this tell you?
- The model is misspecified
- About 95% of the information about the slowest-converging parameter direction is missing (carried by the latent variables)
- EM is converging to a saddle point
- A bug: EM should converge quadratically
Show the answer
B. About 95% of the information about the slowest-converging parameter direction is missing (carried by the latent variables)
The linear rate is , the largest fraction of missing information. A rate of 0.95 means that in some direction the observed data carry only 5% of the information complete data would; switching to (quasi-)Newton steps near the optimum, or reparameterizing, can help.
In Monte Carlo EM, why is the number of Monte Carlo draws per E-step usually increased as the iterations proceed?
- To keep the Monte Carlo error in smaller than the shrinking EM steps, so the iterates converge instead of jittering around the optimum
- Because each iteration needs a fresh burn-in of exactly the same length
- To restore the exact monotonicity of the likelihood, which then holds once the sample is large enough
- Because the M-step becomes harder as approaches the optimum
Show the answer
A. To keep the Monte Carlo error in smaller than the shrinking EM steps, so the iterates converge instead of jittering around the optimum
Far from the optimum, EM's steps are large and crude Monte Carlo estimates suffice. Near it, the steps shrink, and a fixed Monte Carlo error would dominate, leaving the iterates fluctuating. Growing sample sizes (or stochastic-approximation averaging, as in SAEM) let the noise vanish.
Further reading
- A. P. Dempster, N. M. Laird & D. B. Rubin, "Maximum likelihood from incomplete data via the EM algorithm," Journal of the Royal Statistical Society B 39(1), 1–38 (1977).
- C. F. J. Wu, "On the convergence properties of the EM algorithm," Annals of Statistics 11(1), 95–103 (1983).
- R. M. Neal & G. E. Hinton, "A view of the EM algorithm that justifies incremental, sparse, and other variants," in M. I. Jordan (ed.), Learning in Graphical Models (Kluwer, 1998), 355–368.
- S. Balakrishnan, M. J. Wainwright & B. Yu, "Statistical guarantees for the EM algorithm: From population to sample-based analysis," Annals of Statistics 45(1), 77–120 (2017).
- G. J. McLachlan & T. Krishnan, The EM Algorithm and Extensions, 2nd ed. (Wiley, 2008).