Builds a balanced posterior sample from saved grid-cell MCMC files and stores
the combined draws in a tmbfit object. Fixed grid parameters such as
h, psi, m0, and m10 are inserted into the sample
matrix when the corresponding log-parameter columns are requested.
Usage
grid_mcmc_to_tmbfit(
grid_files,
grid_values = NULL,
target_sample_names = NULL,
target_par_names = NULL,
allow_mixed_run_signatures = FALSE,
n_draws = 2000L,
seed = 1L
)Arguments
- grid_files
Character vector of canonical grid-cell
.sbt.rdsfiles. Legacy grid files are rejected because they lack the state diagnostics and scientific signatures required for combination.- grid_values
Optional
data.frameof grid-cell values used when saved files do not containgrid_cell.- target_sample_names
Character vector of sample columns to keep.
- target_par_names
Character vector of parameter columns that must be complete in the combined posterior. The default uses
target_sample_namesexcluding sampler diagnostics such aslp__.- allow_mixed_run_signatures
Logical. The default,
FALSE, requires every cell to share one sampler-run signature. Set toTRUEonly when the calling workflow has independently validated an explicitly approved mixed-source selection. Grid-input and model signatures always remain uniform.- n_draws
Integer number of balanced draws to take across grid cells.
- seed
Integer seed used for draw allocation and within-cell sampling.
Value
A list with fit (a tmbfit object),
draw_metadata, draw_plan, samples, and the verified
source_signatures. Canonical cells must share grid-input and model
signatures and must have matching retained-posterior payload checksums.
Run signatures are common unless an approved caller explicitly enables a
mixed-source selection.
Details
This converter revalidates canonical structure, source signatures,
posterior payloads, and biological states. It does not itself enforce the
MLE-gradient, estimability, R-hat, ESS, divergence, or tree-depth
acceptance thresholds. The calling production workflow must accept every
cell's diagnostic row before combination. Supplying seed changes
the global random-number state.
