--- title: "Definitions and computational methodology" author: "David Bolin and Finn Lindgren" output: rmarkdown::html_vignette header-includes: - \usepackage{amsmath} vignette: > %\VignetteIndexEntry{Definitions and computational methodology} %\VignetteEngine{knitr::rmarkdown} %\VignetteEncoding{UTF-8} bibliography: ref.bib --- \DeclareMathOperator*{\argmax}{arg\,max} \newcommand{\mapset}{G} \newcommand{\mv}[1]{{\boldsymbol{\mathrm{#1}}}} \newcommand{\exset}[2]{E_{{#1}}^{{#2}}} \newcommand{\md}{\,\mathrm{d}} ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) library(excursions) ``` ```{r inla_link, include = FALSE} inla_link <- function() { sprintf("[%s](%s)", "`R-INLA`", "https://www.r-inla.org") } ``` Hierarchical models are of great importance in many areas of statistics. In the simplest form, a hierarchical model has a likelihood distribution $\pi(\mv{Y}|\mv{X}, \mv{\theta})$ for observed data $\mv{Y}$, which is specified conditionally on a latent process of interest, $\mv{X}$, which has a distribution $\pi(\mv{X}|\mv{\theta})$. For Bayesian hierarchical models, one also specifies prior distributions for the model parameters $\mv{\theta}$. The most important special case of these models are the LGMs, which are obtained by assuming that $\mv{X}|\mv{\theta}$ has a Gaussian distribution [@rue09]. Numerous applications can be studied using models of this form, and these are therefore the main focus of the methods in `excursions`. A statistical analysis using an LGM often concludes with reporting the posterior mean $E(\mv{X}|\mv{Y})$ as a point estimate of the latent field, possibly together with posterior variances as a measure of uncertainty. In many applications, however, reporting posterior means and variances are not enough. As stated in the introduction, one may be interested in computing regions where the latent field exceeds some given threshold, contour curves with their associated uncertainty, or simultaneous confidence bands. In some applications, only a contour map of the posterior mean is reported, where the number of levels in the contour map should represent the uncertainty in the estimate. These are quantities that can be computed with `excursions` and we now define these in more detail before outlining how they can be computed. For details we refer to [@bolin12] and [@bolin15contours]. ## Definitions The main quantities that can be computed using `excursions` are (1) excursion sets, (2) contour credible regions and level avoiding sets, (3) excursion functions, (4) contour maps and their quality measures, (5) simultaneous confidence bands. This section defines these in more detail. Throughout the section, $X(\mv{s})$ will denote a stochastic process defined on some domain of interest, $\Omega$, which we assume is open with a well-defined area $|\Omega|<\infty$. Since it is not necessary for the definitions, we will not explicitly state the dependency on the data, but simply allow $X$ to have some possible non-stationary distribution. In practice, however, the distribution of $X$ will typically be a posterior distribution conditionally on data, $X(\mv{s})|\mv{Y}$. For frequentist models, the distribution of $X$ could also be conditionally on for example a maximum likelihood estimate of the parameters, $X(\mv{s})|\mv{Y},\widehat{\mv{\theta}}$. ### Excursion sets An excursion set is a set where the process $X(\mv{s})$ exceeds or goes below some given level of interest, $u$. A where $X(\mv{s})>u$ is referred to as a positive excursion set, whereas a set where $X(\mv{s})u \}$ and $A_u^-(f) = \{ \mv{s}\in\Omega; f(\mv{s})u$ in $M_{u,\alpha}^+$ and $X(\mv{s}) \alpha_2$. This means that $\mv{F}_u$ can be obtained by first reordering the nodes and then computing a sequential integral. The reordering is in this case obtained by sorting the marginal probabilities $P(x_i > u)$ (for other options, see [@bolin12]. After reordering, the $i$:th element of $\mv{F}_u^+$ is obtained as the integral $$ \int_u^{\infty}\pi(\mv{x}_{1:i}|\mv{Y}) d\mv{x}_{1:i}. $$ Using sequential importance sampling as described below, the whole sequence of integrals can be obtained with the same cost as computing only one integral with $i=n$, making the computation of $\mv{F}_u^+$ feasible also for large problems. ### Gaussian integrals The basis for the computational methods in the package is the ability to compute the required integral when the posterior distribution is Gaussian. In this case, one should compute an integral \begin{equation}\label{eq:markovint} \frac{|\mv{Q}|^{1/2}}{(2\pi)^{d/2}}\int_{\mv{u}-\mv{\mu}\leq \mv{x}}\exp\left(-\frac{1}{2}\mv{x}^{\top}\mv{Q} \mv{x}\right) \md \mv{x}. \end{equation} Here $\mv{\mu}$ and $\mv{Q}$ are the posterior mean and posterior precision matrix respectively. To take advantage of the possible sparsity of $\mv{Q}$ if a Markovian model is used, the integral is rewritten as \begin{equation}\label{eq:seqint} \int_{a_d}^{\infty}\pi(x_d) \int_{a_{d-1}}^{\infty}\pi(x_{d-1}|x_d) \cdots \int_{a_2}^{\infty}\pi(x_2|\mv{x}_{3:d}) \int_{a_1}^{\infty} \pi(x_1|\mv{x}_{2:d}) \md \mv{x} \end{equation} where, if the problem has a Markov structure, $x_i|\mv{x}_{i+1:d}$ only depends on a few of the elements in $x_{i+1:d}$ given by the Markov structure. The integral is calculated using a sequential importance sampler by starting with the integral of the last component $\pi(x_d)$ and then moving backward in the indices, see \cite{bolin12} for further details. ### Handling non-Gaussian data Using the sequential importance sampler above, $\mv{F}_u^+$ can be computed for Gaussian models with known parameters. For more complicated models, the latent Gaussian structure has to be handled, and this can be done in different ways depending on the accuracy that is needed. `excursions` currently supports the following five methods described in detail in [@bolin12]: Empirical Bayes (`EB`), Quantile Correction (`QC`), Numerical Integration (`NI`), Numerical integration with Quantile Corrections (`NIQC`), and improved Numerical integration with Quantile Corrections (`iNIQC`). The `EB` method is the simplest method and is based on using a Gaussian approximation of the posterior, $\pi(\mv{x}|\mv{Y}) \approx \pi_G(\mv{x}|\mv{Y},\widehat{\mv{\theta}})$. The `QC` method uses the same Gaussian approximation but modifies the limits in the integral to improve the accuracy. The three other methods are intended for Bayesian models, where the posterior is obtained by integrating over the parameters, \begin{equation*} \pi(\mv{x}\mid\mv{Y}) = \int \pi(\mv{x}\mid\mv{Y},\mv{\theta})\pi(\mv{\theta}\mid\mv{Y})d\mv{\theta}. \end{equation*} The `NI` method approximates the integration with respect to the parameters as in the INLA method, using a sum of representative parameter configurations, and the `NIQC` and `iNIQC` methods combines this with the `QC` method to improve the accuracy further. In general, `EB` and `QC` are suitable for frequentist models and for Bayesian models where the posterior distribution conditionally on the parameters is approximately Gaussian. The methods are equivalent if the posterior is Gaussian and in other cases `QC` is more accurate than `EB`. For Bayesian models, the `NI` method is, in general, more accurate than the `QC` method, and for non-Gaussian likelihoods, the `NIQC` and `iNIQC` methods can be used for improved results. In general the accuracy and computational cost of the methods are as follows Accuracy: `EB` $<$ `QC` $<$ `NI` $<$ `NIQC` $<$ `iNIQC` Computational cost: `EB` $\approx$ `QC` $<$ `NI` $\approx$ `NIQC` $<$ `iNIQC`. If the main purpose of the analysis is to construct excursion or contour sets for low values of $\alpha$, we recommend using the `QC` method for problems with Gaussian likelihoods and the `NIQC` method for problems with non-Gaussian likelihoods. The increase in accuracy of the `iNIQC` method is often small compared to the added computational cost. ### Continuous domain interpolations For a continuous spatial domain, the excursion function $F_u^+(\mv{s})$ can be approximated using $\mv{F}_u^+$ computed at discrete point locations. The main idea is to interpolate $\mv{F}_u^+$ assuming monotonicity of the random field between the discrete computation locations. Specifically, assume that the values of $\mv{F}_u^+$ correspond to the values at the vertices of some triangulated mesh. If the excursion set $\exset{u,\alpha}{+}(X)$ should be computed for some specific value of $\alpha$, one has to find the $1-\alpha$ contour for $F_u^+(\mv{s})$. For interpolation to a location $\mv{s}$ within a specific triangle $\mathcal{T}$ with corners in $\mv{s}_1, \mv{s}_2,$ and $\mv{s}_3$, `excursions` by default uses log-linear interpolation, $F_u(\mv{s}) = \exp\{\sum_{k=1}^3 w_k\log[F_u(\mv{s}_k)]\}$. Here $\{(w_1,w_2,w_3);\, w_1,w_2,w_3\geq 0,\, \sum_{k=1}^3 w_i=1\}$ are the barycentric coordinates of $\mv{s}$ within the triangle. Further technical details of the continuous domain construction are given in [@bolin15contours]. Studies of the resulting continuous domain excursion sets in [@bolin15contours] indicate that the log-linear interpolation method results in sets with coverage probability on target or slightly above target for large target probabilities. ## References