Draws a posterior for each row of x_all, insists on the full
n_posterior_samples count via diagnostic_draws(), and hands the result
to f(draws, i) for whichever per-trial metric the caller wants: sbc()
returns a rank row, tarp() a scalar coverage value.
Arguments
- fit
An
nsbi_npe,nsbi_nleornsbi_nrefit.- x_all
Matrix of simulated data, one row (one trial) per observation.
- n_posterior_samples
Posterior draws requested per trial.
- label
Progress-bar label.
- f
function(draws, i), the per-trial metric.- ...
Passed to
posterior().
Value
A list with results (a list of length nrow(x_all), one f()
return value per trial) and n_posterior_samples (the draw count trials
were actually scored against).
Details
The denominator a caller bins or normalizes against (sbc()'s rank scale,
via the p-value bins and expected_coverage()) is read back from how many
draws a trial actually returned, not trusted from the n_posterior_samples
argument – so if a future change ever lets a short draw through instead of
erroring, the diagnostic is still scored on the scale it was actually drawn
on rather than the one it was asked for.
finally, not on.exit(): this block runs inside
progressr::with_progress(), so on.exit() would attach to the promise's
forcing frame and close the bar before the loop starts (see
run_simulator() in R/parallel.R).
