Expectation–Maximization
Learning probabilistic model parameters when key variables are unobserved
1 Topic at a Glance
One-sentence summary: Expectation–maximization (EM) fits a model with unobserved variables by repeatedly estimating their probabilistic assignments and optimizing parameters against those weighted assignments.
| Item | Description |
|---|---|
| Biological question | What hidden classes, states, or evolutionary/error parameters best explain incomplete biological observations? |
| Computational problem | Maximize likelihood when direct optimization is obstructed by unobserved assignments |
| Method type | Iterative maximum-likelihood estimation with latent variables |
| Input | Observed data, a probabilistic generative model, and initialized parameters |
| Output | Locally optimized parameter estimates plus responsibilities or expected latent counts |
| Bioinformatics uses | HMM training, mixture models, transcript/isoform abundance estimation, genotype and error models |
| Prerequisites | Likelihood, conditional probability, Viterbi and Forward–Backward algorithms |
2 Why missing assignments complicate likelihood
Suppose observations \(X\) arise with unobserved variables \(Z\): a read’s source transcript, a sample’s mixture component, or an HMM’s state path. If \(Z\) were known, estimating parameters \(\theta\) could be straightforward using counts. But the observed-data likelihood
\[ \ell(\theta)=\log P(X\mid\theta)=\log\sum_Z P(X,Z\mid\theta) \]
contains a log of a sum over many possible hidden explanations. Assigning every observation once to its most likely class discards uncertainty and can lock the procedure into early mistakes. EM uses soft assignments instead.
3 The EM cycle
Starting from parameters \(\theta^{(r)}\), EM alternates two steps:
3.2 M-step: update the parameters
Choose parameters that maximize that weighted complete-data objective:
\[ \theta^{(r+1)}=\arg\max_\theta Q(\theta\mid\theta^{(r)}). \]
For many models this is a normalized-count update; for others it requires a numerical optimizer. Repeating E and M steps does not decrease the observed-data likelihood. It converges to a stationary point, which can be a local rather than global maximum.
initialize parameters
-> E-step: soft assignments / expected counts
-> M-step: parameters fitted to those counts
-> test convergence
-> repeat
4 Toy example: a two-component expression mixture
Consider measured expression values \(x_1,\ldots,x_n\) from two latent groups, each modeled by a Gaussian. The hidden variable \(z_i\) says which group produced sample \(i\).
- Initialize two means, for example \(\mu_1=2\) and \(\mu_2=8\).
- E-step: calculate each responsibility \(r_{ik}=P(z_i=k\mid x_i,\theta)\); a sample at 5 may be split almost equally between the groups.
- M-step: update each mean with the responsibility-weighted average,
\[ \mu_k\leftarrow\frac{\sum_i r_{ik}x_i}{\sum_i r_{ik}}. \]
- Update mixture weights and variances similarly, then repeat.
Hard k-means-like assignments are a limiting special case, but EM preserves uncertainty. This is valuable when biological populations overlap or measurements are noisy.
6 Convergence, validation, and failure modes
| Issue | Why it matters | Practical response |
|---|---|---|
| Local optima | EM improves from its initialization, not necessarily to the global solution | Use several scientifically plausible starts and compare held-out likelihood/interpretability |
| Degenerate mixture components | A Gaussian component can collapse onto one point with near-zero variance | Constrain variances, use priors/regularization, and check component sizes |
| Non-identifiability | Different parameter labels or combinations can fit equally well | Treat labels consistently; report uncertainty and biological validation |
| Overfitting | More components/states can always improve training likelihood | Select model complexity with held-out data, information criteria, or prior knowledge |
| Premature convergence | A small parameter change may still hide poor fit | Monitor likelihood, parameter changes, and application-specific diagnostics |
Likelihood increase is an optimization property, not proof of biological correctness. Batch effects, composition bias, missing covariates, and a misspecified error distribution can all lead EM to a stable but misleading explanation.
7 Connections
EM is a general latent-variable framework. In profile HMMs and pairwise HMMs, it can estimate probabilities from sequences or alignments; Forward–Backward supplies the E-step for HMMs. It differs from Viterbi and Forward–Backward algorithms: those algorithms infer hidden states for fixed parameters, while EM uses such inference inside parameter learning. The following Bayesian-inference topics replace point estimates with distributions over parameters when that added uncertainty matters.
8 Take-home Messages
- EM addresses latent variables by alternating posterior-weighted expected counts with parameter updates.
- The E-step is inference under current parameters; the M-step is optimization given that inferred uncertainty.
- EM monotonically improves (or preserves) observed-data likelihood, but it can converge to a poor local or biologically implausible solution.
- Baum–Welch is EM for HMMs, powered by Forward–Backward expected state and transition counts.
9 References
- Dempster, A. P., Laird, N. M., & Rubin, D. B. 1977. Maximum likelihood from incomplete data via the EM algorithm. Journal of the Royal Statistical Society: Series B 39:1–38.
- Baum, L. E., Petrie, T., Soules, G., & Weiss, N. 1970. A maximization technique occurring in the statistical analysis of probabilistic functions of Markov chains. Annals of Mathematical Statistics 41:164–171.
- McLachlan, G. J., & Krishnan, T. 2008. The EM Algorithm and Extensions. Wiley.