cv4postpr {abc}  R Documentation 
Leaveoneour cross validation for model selection ABC
Description
This function performs a leaveoneout cross validation for model
selection with ABC via subsequent calls to the function
postpr
.
Usage
cv4postpr(index, sumstat, postpr.out = NULL, nval, tols, method,
subset = NULL, kernel = "epanechnikov", numnet = 10, sizenet = 5, lambda
= c(0.0001,0.001,0.01), trace = FALSE, maxit = 500, ...)
Arguments
index 
a vector of model indices. It can be character or
numeric and will be coerced to factor. It must have the same length
as the number of rows in 
sumstat 
a vector, matrix or data frame of the simulated summary statistics. 
postpr.out 
an object of class 
nval 
the size of the crossvalidation sample for each model. 
tols 
a single tolerance rate or a vector of tolerance rates. 
method 
a character string indicating the type of simulation required.
Possible values are 
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 
Details
For each model, a simulation is selected repeatedly to be a validation
simulation, while the other simulations are used as training
simulations. Each time the function postpr
is called to
estimate the parameter(s).
Ideally, we want nval
to be equal to the number of simulations
for each model, however, this might take too much time. Users are
warned not to choose a too large number of simulations (especially
when the neural networks are used). Beware that the actual number of
crossvalidation estimation steps that need to be performed is
nval
*the number of models.
The arguments for the function postpr
can be supplied in
two ways. First, simply give them as arguments when calling this
function, in which case postpr.out
can be NULL
. Second,
via an existing object of class "postpr"
, here
postpr.out
. WARNING: when postpr.out
is supplied, the
same sumstat
and param
objects have to be used as in the
original call to postpr
. Column names of sumstat
and param
are checked for match.
See summary.cv4postpr
for calculating the prediction
error from an object of class "cv4postpr"
and
plot.cv4postpr
for visualizing the misclassification of
the models using barplots.
Value
An object of class "cv4postpr"
, which is a list with the following
elements
call 
The original calls to 
cvsamples 
Numeric vector of length 
tols 
The tolerance rates. 
true 
The true models. 
estim 
The estimated model probabilities. 
method 
The method used. 
names 
A list of two elements: 
seed 
The value of 
See Also
postpr
, summary.cv4postpr
, plot.cv4postpr
Examples
require(abc.data)
data(human)
###Reduce the sample size of the simulations to reduce the running time.
###Do not do that with your own data!
ss<c(1:1000,50001:51000,100001:101000)
cv.modsel < cv4postpr(models[ss], stat.3pops.sim[ss,], nval=5, tols=c(.05,.1), method="rejection")
summary(cv.modsel)
plot(cv.modsel, names.arg=c("Bottleneck", "Constant", "Exponential"))