Simple Monte-Carlo sampler approximating the integral of FUN with respect to the prior distribution.
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,
...
)A list made of
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/\sqrt(nsim)\)).
not.finite : The number of non-finite values obtained (and discarded) when evaluating FUN(par,...)
Maximum number of iterations
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.
A list containing Hyper-parameters to be passed to
prior.
The dimension of the model's sample space,
on which the parameter's dimension may depend.
Passed to prior inside MCintegrateFun
A function to be integrated. It may return a vector or an array.
Should the successive evaluations of FUN be stored ?
same as in posteriorMCMC
The minimum number of iterations to be performed.
The desired relative precision \(\epsilon\). See Details below.
Additional arguments to be passed to FUN.
Anne Sabourin
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)/(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.