On this page

Summarize the bias, root mean square error (RMSE), interval coverage, fitting failures and run time of simulation fits, with the denominator of each statistic.

Usage

summarize_simulations(
  fits,
  truth,
  quantities = c("SSB", "Rec"),
  conf_level = 0.95,
  interval = c("lognormal", "wald")
)

Arguments

ArgumentDefaultDescription
fitsrequired

A named list of fits or error records, such as the output of sim_model().

truthrequired

A list with the same replicate names as fits; each element holds year and a vector of true values for every requested quantity. The coordinates must match the fitted time steps exactly; values are never recycled.

quantitiesc("SSB", "Rec")

Distinct aggregate time series to assess, from SSB, Rec, B, N, CN and CB. Only ALSCL reports CB; a quantity that no fit with a report holds is an error. Letter case does not matter.

conf_level0.95

Nominal confidence level of the intervals built from the reported standard errors, strictly between zero and one; the returned coverage is the observed share of usable intervals that contain the truth.

intervalc("lognormal", "wald")

Form of the interval whose coverage is reported. "lognormal" (default) is exp(log(estimate) +/- z * SE / estimate), as in extract_estimates(), the plots of the package and self_test(); "wald" is estimate +/- z * SE. Letter case does not matter.

Value

A list with summary (statistics pooled over replicates and time steps by quantity), replicates (numerical status, elapsed seconds and errors of each replicate), estimates (every replicate, time step, estimate and truth, failed fits included) and conf_level (the confidence level used). summary_converged repeats the statistics of summary for all converged fits, whether or not they pass the numerical checks. failures counts the replicates that fail the numerical checks by reason; n_replicates is the number of replicates with that reason and n_sole the number for which it is the only reason. In replicates, converged marks converged fits and failure_reasons lists the reasons of each replicate. In estimates, converged and covered_converged give the same information for each estimate pair.

Details

Bias and RMSE (root mean square error) use numerically valid estimate pairs, and coverage also requires finite reported standard errors. The result reports the attempted and valid replicates, points and intervals and the failure_rate; read the statistics together with the failure rate. A missing standard error does not count as a failed interval. Relative bias excludes points with a true value of zero. F is not offered, because summarizing F over age classes or length bins needs its own definition and uncertainty.

The time coordinates and each quantity must be one-dimensional real numeric vectors. Matrices and arrays are rejected even when their total length matches the number of time steps. Aggregate quantities at age or length to the intended time series before the call.

A converged fit returned no error and has a finite objective and a maximum absolute gradient below 0.001, the gradient threshold of the numerical checks. Such a fit can still fail the numerical checks, for example because an estimated correlation or SD lies at a natural-scale boundary, a parameter is at its limit in practice (the reason "parameter at its limit in practice" in failures) or the Hessian is not positive definite. Compare summary with summary_converged to see whether the fits excluded by the numerical checks change bias, RMSE or coverage, and read failures before treating the failure rate as a convergence rate.

Additional details from R help

Fits that fail the numerical checks stay in the output but do not enter bias, RMSE or coverage, so read the summary together with the failure rate. Missing uncertainty does not count as a failed interval. A converged fit returned no error and has a finite objective and a maximum absolute gradient below 0.001, the gradient threshold of the numerical checks. Such a fit can still fail the checks, for example because an estimated correlation or standard deviation lies at a natural-scale boundary or the Hessian is not positive definite. Compare summary with summary_converged to see whether the fits that fail the checks change bias, RMSE or coverage, and read failures before treating the failure rate as a convergence rate. Relative bias leaves out true values of zero. F and quantities by age or length are not summarized, because a summary over ages or lengths needs its own definition and uncertainty. Replicates simulated from an operating model are not a parametric bootstrap of a fit.

Examples

Run the setup before the example. Fitting examples require an R-compatible C++ toolchain; simulation and export examples may write files.

Example setup
library(ALSCL)
library(ggplot2)
library(patchwork)
data("YTF_example")
x <- YTF_example
inputs <- x[c("data.CatL", "data.wgt", "data.mat")]
dat <- x$data.CatL
x <- YTF_example
a <- run_acl(x, silent = TRUE)
fits <- list(example = a)
truth <- list(example = list(year = as.numeric(names(x$data.CatL)[-1]),
  SSB = x$truth$SSB, Rec = x$truth$Rec))
performance <- summarize_simulations(fits, truth)
performance$summary
performance$replicates

See also

Search documentation