This function is a convenience wrapper around the functions cv4postpr
and anc::cv4abc
from the R package abc
Arguments
- x
A list of objects of the class
demografr_sims_abc
(each representing an ABC inference result) for the function abc::cv4postpr, or an objectdemografr_abc.abc
for the functionabc::cv4abc
- nval, tols, method
Required arguments of
abc::cv4postpr
- ...
Other optional arguments to be passed to
abc::cv4postpr
Examples
#####################################################
# can we even distinguish between competing models?
if (FALSE) { # \dontrun{
# read a list of three different ABC models
models <- lapply(c("X", "Y", "Z"), function(i) { readRDS(url(paste0(
"raw.githubusercontent.com/bodkan/demografr/refs/heads/main/inst/examples/downstream_abc",
i, ".rds"
))) })
# note that each element of the list is, indeed, a demografr ABC result
models[[1]]
# run cross validation to find out if we have even the power to distinguish
# our competing models(see the abc package vignette for interpretation)
cv_models <- cross_validate(models, nval = 10, tols = c(0.005, 0.01, 0.05), method = "neuralnet")
cv_model
#####################################################
# can our model even estimate the parameters?
# read an example result of an ABC inference
abc_res <- readRDS(system.file("examples/basics_abc.rds", package = "demografr"))
# perform cross-validation
cv_params <- cross_validate(abc_res, nval = 10, tols = c(0.005, 0.01, 0.05),
method = "neuralnet")
cv_params
} # }