This function performs a leaveoneout cross validation for ABC via
subsequent calls to the function abc
. A potential use of
this function is to evaluate the effect of the choice of the tolerance
rate on the quality of the estimation with ABC.
1 2 3 4 
param 
a vector, matrix or data frame of the simulated parameter values. 
sumstat 
a vector, matrix or data frame of the simulated summary statistics. 
abc.out 
an object of class 
nval 
size of the crossvalidation sample. 
tols 
a single tolerance rate or a vector of tolerance rates. 
statistic 
a character string specifying the statistic to calculate a point
estimate from the posterior distribution of the
parameter(s). Possible values are 
prior.range 
a range to truncate the prior range. 
method 
a character string indicating the type of ABC algorithm to be
applied. Possible values are 
hcorr 
logical, if 
transf 
a vector of character strings indicating the kind of transformation
to be applied to the parameter values. The possible values are

logit.bounds 
a vector of bounds if 
subset 
a logical expression indicating elements or rows to keep. Missing
values in 
kernel 
a character string specifying the kernel to be used when

numnet 
the number of neural networks when 
sizenet 
the number of units in the hidden layer. Defaults to 5. Can be zero
if there are no skiplayer units. See 
lambda 
a numeric vector or a single value indicating the weight decay when

trace 
logical, 
maxit 
numeric, the maximum number of iterations. Defaults to 500. Applies
only when 
... 
other arguments passed to 
A simulation is selected repeatedly to be a validation simulation,
while the other simulations are used as training simulations. Each
time the function abc
is called to estimate the
parameter(s). A total of nval
validation simulations are
selected.
The arguments of the function abc
can be supplied in two
ways. First, simply give them as arguments when calling this function,
in which case abc.out
can be NULL
. Second, via an
existing object of class "abc"
, here abc.out
. WARNING:
when abc.out
is supplied, the same sumstat
and
param
objects have to be used as in the original call to
abc
. Column names of sumstat
and param
are
checked for match.
See summary.cv4abc
for calculating the prediction error
from an object of class "cv4abc"
.
An object of class "cv4abc"
, which is a list with the following
elements
call 
The original calls to 
cvsamples 
Numeric vector of length 
tols 
The tolerance rates. 
true 
The parameter values that served as validation values. 
estim 
The estimated parameter values. 
names 
A list with two elements: 
seed 
The value of 
abc
, plot.cv4abc
, summary.cv4abc
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40  require(abc.data)
data(musigma2)
## this data set contains five R objects, see ?musigma2 for
## details
## cv4abc() calls abc(). Here we show two ways for the supplying
## arguments of abc(). 1st way: passing arguments directly. In this
## example only 'param', 'sumstat', 'tol', and 'method', while default
## values are used for the other arguments.
## Number of eval. should be much more greater in realistic settings
cv.rej < cv4abc(param=par.sim, sumstat=stat.sim, nval=5,
tols=c(.1,.2,.3), method="rejection")
## 2nd way: first creating an object of class 'abc', and then using it
## to pass its arguments to abc().
##
lin < abc(target=stat.obs, param=par.sim, sumstat=stat.sim, tol=.2,
method="loclinear", transf=c("none","log"))
cv.lin < cv4abc(param=par.sim, sumstat=stat.sim, abc.out=lin, nval=5,
tols=c(.1,.2,.3))
## using the plot method. Different tolerance levels are plotted with
## different heat.colors. Smaller the tolerance levels correspond to
## "more red" points.
## !!! consider using the argument 'exclude' (plot.cv4abc) to supress
## the plotting of any outliers that mask readibility !!!
plot(cv.lin, log=c("xy", "xy"), caption=c(expression(mu),
expression(sigma^2)))
## comparing with the rejection sampling
plot(cv.rej, log=c("", "xy"), caption=c(expression(mu), expression(sigma^2)))
## or printing results directly to a postscript file...
plot(cv.lin, log=c("xy", "xy"), caption=c(expression(mu),
expression(sigma^2)), file="CVrej", postscript=TRUE)
## using the summary method to calculate the prediction error
summary(cv.lin)
## compare with rejection sampling
summary(cv.rej)

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.