Supriya Ghosh (Editor)

Expectation–maximization algorithm

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit
Expectation–maximization algorithm

In statistics, an expectation–maximization (EM) algorithm is an iterative method to find maximum likelihood or maximum a posteriori (MAP) estimates of parameters in statistical models, where the model depends on unobserved latent variables. The EM iteration alternates between performing an expectation (E) step, which creates a function for the expectation of the log-likelihood evaluated using the current estimate for the parameters, and a maximization (M) step, which computes parameters maximizing the expected log-likelihood found on the E step. These parameter-estimates are then used to determine the distribution of the latent variables in the next E step.

Contents

History

The EM algorithm was explained and given its name in a classic 1977 paper by Arthur Dempster, Nan Laird, and Donald Rubin. They pointed out that the method had been "proposed many times in special circumstances" by earlier authors. A very detailed treatment of the EM method for exponential families was published by Rolf Sundberg in his thesis and several papers following his collaboration with Per Martin-Löf and Anders Martin-Löf. The Dempster-Laird-Rubin paper in 1977 generalized the method and sketched a convergence analysis for a wider class of problems. Regardless of earlier inventions, the innovative Dempster-Laird-Rubin paper in the Journal of the Royal Statistical Society received an enthusiastic discussion at the Royal Statistical Society meeting with Sundberg calling the paper "brilliant". The Dempster-Laird-Rubin paper established the EM method as an important tool of statistical analysis.

The convergence analysis of the Dempster-Laird-Rubin paper was flawed and a correct convergence analysis was published by C.F. Jeff Wu in 1983. Wu's proof established the EM method's convergence outside of the exponential family, as claimed by Dempster-Laird-Rubin.

Introduction

The EM algorithm is used to find (locally) maximum likelihood parameters of a statistical model in cases where the equations cannot be solved directly. Typically these models involve latent variables in addition to unknown parameters and known data observations. That is, either missing values exist among the data, or the model can be formulated more simply by assuming the existence of further unobserved data points. For example, a mixture model can be described more simply by assuming that each observed data point has a corresponding unobserved data point, or latent variable, specifying the mixture component to which each data point belongs.

Finding a maximum likelihood solution typically requires taking the derivatives of the likelihood function with respect to all the unknown values, the parameters and the latent variables, and simultaneously solving the resulting equations. In statistical models with latent variables, this is usually impossible. Instead, the result is typically a set of interlocking equations in which the solution to the parameters requires the values of the latent variables and vice versa, but substituting one set of equations into the other produces an unsolvable equation.

The EM algorithm proceeds from the observation that the following is a way to solve these two sets of equations numerically. One can simply pick arbitrary values for one of the two sets of unknowns, use them to estimate the second set, then use these new values to find a better estimate of the first set, and then keep alternating between the two until the resulting values both converge to fixed points. It's not obvious that this will work at all, but it can be proven that in this context it does, and that the derivative of the likelihood is (arbitrarily close to) zero at that point, which in turn means that the point is either a maximum or a saddle point. In general, multiple maxima may occur, with no guarantee that the global maximum will be found. Some likelihoods also have singularities in them, i.e., nonsensical maxima. For example, one of the solutions that may be found by EM in a mixture model involves setting one of the components to have zero variance and the mean parameter for the same component to be equal to one of the data points.

Description

Given the statistical model which generates a set X of observed data, a set of unobserved latent data or missing values Z , and a vector of unknown parameters θ , along with a likelihood function L ( θ ; X , Z ) = p ( X , Z | θ ) , the maximum likelihood estimate (MLE) of the unknown parameters is determined by the marginal likelihood of the observed data

L ( θ ; X ) = p ( X | θ ) = Z p ( X , Z | θ )

However, this quantity is often intractable (e.g. if Z is a sequence of events, so that the number of values grows exponentially with the sequence length, making the exact calculation of the sum extremely difficult).

The EM algorithm seeks to find the MLE of the marginal likelihood by iteratively applying these two steps:

Expectation step (E step): Calculate the expected value of the log likelihood function, with respect to the conditional distribution of Z given X under the current estimate of the parameters θ ( t ) : Maximization step (M step): Find the parameter that maximizes this quantity: θ ( t + 1 ) = a r g m a x θ   Q ( θ | θ ( t ) )

In typical models to which EM is applied:

  1. The observed data points X may be discrete (taking values in a finite or countably infinite set) or continuous (taking values in an uncountably infinite set). Associated with each data point may be a vector of observations.
  2. The missing values (aka latent variables) Z are discrete, drawn from a fixed number of values, and with one latent variable per observed data point.
  3. The parameters are continuous, and are of two kinds: Parameters that are associated with all data points, and those associated with a specific value of a latent variable (i.e., associated with all data points which corresponding latent variable has that value).

However, it is possible to apply EM to other sorts of models.

The motive is as follows. If the value of the parameters θ is known, usually the value of the latent variables Z can be found by maximizing the log-likelihood over all possible values of Z , either simply by iterating over Z or through an algorithm such as the Viterbi algorithm for hidden Markov models. Conversely, if we know the value of the latent variables Z , we can find an estimate of the parameters θ fairly easily, typically by simply grouping the observed data points according to the value of the associated latent variable and averaging the values, or some function of the values, of the points in each group. This suggests an iterative algorithm, in the case where both θ and Z are unknown:

  1. First, initialize the parameters θ to some random values.
  2. Compute the best value for Z given these parameter values.
  3. Then, use the just-computed values of Z to compute a better estimate for the parameters θ . Parameters associated with a specific value of Z will use only those data points which associated latent variable has that value.
  4. Iterate steps 2 and 3 until convergence.

The algorithm as just described monotonically approaches a local minimum of the cost function, and is commonly called hard EM. The k-means algorithm is an example of this class of algorithms.

However, somewhat better methods exist. Rather than making a hard choice for Z given the current parameter values and averaging only over the set of data points associated with some value of Z , instead, determine the probability of each possible value of Z for each data point, and then use the probabilities associated with some value of Z to compute a weighted average over the whole set of data points. The resulting algorithm is commonly called soft EM, and is the type of algorithm normally associated with EM. The counts used to compute these weighted averages are called soft counts (as opposed to the hard counts used in a hard-EM-type algorithm such as k-means). The probabilities computed for Z are posterior probabilities and are what is computed in the E step. The soft counts used to compute new parameter values are what is computed in the M step.

Properties

Speaking of an expectation (E) step is a bit of a misnomer. What is calculated in the first step are the fixed, data-dependent parameters of the function Q. Once the parameters of Q are known, it is fully determined and is maximized in the second (M) step of an EM algorithm.

Although an EM iteration does increase the observed data (i.e., marginal) likelihood function, no guarantee exists that the sequence converges to a maximum likelihood estimator. For multimodal distributions, this means that an EM algorithm may converge to a local maximum of the observed data likelihood function, depending on starting values. A variety of heuristic or metaheuristic approaches exist to escape a local maximum, such as random-restart hill climbing (starting with several different random initial estimates θ(t)), or applying simulated annealing methods.

EM is especially useful when the likelihood is an exponential family: the E step becomes the sum of expectations of sufficient statistics, and the M step involves maximizing a linear function. In such a case, it is usually possible to derive closed-form expression updates for each step, using the Sundberg formula (published by Rolf Sundberg using unpublished results of Per Martin-Löf and Anders Martin-Löf).

The EM method was modified to compute maximum a posteriori (MAP) estimates for Bayesian inference in the original paper by Dempster, Laird, and Rubin.

Other methods exist to find maximum likelihood estimates, such as gradient descent, conjugate gradient, or variants of the Gauss–Newton algorithm. Unlike EM, such methods typically require the evaluation of first and/or second derivatives of the likelihood function.

Proof of correctness

Expectation-maximization works to improve Q ( θ | θ ( t ) ) rather than directly improving log p ( X | θ ) . Here is shown that improvements to the former imply improvements to the latter.

For any Z with non-zero probability p ( Z | X , θ ) , we can write

We take the expectation over possible values of the unknown data Z under the current parameter estimate θ ( t ) by multiplying both sides by p ( Z | X , θ ( t ) ) and summing (or integrating) over Z . The left-hand side is the expectation of a constant, so we get:

where H ( θ | θ ( t ) ) is defined by the negated sum it is replacing. This last equation holds for any value of θ including θ = θ ( t ) ,

and subtracting this last equation from the previous equation gives

However, Gibbs' inequality tells us that H ( θ | θ ( t ) ) H ( θ ( t ) | θ ( t ) ) , so we can conclude that

In words, choosing θ to improve Q ( θ | θ ( t ) ) beyond Q ( θ ( t ) | θ ( t ) ) can not cause log p ( X | θ ) to decrease below log p ( X | θ ( t ) ) , and so the marginal likelihood of the data is non-decreasing.

As a maximization-maximization procedure

The EM algorithm can be viewed as two alternating maximization steps, that is, as an example of coordinate ascent. Consider the function:

F ( q , θ ) := E q [ log L ( θ ; x , Z ) ] + H ( q ) ,

where q is an arbitrary probability distribution over the unobserved data z and H(q) is the entropy of the distribution q. This function can be written as

F ( q , θ ) = D K L ( q p Z | X ( | x ; θ ) ) + log L ( θ ; x ) ,

where p Z | X ( | x ; θ ) is the conditional distribution of the unobserved data given the observed data x and D K L is the Kullback–Leibler divergence.

Then the steps in the EM algorithm may be viewed as:

Expectation step: Choose q to maximize F : q ( t ) = a r g m a x q   F ( q , θ ( t ) ) Maximization step: Choose θ to maximize F : θ ( t + 1 ) = a r g m a x θ   F ( q ( t ) , θ )

Applications

EM is frequently used for data clustering in machine learning and computer vision. In natural language processing, two prominent instances of the algorithm are the Baum-Welch algorithm and the inside-outside algorithm for unsupervised induction of probabilistic context-free grammars.

In psychometrics, EM is almost indispensable for estimating item parameters and latent abilities of item response theory models.

With the ability to deal with missing data and observe unidentified variables, EM is becoming a useful tool to price and manage risk of a portfolio.[ref?]

The EM algorithm (and its faster variant ordered subset expectation maximization) is also widely used in medical image reconstruction, especially in positron emission tomography and single photon emission computed tomography. See below for other faster variants of EM.

In structural engineering, the Structural Identification using Expectation Maximization (STRIDE) algorithm is an output-only method for identifying natural vibration properties of a structural system using sensor data (see Operational Modal Analysis).

Filtering and smoothing EM algorithms

A Kalman filter is typically used for on-line state estimation and a minimum-variance smoother may be employed for off-line or batch state estimation. However, these minimum-variance solutions require estimates of the state-space model parameters. EM algorithms can be used for solving joint state and parameter estimation problems.

Filtering and smoothing EM algorithms arise by repeating this two-step procedure:

E-step
Operate a Kalman filter or a minimum-variance smoother designed with current parameter estimates to obtain updated state estimates.
M-step
Use the filtered or smoothed state estimates within maximum-likelihood calculations to obtain updated parameter estimates.

Suppose that a Kalman filter or minimum-variance smoother operates on noisy measurements of a single-input-single-output system. An updated measurement noise variance estimate can be obtained from the maximum likelihood calculation

σ ^ v 2 = 1 N k = 1 N ( z k x ^ k ) 2

where x ^ k are scalar output estimates calculated by a filter or a smoother from N scalar measurements z k . Similarly, for a first-order auto-regressive process, an updated process noise variance estimate can be calculated by

σ ^ w 2 = 1 N k = 1 N ( x ^ k + 1 F ^ x ^ k ) 2

where x ^ k and x ^ k + 1 are scalar state estimates calculated by a filter or a smoother. The updated model coefficient estimate is obtained via

F ^ = k = 1 N ( x ^ k + 1 F ^ x ^ k ) k = 1 N x ^ k 2 .

The convergence of parameter estimates such as those above are well studied.

Variants

A number of methods have been proposed to accelerate the sometimes slow convergence of the EM algorithm, such as those using conjugate gradient and modified Newton's methods (Newton–Raphson). Also, EM can be used with constrained estimation methods.

Expectation conditional maximization (ECM) replaces each M step with a sequence of conditional maximization (CM) steps in which each parameter θi is maximized individually, conditionally on the other parameters remaining fixed.

This idea is further extended in generalized expectation maximization (GEM) algorithm, in which is sought only an increase in the objective function F for both the E step and M step under the alternative description. GEM is further developed in a distributed environment and shows promising results.

It is also possible to consider the EM algorithm as a subclass of the MM (Majorize/Minimize or Minorize/Maximize, depending on context) algorithm, and therefore use any machinery developed in the more general case.

α-EM algorithm

The Q-function used in the EM algorithm is based on the log likelihood. Therefore, it is regarded as the log-EM algorithm. The use of the log likelihood can be generalized to that of the α-log likelihood ratio. Then, the α-log likelihood ratio of the observed data can be exactly expressed as equality by using the Q-function of the α-log likelihood ratio and the α-divergence. Obtaining this Q-function is a generalized E step. Its maximization is a generalized M step. This pair is called the α-EM algorithm which contains the log-EM algorithm as its subclass. Thus, the α-EM algorithm by Yasuo Matsuyama is an exact generalization of the log-EM algorithm. No computation of gradient or Hessian matrix is needed. The α-EM shows faster convergence than the log-EM algorithm by choosing an appropriate α. The α-EM algorithm leads to a faster version of the Hidden Markov model estimation algorithm α-HMM.

Relation to variational Bayes methods

EM is a partially non-Bayesian, maximum likelihood method. Its final result gives a probability distribution over the latent variables (in the Bayesian style) together with a point estimate for θ (either a maximum likelihood estimate or a posterior mode). A fully Bayesian version of this may be wanted, giving a probability distribution over θ and the latent variables. The Bayesian approach to inference is simply to treat θ as another latent variable. In this paradigm, the distinction between the E and M steps disappears. If using the factorized Q approximation as described above (variational Bayes), solving can iterate over each latent variable (now including θ) and optimize them one at a time. Now, k steps per iteration are needed, where k is the number of latent variables. For graphical models this is easy to do as each variable's new Q depends only on its Markov blanket, so local message passing can be used for efficient inference.

Geometric interpretation

In information geometry, the E step and the M step are interpreted as projections under dual affine connections, called the e-connection and the m-connection; the Kullback–Leibler divergence can also be understood in these terms.

Gaussian mixture

Let x = ( x 1 , x 2 , , x n ) be a sample of n independent observations from a mixture of two multivariate normal distributions of dimension d , and let z = ( z 1 , z 2 , , z n ) be the latent variables that determine the component from which the observation originates.

X i | ( Z i = 1 ) N d ( μ 1 , Σ 1 ) and X i | ( Z i = 2 ) N d ( μ 2 , Σ 2 )

where

P ( Z i = 1 ) = τ 1 and P ( Z i = 2 ) = τ 2 = 1 τ 1

The aim is to estimate the unknown parameters representing the mixing value between the Gaussians and the means and covariances of each:

θ = ( τ , μ 1 , μ 2 , Σ 1 , Σ 2 )

where the incomplete-data likelihood function is

L ( θ ; x ) = i = 1 n j = 1 2 τ j   f ( x i ; μ j , Σ j ) ,

and the complete-data likelihood function is

L ( θ ; x , z ) = p ( x , z | θ ) = i = 1 n j = 1 2 I ( z i = j )   f ( x i ; μ j , Σ j ) τ j

or

L ( θ ; x , z ) = exp { i = 1 n j = 1 2 I ( z i = j ) [ log τ j 1 2 log | Σ j | 1 2 ( x i μ j ) Σ j 1 ( x i μ j ) d 2 log ( 2 π ) ] } .

where I is an indicator function and f is the probability density function of a multivariate normal.

To see the last equality, then for each i all indicators I ( z i = j ) are equal to zero, except for one which is equal to one. The inner sum thus reduces to one term.

E step

Given our current estimate of the parameters θ(t), the conditional distribution of the Zi is determined by Bayes theorem to be the proportional height of the normal density weighted by τ:

T j , i ( t ) := P ( Z i = j | X i = x i ; θ ( t ) ) = τ j ( t )   f ( x i ; μ j ( t ) , Σ j ( t ) ) τ 1 ( t )   f ( x i ; μ 1 ( t ) , Σ 1 ( t ) ) + τ 2 ( t )   f ( x i ; μ 2 ( t ) , Σ 2 ( t ) ) .

These are called the "membership probabilities" which are normally considered the output of the E step (although this is not the Q function of below).

This E step corresponds with this function for Q:

Q ( θ | θ ( t ) ) = E Z | X , θ ( t ) [ log L ( θ ; x , Z ) ] = E Z | X , θ ( t ) [ log i = 1 n L ( θ ; x i , z i ) ] = E Z | X , θ ( t ) [ i = 1 n log L ( θ ; x i , z i ) ] = i = 1 n E Z | X ; θ ( t ) [ log L ( θ ; x i , z i ) ] = i = 1 n j = 1 2 P ( Z i = j | X i = x i ; θ ( t ) ) log L ( θ j ; x i , z i ) = i = 1 n j = 1 2 T j , i ( t ) [ log τ j 1 2 log | Σ j | 1 2 ( x i μ j ) Σ j 1 ( x i μ j ) d 2 log ( 2 π ) ]

This full conditional expectation does not need to be calculated in one step, because τ and μ/Σ appear in separate linear terms and can thus be maximized independently.

M step

Q(θ|θ(t)) being quadratic in form means that determining the maximizing values of θ is relatively straightforward. Also, τ, (μ1,Σ1) and (μ2,Σ2) may all be maximized independently since they all appear in separate linear terms.

To begin, consider τ, which has the constraint τ1 + τ2=1:

τ ( t + 1 ) = a r g m a x τ   Q ( θ | θ ( t ) ) = a r g m a x τ   { [ i = 1 n T 1 , i ( t ) ] log τ 1 + [ i = 1 n T 2 , i ( t ) ] log τ 2 }

This has the same form as the MLE for the binomial distribution, so

τ j ( t + 1 ) = i = 1 n T j , i ( t ) i = 1 n ( T 1 , i ( t ) + T 2 , i ( t ) ) = 1 n i = 1 n T j , i ( t ) .

For the next estimates of (μ1,Σ1):

( μ 1 ( t + 1 ) , Σ 1 ( t + 1 ) ) = a r g m a x μ 1 , Σ 1   Q ( θ | θ ( t ) ) = a r g m a x μ 1 , Σ 1   i = 1 n T 1 , i ( t ) { 1 2 log | Σ 1 | 1 2 ( x i μ 1 ) Σ 1 1 ( x i μ 1 ) } .

This has the same form as a weighted MLE for a normal distribution, so

μ 1 ( t + 1 ) = i = 1 n T 1 , i ( t ) x i i = 1 n T 1 , i ( t ) and Σ 1 ( t + 1 ) = i = 1 n T 1 , i ( t ) ( x i μ 1 ( t + 1 ) ) ( x i μ 1 ( t + 1 ) ) i = 1 n T 1 , i ( t )

and, by symmetry

μ 2 ( t + 1 ) = i = 1 n T 2 , i ( t ) x i i = 1 n T 2 , i ( t ) and Σ 2 ( t + 1 ) = i = 1 n T 2 , i ( t ) ( x i μ 2 ( t + 1 ) ) ( x i μ 2 ( t + 1 ) ) i = 1 n T 2 , i ( t ) .

Termination

Conclude the iterative process if E Z | θ ( t ) , x [ log L ( θ ( t ) ; x , Z ) ] E Z | θ ( t 1 ) , x [ log L ( θ ( t 1 ) ; x , Z ) ] + ϵ for ϵ below some preset threshold.

Generalization

The algorithm illustrated above can be generalized for mixtures of more than two multivariate normal distributions.

Truncated and censored regression

The EM algorithm has been implemented in the case where an underlying linear regression model exists explaining the variation of some quantity, but where the values actually observed are censored or truncated versions of those represented in the model. Special cases of this model include censored or truncated observations from one normal distribution.

Alternatives

EM typically converges to a local optimum, not necessarily the global optimum, with no bound on the convergence rate in general. It is possible that it can be arbitrarily poor in high dimensions and there can be an exponential number of local optima. Hence, a need exists for alternative methods for guaranteed learning, especially in the high-dimensional setting. Alternatives to EM exist with better guarantees for consistency, which are termed moment-based approaches or the so-called spectral techniques. Moment-based approaches to learning the parameters of a probabilistic model are of increasing interest recently since they enjoy guarantees such as global convergence under certain conditions unlike EM which is often plagued by the issue of getting stuck in local optima. Algorithms with guarantees for learning can be derived for a number of important models such as mixture models, HMMs etc. For these spectral methods, no spurious local optima occur, and the true parameters can be consistently estimated under some regularity conditions.

References

Expectation–maximization algorithm Wikipedia


Similar Topics