Skip to contents

Recreates the RTMB objective from the stored data, fitted parameter state, map, and random-effect specification, then restores the optimizer parameter vector. By default the current scientific contract, parameter layout, and objective value must agree with the saved run. An implementation-checksum difference alone is permitted within an unchanged scientific contract. Rebuilt objectives are session-only and never serialized.

Usage

sbt_fit_rebuild(
  x,
  strict = TRUE,
  check_objective = TRUE,
  tolerance = 1e-06,
  silent = FALSE,
  cache = TRUE
)

Arguments

x

An sbt_fit object.

strict

If TRUE, stop on model-schema, function-signature, parameter, or objective mismatches. If FALSE, warn where a safe rebuild can still be attempted.

check_objective

Compare the rebuilt objective with opt$objective.

tolerance

Relative tolerance passed to base::all.equal() for the objective comparison.

silent

Passed to RTMB::MakeADFun().

cache

Cache the rebuilt objective for plots and subsequent model operations in the current R session.

Value

A newly constructed RTMB objective restored to the saved optimum when available. The objective is transient and is not added to the serialized sbt_fit payload.

Examples

if (FALSE) { # \dontrun{
fit <- sbt_example_fit(rebuild = FALSE)
object <- sbt_fit_rebuild(fit)
object$fn(object$par)
} # }