# posterior.predictive3D: Posterior predictive density on the simplex, for... In lbelzile/BMAmevt: Multivariate Extremes: Bayesian Estimation of the Spectral Measure

## Description

Computes an approximation of the predictive density based on a posterior parameters sample. Only allowed in the three-dimensional case.

## Usage

 ```1 2 3``` ```posterior.predictive3D(post.sample, densityGrid, from = post.sample\$Nbin + 1, to = post.sample\$Nsim, thin = 40, npoints = 40, eps = 10^(-3), equi = T, displ = T, ...) ```

## Arguments

 `post.sample` A posterior sample as returned by `posteriorMCMC` `densityGrid` A function returning a `npoints*npoints` matrix, representing a discretized version of the spectral density on the two dimensional simplex. The function should be compatible with `dgridplot`. In particular, it must use `discretize` to produce the discretization grid. It must be of type ```function(par, npoints, eps, equi, displ,invisible, ... )```. See Details below. `from` Integer or `NULL`. If `NULL`, the default value is used. Otherwise, should be greater than `post.sample\$Nbin`. Indicates the index where the averaging process should start. Default to `post.sample\$Nbin +1` `to` Integer or `NULL`. If `NULL`, the default value is used. Otherwise, must be lower than `Nsim+1`. Indicates where the averaging process should stop. Default to `post.sample\$Nsim`. `thin` Thinning interval. `npoints` The number of grid nodes on the squared grid containing the desired triangle. `eps` Positive number: minimum distance from any node inside the simplex to the simplex boundary `equi` logical. Is the simplex represented as an equilateral triangle (if `TRUE`) or a right triangle (if `FALSE`) ? `displ` logical. Should a plot be produced ? `...` Additional graphical parameters and arguments to be passed to `contour` and `image`.

## Details

The posterior predictive density is approximated by averaging the densities produced by the function `densityGrid(par, npoints, eps, equi, displ,invisible, ...)` for `par` in a subset of the parameters sample stored in `post.sample`. The arguments of `densityGrid` must be

• `par`: A vector containing the parameters.

• `npoints, eps, equi`: Discretization parameters to be passed to `dgridplot`.

• `displ`: logical. Should a plot be produced ?

• `invisible`: logical. Should the result be returned as `invisible` ?

• `...` additional arguments to be passed to `dgridplot`

Only a sub-sample is used: one out of `thin` parameters is used (thinning). Further, only the parameters produced between time `from` and time `to` (included) are kept.

## Value

A `npoints*npoints` matrix: the posterior predictive density.

## Note

The computational burden may be high: it is proportional to `npoints^2`. Therefore, the function assigned to `densityGridplot` should be optimized, typically by calling `.C` with an internal, user defined `C` function.

## Author(s)

Anne Sabourin

`dgridplot`, `posteriorMCMC`.