Run a simulation self-test of a fitted RTMB estimation model
simulation_self_test.RdValidates model performance by: (1) generating n_sims new datasets
from the fitted model parameters using Simulate_Pop_Static,
(2) re-fitting the estimation model to each simulated dataset, and (3)
storing user-specified report quantities for comparison against true values.
Supports sequential or parallel execution via
future/future.apply. Likelihood weights from the original fit
are propagated into the simulation (e.g., ISS scaled by
Wt_FishAgeComps; ObsSrvIdx_SE divided by
sqrt(Wt_SrvIdx)); all weights are reset to 1 when re-fitting.
Failed replicates are silently stored as NA.
Arguments
- data
Named list of model data from a fitted RTMB object (
$data).- parameters
Named list of fitted parameter values (
$paror equivalent).- mapping
Named list of parameter factor maps (
$map).- random
Character vector of random effect names passed to RTMB.
- rep
Named list of report values from the fitted model (
obj$rep).- sd_rep
sdreportobject from the fitted model, used to extract optimized parameter values in list format viaget_optim_param_list.- n_sims
Integer. Number of simulation replicates.
- newton_loops
Integer. Number of Newton refinement steps applied during re-fitting. Default
3.- do_sdrep
Logical. Whether to compute
sdreportfor each fitted replicate. Results stored as$sd_repin the output list; failedsdreportcalls stored asNA. DefaultFALSE.- do_par
Logical. Whether to run replicates in parallel via
future::multisession. DefaultFALSE.- n_cores
Integer. Number of parallel workers. If
NULL(default),parallel::detectCores() - 1is used.- output_path
Character string. Path to save the simulated dataset RDS file. Passed to
Simulate_Pop_Static. DefaultNULL.- what
Character vector. Names of report elements (keys of
rep) to extract and store from each replicate. An error is raised if any name is not found inrep. Defaultc("SSB", "Rec").- sim_recruitment
Character. How the operating model generates recruitment.
"input"(default, and the historical behavior) feeds the estimated recruitment series in asRec_input, so every simulated replicate holds the same recruitment andrec_modelhas no effect on the data. That conditions away recruitment and tests everything downstream of it, but it cannot test the stock-recruit relationship itself, because steepness is then informed only by its penalty."model"withholds the input so recruitment is generated from the fitted curve underrec_model. Use it when the test is whether steepness andR0are recoverable.
Value
Named list with one element per entry in what, each an
array with the last dimension indexing simulation replicates (via
simplify2array). If do_sdrep = TRUE, an additional element
"sd_rep" contains a list of sdreport objects (or NA
for failed replicates).