View source: R/posterior_predictive_check.R
| abi_posterior_predictive_check | R Documentation |
High-level convenience wrapper for posterior predictive checks from ABI-trained estimators.
abi_posterior_predictive_check(
config,
trained_estimator,
estimator_type = c("point", "posterior"),
observed_df,
Z = NULL,
posterior_dataset_id = 1,
posterior_n_samples = 1000,
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. |
trained_estimator |
Trained ABI estimator from |
estimator_type |
Character string: |
observed_df |
Observed trial-level data frame. |
Z |
Input data for ABI estimation/sampling. If |
posterior_dataset_id |
Dataset id used when |
posterior_n_samples |
Number of samples when |
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 estimator workflow at a time,
selected by estimator_type.
For step checks, follow these functions:
abi_estimate() or abi_sample_posterior(), then
update_config_from_posterior(), and run_simulation().
This wrapper is mainly a teaching tool. It provides a compact end-to-end posterior predictive workflow for ABI, but it intentionally hides several modeling choices behind a single helper call.
For more serious work, manual posterior predictive simulation is preferred.
The recommended workflow is to obtain parameter values explicitly with
abi_estimate() for point estimators or abi_sample_posterior()
for posterior estimators, inspect or summarise those values, 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 simulated and 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 inferred values are mapped
back into the model. Following the steps manually makes each assumption
visible, including which ABI output was used, how posterior summaries were
constructed, 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.
## Not run:
# Load an observed dataset and a trained ABI estimator prepared in your environment
observed_data <- sim_output$open_dataset() |>
dplyr::filter(chunk_idx == 1, condition_idx == 1) |>
dplyr::collect()
# Point-estimate workflow
abi_posterior_predictive_check(
config = sim_config,
trained_estimator = trained_point_estimator,
estimator_type = "point",
observed_df = observed_data,
Z = abi_input$Z_test[[1]],
rt_facet_x = c("item_idx"),
rt_facet_y = c(),
accuracy_x = "item_idx",
accuracy_facet_x = c("ndt_beta_0"),
accuracy_facet_y = c()
)
# Posterior-sampling workflow
abi_posterior_predictive_check(
config = sim_config,
trained_estimator = trained_posterior_estimator,
estimator_type = "posterior",
observed_df = observed_data,
Z = abi_input$Z_test,
posterior_dataset_id = 1,
posterior_n_samples = 1000,
rt_facet_x = c("item_idx"),
rt_facet_y = c(),
accuracy_x = "item_idx",
accuracy_facet_x = c("ndt_beta_0"),
accuracy_facet_y = c()
)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.