Assume we have data and a parameter vector
, where
is formed by latent (non-observed) variables and
are possible hyperparameters, usually connected to the likelihood and/or the distribution of the latent variables
. A Bayesian model specifies the joint distribution
and our main goal is to compute the posterior distribution of the model parameters
and the marginal distribution of data (or model evidence)
. In practice, those quantities are rarely available in closed form, which asks for some kind of numerical approximation. One of the many approximation methods used in this context is called Variational Bayes.
Variational Bayes
Lets introduce a distribution defined over the parameters of the model
. For any choice of
, the following equation holds (see for example Section
of [1]):
is the Kullback-Leibler divergence [2] between
and the posterior distribution
. Since
, it follows from Eq. (1) that
. That is,
is a lower bound on
. Note also that
if and only if
almost everywhere.
Now, we can maximize the lower bound by optimization with respect to the distribution
(hence the name variational, see note below), which is equivalent to minimizing
.
Note: The term variational comes from the calculus of variations, which is concerned with the behavior of functionals. Functions map the value of a variable to the value of the function. Functionals map a function to the value of the functional. , for example, is a functional that takes the function
as input.
Is Variational Bayes an exact or an approximate method?
If we allow any possible choice of when optimizing
, then the maximum of the lower bound occurs when the KL divergence
vanishes, which occurs when
equals the posterior distribution
, and variational Bayes would then give an exact result.
However, maximizing over all possible choices of
is not feasible. Therefore, we usually impose some restriction on the family of distributions
considered in the optimization. The goal is to restrict the family sufficiently so that computations are feasible, while at the same time allowing the family to be sufficiently rich and flexible that it can provide a good approximation to the true posterior distribution.
Parametric approximation
One way to restrict the family of approximating distributions is to use a parametric distribution , like a Gaussian distribution for example, governed by a set of parameters
. The lower bound
then becomes a function of
, and we can exploit standard nonlinear optimization techniques to determine the optimal values for the parameters.
Factorized approximation
A different restriction is obtained by partitioning the elements of into disjoint groups that we denote by
, where
. We then assume that
factorizes with respect to these groups, so that
It should be emphasized that we are making no further assumptions about the distribution. In particular, we place no restriction on the functional forms of the individual factors . We now substitute Eq. (3) into Eq. (2) and optimize
with respect to each of the factors in turn.
It can be shown (see Section of [1]) that the optimal solution
for the factor
is given by
where the expectation is taken with respect to all other factors
such that
.
The set of equations in (4) does not represent an explicit solution to our optimization problem, since the equation for a specific depends on expectations computed with respect to other factor
for
. We then solve using an iterative method, by first initializing all the factors appropriately and cycling through the factors using updated solution from previous factors in the cycle. Convergence is guaranteed because the bound is convex with respect to each of the factors
.
As noted by [1], a factorized variational approximation tends to under-estimate the variance of the posterior distributions. Technically, this happens because we are trying to minimize , which is zero forcing in the sense that it forces
for every value of
where
, and typically
will under-estimate the support of
and will tend to seek the mode with the largest mass in case of a multi-modal posterior distribution.
In future posts, I will try to illustrate different implementations of Variational Bayes in practice.
References:
[1] Bishop, C. M. (2006). Pattern recognition and machine learning. New York: springer.
[2] Kullback, S., Leibler, R. A. (1951). On information and sufficiency. The Annals of Mathematical Statistics, 22(1), 79-86.
Further reading:
– Ormerod, J.T., Wand, M.P. (2010). Explaining variational approximations. The American Statistician, 64(2).
Related posts: