With only processed data, or preprocessing inputs supplied through
data_in, creates the first stage of the standard workflow:
sbt_fit(data), sbt_optimise(), then sbt_mcmc(). data_in is passed to
get_data() for the current model or get_data_v1() for the frozen V1
model. Missing parameters, priors, map, and bounds are resolved and stored
when the objective is first built. The existing completed-fit form remains
supported by supplying both obj and opt; that transient objective is
used to capture the fitted state but is never serialized.
Usage
sbt_fit(
data = NULL,
obj = NULL,
bounds = NULL,
control = NULL,
opt = NULL,
estimability = NULL,
diagnostics = list(),
metadata = list(),
mcmc = NULL,
mcmc_settings = list(),
keep_mcmc_raw = FALSE,
full_mcmc_mle = FALSE,
makeadfun_args = list(),
optimizer = "nlminb",
model = c("sbt_model", "sbt_model_v1"),
data_in = NULL
)Arguments
- data
Processed model data returned by
get_data()and used to constructobj. Supply exactly one ofdataanddata_in.- obj
Fitted RTMB objective. This is a transient input and is never serialized.
- bounds
Optional parameter bounds used for optimization.
- control
Optional optimizer control list.
- opt
Optimizer result, normally returned by
stats::nlminb().- estimability
Optional result from
check_estimability(). Only a compact summary is retained.- diagnostics
Optional named list of additional fit diagnostics.
- metadata
Optional named list of user metadata.
- mcmc
Optional SparseNUTS-style fit, posterior sample array, or matrix. Only portable sample and diagnostic fields are retained.
- mcmc_settings
Optional named list recording sanitized sampler settings.
- keep_mcmc_raw
If
TRUE, also retain the original MCMC object when it is portable. The normalizedsbt_mcmcfields remain canonical.- full_mcmc_mle
If
TRUE, retain every element of the sampler's MLE payload. The default keeps only estimates, standard errors, and correlations.- makeadfun_args
Optional named list of additional arguments needed to rebuild
RTMB::MakeADFun(). Reserved core arguments are not allowed.- optimizer
Character name of the optimizer used.
- model
Model function identifier:
"sbt_model"or"sbt_model_v1".- data_in
Optional preprocessing input list passed to
get_data()orget_data_v1(), according tomodel.
Value
An object of class sbt_fit containing portable state only. Principal
components are data, parameters, map, bounds, and configuration
for the scientific setup; fit and mcmc for fitted results;
posterior_summaries and msy for derived outputs; and validation,
status, and provenance for acceptance and reproducibility metadata.
See also
Other fit workflow:
check_mcmc(),
check_mle(),
sbt_add_bounds(),
sbt_add_map(),
sbt_add_msy(),
sbt_add_parameters(),
sbt_add_priors(),
sbt_build_object(),
sbt_example_fit(),
sbt_fit_compatibility(),
sbt_fit_io,
sbt_fit_rebuild(),
sbt_fit_report(),
sbt_fit_validate(),
sbt_fit_validation(),
sbt_mcmc(),
sbt_obj(),
sbt_optimise()
Examples
data <- sbt_example_data()
fit <- sbt_fit(data, metadata = list(run = "documentation example"))
fit
#> <sbt_fit>
#> Model: sbt_model (schema 2)
#> sbt version: 3.0.0
#> Stage: data
#> Estimability: not run
#> MCMC: not stored
#> MSY: 0 stored calculations
#> Next: sbt_optimise() or configuration setters
#> Created: 2026-08-26 16:26:33 UTC
fit$configuration$origins
#> $parameters
#> [1] "unresolved"
#>
#> $priors
#> [1] "supplied"
#>
#> $map
#> [1] "unresolved"
#>
#> $bounds
#> [1] "unresolved"
#>
#> $random
#> [1] "default"
#>
#> $makeadfun_args
#> [1] "default"
#>
