Laplace's approximation

From testwiki
Jump to navigation Jump to search

Template:Short description Template:Distinguish

Template:Bayesian statistics

Laplace's approximation or the quadratic approximation (QUAP)[1] provides an analytical expression for a posterior probability distribution by fitting a Gaussian distribution with a mean equal to the MAP solution and precision equal to the observed Fisher information.[2][3] The approximation is justified by the Bernstein–von Mises theorem, which states that, under regularity conditions, the error of the approximation tends to 0 as the number of data points tends to infinity.[4][5]

For example, consider a regression or classification model with data set {xn,yn}n=1,…,N comprising inputs x and outputs y with (unknown) parameter vector ΞΈ of length D. The likelihood is denoted p(𝐲|𝐱,ΞΈ) and the parameter prior p(ΞΈ). Suppose one wants to approximate the joint density of outputs and parameters p(𝐲,ΞΈ|𝐱). Bayes' formula reads:

p(𝐲,ΞΈ|𝐱)=p(𝐲|𝐱,ΞΈ)p(ΞΈ|𝐱)=p(𝐲|𝐱)p(ΞΈ|𝐲,𝐱)≃q~(ΞΈ)=Zq(ΞΈ).

The joint is equal to the product of the likelihood and the prior and by Bayes' rule, equal to the product of the marginal likelihood p(𝐲|𝐱) and posterior p(θ|𝐲,𝐱). Seen as a function of θ the joint is an un-normalised density.

In Laplace's approximation, we approximate the joint by an un-normalised Gaussian q~(θ)=Zq(θ), where we use q to denote approximate density, q~ for un-normalised density and Z the normalisation constant of q~ (independent of θ). Since the marginal likelihood p(𝐲|𝐱) doesn't depend on the parameter θ and the posterior p(θ|𝐲,𝐱) normalises over θ we can immediately identify them with Z and q(θ) of our approximation, respectively.

Laplace's approximation is

p(𝐲,ΞΈ|𝐱)≃p(𝐲,ΞΈΜ‚|𝐱)exp⁡(βˆ’12(ΞΈβˆ’ΞΈΜ‚)⊀Sβˆ’1(ΞΈβˆ’ΞΈΜ‚))=q~(ΞΈ),

where we have defined

ΞΈΜ‚=argmaxΞΈlog⁡p(𝐲,ΞΈ|𝐱),Sβˆ’1=βˆ’βˆ‡ΞΈβˆ‡ΞΈlog⁡p(𝐲,ΞΈ|𝐱)|ΞΈ=ΞΈΜ‚,

where ΞΈΜ‚ is the location of a mode of the joint target density, also known as the maximum a posteriori or MAP point and Sβˆ’1 is the DΓ—D positive definite matrix of second derivatives of the negative log joint target density at the mode ΞΈ=ΞΈΜ‚. Thus, the Gaussian approximation matches the value and the log-curvature of the un-normalised target density at the mode. The value of ΞΈΜ‚ is usually found using a gradient based method.

In summary, we have

q(ΞΈ)=𝒩(ΞΈ|ΞΌ=ΞΈΜ‚,Ξ£=S),log⁡Z=log⁡p(𝐲,ΞΈΜ‚|𝐱)+12log⁡|S|+D2log⁡(2Ο€),

for the approximate posterior over ΞΈ and the approximate log marginal likelihood respectively.

The main weaknesses of Laplace's approximation are that it is symmetric around the mode and that it is very local: the entire approximation is derived from properties at a single point of the target density. Laplace's method is widely used and was pioneered in the context of neural networks by David MacKay,[6] and for Gaussian processes by Williams and Barber.[7]

Integrated nested Laplace approximation

Template:Vanchor (Template:Vanchor) is a method for approximate Bayesian inference based on Laplace's approximation.[8] It is designed for a class of models called latent Gaussian models (LGMs), for which it can be a fast and accurate alternative for Markov chain Monte Carlo methods to compute posterior marginal distributions.[9][10][11] Due to its relative speed even with large data sets for certain problems and models, INLA has been a popular inference method in applied statistics, in particular spatial statistics, ecology, seismology, and epidemiology.[12][13][14] It is also possible to combine INLA with a finite element method solution of a stochastic partial differential equation to study e.g. spatial point processes and species distribution models.[15][16] The INLA method is implemented in the R-INLA R package.[17]

Latent Gaussian models

Let π’š=(y1,…,yn) denote the response variable (that is, the observations) which belongs to an exponential family, with the mean ΞΌi (of yi) being linked to a linear predictor Ξ·i via an appropriate link function. The linear predictor can take the form of a (Bayesian) additive model. All latent effects (the linear predictor, the intercept, coefficients of possible covariates, and so on) are collectively denoted by the vector 𝒙. The hyperparameters of the model are denoted by 𝜽. As per Bayesian statistics, 𝒙 and 𝜽 are random variables with prior distributions.

The observations are assumed to be conditionally independent given 𝒙 and 𝜽: Ο€(π’š|𝒙,𝜽)=∏iβˆˆβ„Ο€(yi|Ξ·i,𝜽), where ℐ is the set of indices for observed elements of π’š (some elements may be unobserved, and for these INLA computes a posterior predictive distribution). Note that the linear predictor 𝜼 is part of 𝒙.

For the model to be a latent Gaussian model, it is assumed that 𝒙|𝜽 is a Gaussian Markov Random Field (GMRF)[8] (that is, a multivariate Gaussian with additional conditional independence properties) with probability density Ο€(𝒙|𝜽)∝|π‘Έπœ½|1/2exp⁡(βˆ’12𝒙Tπ‘Έπœ½π’™), where π‘Έπœ½ is a 𝜽-dependent sparse precision matrix and |π‘Έπœ½| is its determinant. The precision matrix is sparse due to the GMRF assumption. The prior distribution Ο€(𝜽) for the hyperparameters need not be Gaussian. However, the number of hyperparameters, m=dim(𝜽), is assumed to be small (say, less than 15).

Approximate Bayesian inference with INLA

In Bayesian inference, one wants to solve for the posterior distribution of the latent variables 𝒙 and 𝜽. Applying Bayes' theorem Ο€(𝒙,𝜽|π’š)=Ο€(π’š|𝒙,𝜽)Ο€(𝒙|𝜽)Ο€(𝜽)Ο€(π’š), the joint posterior distribution of 𝒙 and 𝜽 is given by Ο€(𝒙,𝜽|π’š)βˆΟ€(𝜽)Ο€(𝒙|𝜽)∏iΟ€(yi|Ξ·i,𝜽)βˆΟ€(𝜽)|π‘Έπœ½|1/2exp⁡(βˆ’12𝒙Tπ‘Έπœ½π’™+βˆ‘ilog⁡[Ο€(yi|Ξ·i,𝜽)]). Obtaining the exact posterior is generally a very difficult problem. In INLA, the main aim is to approximate the posterior marginals Ο€(xi|π’š)=βˆ«Ο€(xi|𝜽,π’š)Ο€(𝜽|π’š)dπœ½Ο€(ΞΈj|π’š)=βˆ«Ο€(𝜽|π’š)dπœ½βˆ’j, where πœ½βˆ’j=(ΞΈ1,…,ΞΈjβˆ’1,ΞΈj+1,…,ΞΈm).

A key idea of INLA is to construct nested approximations given by Ο€~(xi|π’š)=βˆ«Ο€~(xi|𝜽,π’š)Ο€~(𝜽|π’š)dπœ½Ο€~(ΞΈj|π’š)=βˆ«Ο€~(𝜽|π’š)dπœ½βˆ’j, where Ο€~(β‹…|β‹…) is an approximated posterior density. The approximation to the marginal density Ο€(xi|π’š) is obtained in a nested fashion by first approximating Ο€(𝜽|π’š) and Ο€(xi|𝜽,π’š), and then numerically integrating out 𝜽 as Ο€~(xi|π’š)=βˆ‘kΟ€~(xi|𝜽k,π’š)Γ—Ο€~(𝜽k|π’š)Γ—Ξ”k, where the summation is over the values of 𝜽, with integration weights given by Ξ”k. The approximation of Ο€(ΞΈj|π’š) is computed by numerically integrating πœ½βˆ’j out from Ο€~(𝜽|π’š).

To get the approximate distribution Ο€~(𝜽|π’š), one can use the relation Ο€(𝜽|π’š)=Ο€(𝒙,𝜽,π’š)Ο€(𝒙|𝜽,π’š)Ο€(π’š), as the starting point. Then Ο€~(𝜽|π’š) is obtained at a specific value of the hyperparameters 𝜽=𝜽k with Laplace's approximation[8] Ο€~(𝜽k|π’š)βˆΟ€(𝒙,𝜽k,π’š)Ο€~G(𝒙|𝜽k,π’š)|𝒙=π’™βˆ—(𝜽k),βˆΟ€(π’š|𝒙,𝜽k)Ο€(𝒙|𝜽k)Ο€(𝜽k)Ο€~G(𝒙|𝜽k,π’š)|𝒙=π’™βˆ—(𝜽k), where Ο€~G(𝒙|𝜽k,π’š) is the Gaussian approximation to Ο€(𝒙|𝜽k,π’š) whose mode at a given 𝜽k is π’™βˆ—(𝜽k). The mode can be found numerically for example with the Newton-Raphson method.

The trick in the Laplace approximation above is the fact that the Gaussian approximation is applied on the full conditional of 𝒙 in the denominator since it is usually close to a Gaussian due to the GMRF property of 𝒙. Applying the approximation here improves the accuracy of the method, since the posterior Ο€(𝜽|π’š) itself need not be close to a Gaussian, and so the Gaussian approximation is not directly applied on Ο€(𝜽|π’š). The second important property of a GMRF, the sparsity of the precision matrix π‘Έπœ½k, is required for efficient computation of Ο€~(𝜽k|π’š) for each value 𝜽k.[8]

Obtaining the approximate distribution Ο€~(xi|𝜽k,π’š) is more involved, and the INLA method provides three options for this: Gaussian approximation, Laplace approximation, or the simplified Laplace approximation.[8] For the numerical integration to obtain Ο€~(xi|π’š), also three options are available: grid search, central composite design, or empirical Bayes.[8]

References

Template:Reflist

Further reading