MCpriorIntFun: Generic Monte-Carlo integration of a function under the prior... In lbelzile/BMAmevt: Multivariate Extremes: Bayesian Estimation of the Spectral Measure

Description

Simple Monte-Carlo sampler approximating the integral of `FUN` with respect to the prior distribution.

Usage

 ```1 2 3 4``` ```MCpriorIntFun(Nsim = 200, prior, Hpar, dimData, FUN = function(par, ...) { as.vector(par) }, store = TRUE, show.progress = floor(seq(1, Nsim, length.out = 20)), Nsim.min = Nsim, precision = 0, ...) ```

Arguments

 `Nsim` Maximum number of iterations `prior` The prior distribution: of type ```function(type=c("r","d"), n ,par, Hpar, log, dimData )```, where `dimData` is the dimension of the sample space (e.g., for the two-dimensional simplex (triangle), `dimData=3`. Should return either a matrix with `n` rows containing a random parameter sample generated under the prior (if `type == "d"`), or the density of the parameter `par` (the logarithm of the density if `log==TRUE`. See `prior.pb` and `prior.nl` for templates. `Hpar` A list containing Hyper-parameters to be passed to `prior`. `dimData` The dimension of the model's sample space, on which the parameter's dimension may depend. Passed to `prior` inside `MCintegrateFun` `FUN` A function to be integrated. It may return a vector or an array. `store` Should the successive evaluations of `FUN` be stored ? `show.progress` same as in `posteriorMCMC` `Nsim.min` The minimum number of iterations to be performed. `precision` The desired relative precision ε. See Details below. `...` Additional arguments to be passed to `FUN`.

Details

The algorithm exits after n iterations, based on the following stopping rule : n is the minimum number of iteration, greater than `Nsim.min`, such that the relative error is less than the specified `precision`.

max (est.esterr(n)/ |est.mean(n)| ) ≤ ε ,

where est.mean(n) is the estimated mean of `FUN` at time n, est.err(n) is the estimated standard deviation of the estimate: est.err(n) = √{est.var(n)/(nsim-1)} . The empirical variance is computed component-wise and the maximum over the parameters' components is considered.

The algorithm exits in any case after `Nsim` iterations, if the above condition is not fulfilled before this time.

Value

• `stored.vals` : A matrix with `nsim` rows and `length(FUN(par))` columns.

• `elapsed` : The time elapsed during the computation.

• `nsim` : The number of iterations performed

• `emp.mean` : The desired integral estimate: the empirical mean.

• `emp.stdev` : The empirical standard deviation of the sample.

• `est.error` : The estimated standard deviation of the estimate (i.e. emp.stdev/√(nsim)).

• `not.finite` : The number of non-finite values obtained (and discarded) when evaluating `FUN(par,...)`

Author(s)

Anne Sabourin

lbelzile/BMAmevt documentation built on June 13, 2019, 12:43 p.m.