Lecture 19 The EM Algorithm
In lecture 5 we found the MLE by solving the likelihood equation, in closed form where this is possible and numerically otherwise. In this lecture we consider models with latent variables or missing data, where the likelihood would be easy to maximise if the missing values were known. The expectation-maximisation (EM) algorithm, introduced in this lecture, makes use of this structure: it alternates between filling in the missing information and re-estimating the parameter values. We illustrate the EM algorithm with the help of a worked example, considering a mixture of two normal distributions. This example also gives the non-identifiable model from lecture 4, to which we return in lecture 20. There we will also prove that each round of the EM algorithm cannot decrease the likelihood, and in lecture 21 we will discuss how to implement the EM algorithm in R.
19.1 Incomplete Data
Assume that we are given data consisting of i.i.d. pairs , , with joint density or joint probability weights , but we have observed only . The pair with is called the complete data, the values are called the observed data and the unobserved values are called latent variables. The complete-data log-likelihood is given by
and the observed-data log-likelihood is given by
where is the marginal density of a single observation, given by
with the integral used instead of the sum when is continuous. The MLE for is the maximiser of , but the algebra from lecture 5 is not applicable, since the sum inside the logarithm prevents any simplifications. The function , being a sum of standard log-likelihoods, would be easy to maximise, but it cannot even be evaluated as it depends on . The EM algorithm is based on this observation.
We will use the following example throughout this lecture and the next.
Suppose that a population consists of two groups, with proportion for group 1 and for group 2. The measurement has distribution in group 1 and in group 2, where we assume that we know , while , and are unknown. We are given observations of the measurement , but we do not know which group the observation belongs to. If we write for the density of , then the observations are i.i.d. with density
where the parameter is
This is an example of a two-component normal mixture. The observed-data log-likelihood is
with a sum of two terms inside each logarithm. If we knew the groups, the MLEs for this example would be easy to find: we would get the proportion of group 1 and the two group means by using examples 5.3 and 5.4, but without the groups we cannot find the MLEs in closed form.
19.2 The Algorithm
The EM algorithm starts from a guess and then alternates between two steps: it replaces by its conditional expectation given the observed data, computed under the current parameter value, and it maximises the result over .
Let be given. Then the EM algorithm for finding the parameter values consists of the following iterative steps for :
-
(E)
Expectation step: compute
the conditional expectation of the complete-data log-likelihood given the observed data, where the conditional distribution of is computed using the parameter value .
-
(M)
Maximisation step: set
The second argument of enters only through the conditional distribution of given . By Bayes’ rule, proposition A.20 in appendix A, this conditional distribution has density or probability weights
Since the pairs are independent, once the data are observed is a sum over the observations, given by
For a discrete latent variable the complete-data log-likelihood is linear in the indicators , since
Comparing this with the formula for , we see that the E step replaces each indicator by its conditional probability given the data.
We now apply the algorithm to the two-component normal mixture from example 19.1. We will see that the M step gives the complete-data MLEs from lecture 5, with each group indicator replaced by the conditional probability that the observation belongs to the group.
In this model, the latent variables are i.i.d. with and , and given we have . The complete-data density is and , and thus the complete-data log-likelihood is
which is linear in the indicators. For the E step, using Bayes’ rule with the current value , we find
This is called the responsibility of group 1 for the observation . By this linearity, taking the conditional expectation replaces by and by , and thus
For the M step we maximise over with the fixed. Since , the partial derivatives of are
and setting these to zero gives the updates
The second derivatives are negative and thus these are maxima. They are the complete-data MLEs of examples 5.3 and 5.4 with indicators replaced by responsibilities.
-
•
In an incomplete-data model, the complete data has an easy log-likelihood , but only is observed and the observed-data log-likelihood has a sum inside the logarithm.
-
•
EM iteratively computes the expectation and then maximises the expectation over .
-
•
For a two-component normal mixture, the E step computes the responsibilities and the M step computes the weight as the average responsibility and the means as responsibility-weighted means of the data.
Consider the two-component normal mixture from example 19.1, but with known weight and known variance . The only unknown quantities are the means .
-
1.
Show that the EM updates for this case are given by the two mean updates from (19.1), where the responsibilities are computed using the known .
-
2.
Compute the derivative of the observed-data log-likelihood and show that
where is the responsibility at . Deduce that the likelihood equations coincide with the fixed-point equations of the EM iteration.
-
3.
What are the updates in the limit ? Comment upon your result in the context of example 5.4.