For each DISTINCT row of fit_grid (deduped by model_spec_hash()), compiles
a prefit via brms::brm(chains = 0) against generator-supplied template
data. Returns a named list of prefit objects keyed by spec hash.
Arguments
- fitter
A BrmsFitter S7 object.
- fit_grid
A data.frame of model fitting specifications. Each row's
formula,family,prior,stanvarscolumns (list-columns) define a model spec.- data_generator
The simulation data generator function.
- data_spec_template
A named list (one row of
data_gridas a list) used to generate template data.- result_path
NULL or character path. When non-NULL,
options(cmdstanr_write_stan_file_dir)is set tofile.path(result_path, "stan_binaries")so compiled binaries persist and are shared across controller and local daemons.
Value
A named list of brmsfit prefit objects keyed by
model_spec_hash(), or NULL when precompile is FALSE.
Details
When fitter@precompile is FALSE, returns NULL immediately (the fitter falls
back to a fresh brms::brm() per task).
A compile failure is fatal: it raises a bayesim_internal_error() since the
simulation cannot proceed without a compilable model.
A model spec without an explicit prior is likewise fatal (a
bayesim_config_error(), raised before any compilation work for that spec)
unless the fitter opts in via allow_default_priors = TRUE: brms
data-derived default priors from the template dataset would otherwise stay
embedded in the compiled model reused for every task. When opted in, a
one-time notice is emitted instead.