Skip to contents

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 list containing the data created using the get_data function.

parameters

A list containing the parameter inputs.

grid

A list of fitted model objects from run_grid, or a data.frame containing sampled grid-cell parameter values.

grid_parameters

A list of parameter inputs for each grid cell, created using get_grid. Required when grid is a list.

grid_cells

A list with element grid_cells (integer vector) from sample_grid.

target_sample_names

Optional character vector of parameter names to include when grid is a data.frame.

parameter_columns

Named character vector mapping data-frame columns to tmbfit parameter names. Values are log-transformed.

template

Optional tmbfit object 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 containing fitted_par.

source_map

Parameter map under which fitted_parameters were 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.

Value

A tmbfit object containing sampled grid values.

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.