# Vecchia approximation

Vecchia approximation is a Gaussian processes approximation technique originally developed by Aldo Vecchia, a statistician at United States Geological Survey. It is one of the earliest attempts to use Gaussian processes in high-dimensional settings. It has since been extensively generalized giving rise to many contemporary approximations.

## Intuition

A joint probability distribution for events $A,B$, and $C$, denoted $P(A,B,C)$, can be expressed as
    $P(A,B,C)=P(A)P(B|A)P(C|A,B)$
Vecchia's approximation takes the form, for example,
    $P(A,B,C)\approx P(A)P(B|A)P(C|A)$
and is accurate when events $B$ and $C$ are close to conditionally independent given knowledge of $A$. Of course one could have alternatively chosen the approximation
    $P(A,B,C)\approx P(A)P(B|A)P(C|B)$
and so use of the approximation requires some knowledge of which events are close to conditionally independent given others. Moreover, we could have chosen a different ordering, for example
    $P(A,B,C)\approx P(C)P(C|A)P(B|A).$
Fortunately, in many cases there are good heuristics making decisions about how to construct the approximation.
More technically, general versions of the approximation lead to a sparse Cholesky factor of the precision matrix. Using the standard Cholesky factorization produces entries which can be interpreted as conditional correlations with zeros indicating no dependence (since the model is Gaussian). These independence relations can be alternatively expressed using graphical models and there exist theorems linking graph structure and vertex ordering with zeros in the Cholesky factor. In particular, it is known that independencies that are encoded in a moral graph lead to Cholesky factors of the precision matrix that have no fill-in.

## Formal description
### The problem

Let $x$ be a Gaussian process indexed by ${\mathcal {S}}$ with mean function $\mu$ and covariance function $K$. Assume that $S=\{s_{1},\dots ,s_{n}\}\subset {\mathcal {S}}$ is a finite subset of ${\mathcal {S}}$ and $\mathbf {x} =(x_{1},\dots ,x_{n})$ is a vector of values of $x$ evaluated at $S$, i.e. $x_{i}=x(s_{i})$ for $i=1,\dots ,n$. Assume further, that one observes $\mathbf {y} =(y_{1},\dots ,y_{n})$ where $y_{i}=x_{i}+\varepsilon _{i}$ with $\varepsilon _{i}{\overset {\text{i.i.d.}}{\sim }}{\mathcal {N}}(0,\sigma ^{2})$. In this context the two most common inference tasks include evaluating the likelihood
    ${\mathcal {L}}(\mathbf {y} )=\int f(\mathbf {y} ,\mathbf {x} )\,d\mathbf {x} ,$
or making predictions of values of $x$ for $s^{*}\in {\mathcal {S}}$ and $s\not \in S$, i.e. calculating
    $f(x(s^{*})\mid y_{1},\dots ,y_{n}).$

### Original formulation

The original Vecchia method starts with the observation that the joint density of observations $f(\mathbf {y} )=\left(y_{1},\dots ,y_{n}\right)$ can be written as a product of conditional distributions
    $f(\mathbf {y} )=f(y_{1})\prod _{i=2}^{n}f(y_{i}\mid y_{i-1},\dots ,y_{1}).$
Vecchia approximation assumes instead that for some $k\ll n$
    ${\hat {f}}(\mathbf {y} )=f(y_{1})\prod _{i=2}^{n}f(y_{i}\mid y_{i-1},\dots ,y_{\max(i-k,1)}).$
Vecchia also suggested that the above approximation be applied to observations that are reordered lexicographically using their spatial coordinates. While his simple method has many weaknesses, it reduced the computational complexity to ${\mathcal {O}}(nk^{3})$. Many of its deficiencies were addressed by the subsequent generalizations.

## General formulation

While conceptually simple, the assumption of the Vecchia approximation often proves to be fairly restrictive and inaccurate. This inspired important generalizations and improvements introduced in the basic version over the years: the inclusion of latent variables, more sophisticated conditioning and better ordering. Different special cases of the general Vecchia approximation can be described in terms of how these three elements are selected.

### Latent variables

To describe extensions of the Vecchia method in its most general form, define $z_{i}=(x_{i},y_{i})$ and notice that for $\mathbf {z} =(z_{1},\dots ,z_{n})$ it holds that like in the previous section
    $f(\mathbf {z} )=f(x_{1},y_{1})\left(\prod _{i=2}^{n}f(x_{i}\mid z_{1:i-1})\right)\left(\prod _{i=2}^{n}f(y_{i}\mid x_{i})\right)$
because given $x_{i}$ all other variables are independent of $y_{i}$.

### Ordering

It has been widely noted that the original lexicographic ordering based on coordinates when ${\mathcal {S}}$ is two-dimensional produces poor results. More recently another orderings have been proposed, some of which ensure that points are ordered in a quasi-random fashion. Highly scalable, they have been shown to also drastically improve accuracy.

### Conditioning

Similar to the basic version described above, for a given ordering a general Vecchia approximation can be defined as
    ${\hat {f}}(\mathbf {z} )=f(x_{1},y_{1})\left(\prod _{i=2}^{n}f(x_{i}\mid z_{q(i)})\right)\left(\prod _{i=2}^{n}f(y_{i}\mid x_{i})\right),$
where $q(i)\subset \left\{1,\dots ,i-1\right\}$. Since $y_{i}\perp x_{-i},y_{-i}\mid x_{i}$ it follows that $f(x_{i}\mid z_{q(i)})=f(x_{i}\mid x_{q}(i),y_{q}(i))=f(x_{i}\mid x_{q}(i))$ since suggesting that the terms $f(x_{i}\mid z_{q(i)})$ be replaced with $f(x_{i}\mid x_{q(i)})$. It turns out, however, that sometimes conditioning on some of the observations $z_{i}$ increases sparsity of the Cholesky factor of the precision matrix of $(\mathbf {x} ,\mathbf {y} )$. Therefore, one might instead consider sets $q_{y}(i)$ and $q_{x}(i)$ such that $q(i)=q_{y}(i)\cup q_{x}(i)$ and express ${\hat {f}}$ as
    ${\hat {f}}(\mathbf {z} )=f(x_{1},y_{1})\left(\prod _{i=2}^{n}f(x_{i}\mid x_{q_{x}(i)},y_{q_{y}(i)})\right)\left(\prod _{i=2}^{n}f(y_{i}\mid x_{i})\right).$
Multiple methods of choosing $q_{y}(i)$ and $q_{x}(i)$ have been proposed, most notably the nearest-neighbour Gaussian process (NNGP), meshed Gaussian process and multi-resolution approximation (MRA) approaches using $q(i)=q_{x}(i)$, standard Vecchia using $q(i)=q_{y}(i)$ and Sparse General Vecchia where both $q_{y}(i)$ and $q_{x}(i)$ are non-empty.

## Software

Several packages have been developed which implement some variants of the Vecchia approximation.
* GPvecchia is an R package available through CRAN which implements most versions of the Vecchia approximation
* GpGp is an R package available through CRAN which implements an scalable ordering method for spatial problems which greatly improves accuracy.
* spNNGP is an R package available through CRAN which implements the latent Vecchia approximation
* pyMRA is a Python package available through pyPI implementing Multi-resolution approximation, a special case of the general Vecchia method used in dynamic state-space models
* meshed is an R package available through CRAN which implements Bayesian spatial or spatiotemporal multivariate regression models based a latent Meshed Gaussian Process (MGP) using Vecchia approximations on partitioned domains