View source: R/posterior_predictive_check.R
| abc_posterior_predictive_check | R Documentation |
High-level convenience wrapper for posterior predictive checks from
abc_abc() outputs.
abc_posterior_predictive_check(
config,
abc_result,
observed_df,
n_conditions = 1,
n_trials_per_condition = 500,
n_items = config$n_items,
n_conditions_per_chunk = NULL,
output_dir = NULL,
rt_facet_x = c("item_idx"),
rt_facet_y = c(),
accuracy_x = "item_idx",
accuracy_facet_x = c(),
accuracy_facet_y = c()
)
config |
Simulation configuration object. |
abc_result |
Fitted object from |
observed_df |
Observed trial-level data frame. |
n_conditions |
Number of posterior predictive conditions. |
n_trials_per_condition |
Number of trials per condition. |
n_items |
Number of items per trial. |
n_conditions_per_chunk |
Number of conditions per processing chunk. |
output_dir |
Optional output directory for simulation files. |
rt_facet_x |
Facet columns for |
rt_facet_y |
Facet columns for |
accuracy_x |
Grouping variable for |
accuracy_facet_x |
Facet columns for |
accuracy_facet_y |
Facet columns for |
This function is for teaching and quick demonstrations.
It is intentionally specific to one input shape (an abc object).
For step checks, follow these functions:
abc_posterior_bootstrap(), update_config_from_posterior(),
and run_simulation().
This wrapper is mainly a teaching tool. It provides a compact end-to-end posterior predictive workflow, but it intentionally hides several modeling choices by collapsing the posterior to a single summary and then simulating from that reduced representation.
For more serious work, manual posterior predictive simulation is preferred.
The recommended workflow is to draw posterior parameter values explicitly
with abc_posterior_bootstrap(), inspect or modify those draws as
needed, rebuild a simulation configuration explicitly with
new_simulation_config so the parameter structure is fully under
your control, run the simulation with run_simulation(), and then
compare the simulated output with the observed data using plotting or
summary functions. update_config_from_posterior() can still be useful
for quick checks, but rebuilding the config is the safer option when you
need to know exactly how posterior values are mapped back into the model.
Following the steps manually makes each assumption visible, including which
posterior draw was used, how parameter values entered the simulation config,
and how the posterior predictive data were generated.
invisible(NULL). This function is used for plotting side
effects only and prints RT and accuracy plots directly.
# Load example simulation config, fitted ABC model, and observed data
base_dir <- system.file("extdata", "rdm_minimal", package = "eam")
sim_output <- load_simulation_output(file.path(base_dir, "simulation"))
abc_model <- readRDS(file.path(base_dir, "abc", "abc_neuralnet_model.rds"))
obs_df <- read.csv(file.path(base_dir, "observation", "observation_data.csv"))
# Run a high-level posterior predictive check
abc_posterior_predictive_check(
config = sim_output$simulation_config,
abc_result = abc_model,
observed_df = obs_df,
n_conditions = 1,
n_trials_per_condition = 500,
rt_facet_x = c("item_idx"),
rt_facet_y = c(),
accuracy_x = "item_idx",
accuracy_facet_x = c("group"),
accuracy_facet_y = c()
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.