Computes per-condition aggregates of the wide summary tibble: mean and median of each metric column, Monte Carlo standard errors (MCSE), replicate counts, and failure/convergence-failure rates. Returns a tidy tibble with one row per condition.
Aggregation follows each metric's declared summary_type (E4; see
Metric): "mean" columns get a sd / sqrt(n) MCSE, "proportion"
columns (e.g. coverage) get sqrt(p(1-p) / n), and "none" columns
(e.g. SBC ranks) are excluded from aggregation. Columns from unknown or
user-defined sources default to "mean". MCSE formulas follow rsimsum
(Gasparini, 2018).
Wide summaries: several metrics legitimately flatten to dozens of columns
each, so the default aggregation can return 100+ columns. Nothing is ever
dropped or truncated. Narrow the output with the metrics argument, and
discover a single metric's flattened columns with metric_cols(). In
interactive sessions only, a wide default call prints a one-line hint
pointing at these; programmatic and noninteractive use is always silent.
Arguments
- result
A
bayesim_simulation_resultobject (usesresult$summary), or a data.frame/tibble of per-task metrics. Passing the full result is preferred: it carries the metrics'summary_typedeclarations.- by
Character vector of grouping columns (conditions). Defaults to the
data_*/fit_*grid columns found in the summary plus any other non-numeric condition columns (excludingtask_idandstatus).- metrics
Character vector of metric columns to aggregate. Defaults to all numeric columns not in
byand not metadata (task_id,rep_idx,status,*timing*).
Value
A tibble with one row per condition: the by columns, then for each
metric <m>_n_used, <m>_mean, <m>_median, <m>_sd, <m>_mcse, plus
n_reps, n_failed, failure_rate. <m>_n_used is the number of finite
values used for that metric; failed or non-finite metric values do not
contribute to its aggregate.
Examples
if (FALSE) { # \dontrun{
result <- run_simulation(config, progress = FALSE)
summarize_simulation(result)
summarize_simulation(result, by = "model", metrics = "rmse__value")
} # }