selectDecay {esaddle} | R Documentation |
Tuning the Extended Empirical Saddlepoint (EES) density by cross-validation
Description
Performs k-fold cross-validation to choose the EES's tuning parameter, which determines the mixture between a consistent and a Gaussian estimator of the Cumulant Generating Function (CGF).
Usage
selectDecay(
decay,
simulator,
K,
nrep = 1,
normalize = FALSE,
draw = TRUE,
multicore = !is.null(cluster),
cluster = NULL,
ncores = detectCores() - 1,
control = list(),
...
)
Arguments
decay |
Numeric vector containing the possible values of the tuning parameter. |
simulator |
Function with prototype |
K |
the number of folds to be used in cross-validation. |
nrep |
Number of times the whole cross-validation procedure will be repeated, by calling
|
normalize |
if TRUE the normalizing constant of EES is normalized at each value of |
draw |
if |
multicore |
if TRUE each fold will run on a different core. |
cluster |
an object of class |
ncores |
number of cores to be used. |
control |
a list of control parameters, with entries:
|
... |
extra arguments to be passed to |
Value
A list with entries:
-
negLogLik
A matrixlength{decay}
byK*nrep
where the i-th row represent the negative loglikelihood estimated for the i-th value ofdecay
, while each column represents a different fold and repetition. -
summary
A matrix of summary results from the cross-validation procedure. -
normConst
A matrixlength{decay}
bynrep
where the i-th row contains the estimates of the normalizing constant.
The list is returned invisibly. If control$draw == TRUE
the function will also plot the cross-validation curve.
Author(s)
Matteo Fasiolo <matteo.fasiolo@gmail.com>.
References
Fasiolo, M., Wood, S. N., Hartig, F. and Bravington, M. V. (2016). An Extended Empirical Saddlepoint Approximation for Intractable Likelihoods. ArXiv http://arxiv.org/abs/1601.01849.
Examples
library(esaddle)
# The data is far from normal: saddlepoint is needed and we expect
# cross validation to be minimized at low "decay"
set.seed(4124)
selectDecay(decay = c(0.001, 0.01, 0.05, 0.1, 0.5, 1),
simulator = function(...) rgamma(500, 2, 1),
K = 5)
# The data is far from normal: saddlepoint is not needed and we expect
# the curve to be fairly flat for high "decay"
selectDecay(decay = c(0.001, 0.01, 0.05, 0.1, 0.5, 1),
simulator = function(...) rnorm(500, 0, 1),
K = 5)