Conduct a Simulation Self Test
simulation_self_test.Rd
This function runs a self test of the fitted RTMB model by simulating new datasets under the fitted parameters, refitting the model, and comparing estimated outputs to the true values used for simulation. It can be run sequentially or in parallel.
Usage
simulation_self_test(
data,
parameters,
mapping,
random,
rep,
sd_rep,
n_sims,
newton_loops = 3,
do_sdrep = FALSE,
do_par = FALSE,
n_cores = NULL,
output_path = NULL,
what = c("SSB", "Rec")
)
Arguments
- data
A list containing model data from an RTMB object.
- parameters
A list of fitted parameter values from an RTMB object.
- mapping
A list specifying parameter mappings from an RTMB object.
- random
Character vector specifying random effects.
- rep
A list of report values from an RTMB object (`$rep`).
- sd_rep
An `sdreport` object from RTMB summarizing parameter uncertainty.
- n_sims
Integer. Number of simulation replicates to run.
- newton_loops
Integer. Number of Newton loops used in model fitting (default: `3`).
- do_sdrep
Logical. If `TRUE`, compute `sdreport` for each fitted replicate (default: `FALSE`).
- do_par
Logical. If `TRUE`, run simulations in parallel (default: `FALSE`).
- n_cores
Integer. Number of cores to use for parallelization (default: `NULL` = detect automatically).
- output_path
Optional file path. If provided, the simulated datasets are written to this location.
- what
Character vector. Names of report elements in `rep` to extract and store for each replicate.
Value
A list with elements corresponding to the requested `what` values, each containing an array of simulation results across replicates. If `do_sdrep = TRUE`, an additional element `"sd_rep"` is included with the list of `sdreport` objects (or `NA` if a replicate fails).
See also
Other Simulation Setup:
Setup_Sim_Biologicals()
,
Setup_Sim_Containers()
,
Setup_Sim_Dim()
,
Setup_Sim_Fishing()
,
Setup_Sim_Rec()
,
Setup_Sim_Survey()
,
Setup_Sim_Tagging()
,
Setup_sim_env()
,
Simulate_Pop_Static()
,
run_annual_cycle()
,
simulation_data_to_SPoRC()
Examples
if (FALSE) { # \dontrun{
# Run a simple self test with 10 simulations, extracting SSB
res <- simulation_self_test(
data = model$data,
parameters = model$parameters,
mapping = model$mapping,
random = model$random,
rep = model$rep,
sd_rep = model$sd_rep,
n_sims = 10,
what = "SSB"
)
str(res$SSB) # look at simulated SSB arrays
} # }