Converts either a historical in-memory grid, a coordinate-only data frame,
or saved fitted MLE-grid states to a tmbfit. When
fitted_parameters, source_map, and target_map are
supplied, every sampled row is reconstructed by parameter structure and the
result contains the complete active parameter layout required by the target
model object.
Usage
grid_to_tmbfit(
data,
parameters,
grid,
grid_parameters = NULL,
grid_cells,
target_sample_names = NULL,
parameter_columns = c(h = "par_log_h", psi = "par_log_psi", m0 = "par_log_m0", m10 =
"par_log_m10", fixed_m0 = "par_log_m0", fixed_m10 = "par_log_m10"),
template = NULL,
fitted_parameters = NULL,
source_map = NULL,
target_map = NULL,
objective_tolerance = 1e-08,
cores = 1L
)Arguments
- data
A
listcontaining the data created using theget_datafunction.- parameters
A
listcontaining the parameter inputs.- grid
A
listof fitted model objects fromrun_grid, or adata.framecontaining sampled grid-cell parameter values.- grid_parameters
A
listof parameter inputs for each grid cell, created usingget_grid. Required whengridis a list.- grid_cells
A
listwith elementgrid_cells(integervector) fromsample_grid.- target_sample_names
Optional character vector of parameter names to include when
gridis adata.frame.- parameter_columns
Named character vector mapping data-frame columns to tmbfit parameter names. Values are log-transformed.
- template
Optional
tmbfitobject used as a template.- fitted_parameters
Optional list aligned with the rows of a data-frame
grid. Each element can be a named fitted active parameter vector or a state-record list containingfitted_par.- source_map
Parameter map under which
fitted_parameterswere estimated.- target_map
Parameter map defining the active parameter layout required in the returned
tmbfit; for example, the map used by a projection objective.- objective_tolerance
Relative tolerance used to require that source- and target-map objectives agree at every reconstructed state.
- cores
Positive integer number of forked fitted-state conversion workers on non-Windows platforms.
Details
The fitted-state data-frame route is the current deterministic-grid
conversion and is suitable for downstream model
evaluation and projections: it uses RTMB::MakeADFun() and
parList() to reconstruct by named parameter structure, adds
lp__, and verifies objective equivalence. The coordinate-only
data-frame route remains intended for plotting only. The historical list
route reconstructs samples by parameter positions and is retained only for
compatibility. Fitted state records must first pass
validate_mle_grid_state_records(). This function does not replace the
calling workflow's MLE, provenance, or biological-state acceptance gates.
