MCpriorIntFun {BMAmevt}  R Documentation 
Generic MonteCarlo integration of a function under the prior distribution
Description
Simple MonteCarlo sampler approximating the integral of FUN
with respect to the prior distribution.
Usage
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 
Hpar 
A list containing Hyperparameters to be passed to

dimData 
The dimension of the model's sample space,
on which the parameter's dimension may depend.
Passed to 
FUN 
A function to be integrated. It may return a vector or an array. 
store 
Should the successive evaluations of 
show.progress 
same as in 
Nsim.min 
The minimum number of iterations to be performed. 
precision 
The desired relative precision 
... 
Additional arguments to be passed to 
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) ) \le \epsilon ,
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) = \sqrt{est.var(n)/(nsim1)}
.
The empirical variance is computed componentwise 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
A list made of

stored.vals
: A matrix withnsim
rows andlength(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/\sqrt(nsim)
). 
not.finite
: The number of nonfinite values obtained (and discarded) when evaluatingFUN(par,...)
Author(s)
Anne Sabourin