View source: R/plot_cv_recovery.R
| plot_cv_recovery | R Documentation |
Visualize parameter recovery from cross-validation results, showing estimated vs. true parameter values and residual distributions for each parameter.
plot_cv_recovery(data, ...)
## S3 method for class 'cv4abc'
plot_cv_recovery(data, ...)
## S3 method for class 'eam_abi_assess'
plot_cv_recovery(data, ...)
## S3 method for class 'eam_abi_posterior_samples'
plot_cv_recovery(data, trained_estimator = NULL, theta = NULL, ...)
data |
An |
... |
Additional arguments:
|
trained_estimator |
Optional. A trained estimator object returned by
|
theta |
Optional. A matrix of true parameter values with parameters as rows
and datasets as columns. Column count must match the number of unique
|
Invisibly returns 'NULL'. Called for its side effect of producing plots.
plot_cv_recovery.cv4abc, plot_cv_recovery.eam_abi_assess,
plot_cv_recovery.eam_abi_posterior_samples
# Load CV output from saved file
cv_file <- system.file(
"extdata", "rdm_minimal", "abc", "cv", "neuralnet.rds",
package = "eam"
)
abc_neuralnet_cv <- readRDS(cv_file)
# Plot parameter recovery
plot_cv_recovery(
abc_neuralnet_cv,
n_rows = 2,
n_cols = 1,
resid_tol = 0.99
)
## Not run:
# Train a posterior estimator
trained_estimator <- abi_train(
estimator = posterior_estimator,
abi_input = abi_input,
epochs = 50
)
# Sample from posterior using test data (default)
posterior_samples <- abi_sample_posterior(
trained_estimator = trained_estimator,
N = 1000
)
# Plot recovery using trained_estimator to get true values
plot_cv_recovery(
posterior_samples,
trained_estimator = trained_estimator
)
# Alternatively, provide true parameter values directly
plot_cv_recovery(
posterior_samples,
theta = abi_input$theta_test
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.