On this page

On this page you run a retrospective analysis of ACL and ALSCL on the synthetic YTF example. Each model is refitted after removing the last one, two and three time steps, each peel is compared with the full fit, and Mohn's rho summarizes the revisions. You need the package installed (Install ALSCL); each analysis runs four fits, and Run a retrospective analysis explains the function and its tables. At the end you have both results, their figures and a saved folder.

1. Run the ALSCL retrospective analysis

library(ALSCL)
data("YTF_example")
x <- YTF_example
rb <- retro_alscl(x, nyear = 3, train_times = 2, silent = TRUE)
rb$fit_diagnostics
rb$rho_text
plot_retro(rb, rho_digits = 3)

retro_alscl() reads the input bundle x as run_alscl(x) does, fits the full series and then three peels: peel 1 removes the last time step, peel 2 the last two, peel 3 the last three. nyear is the number of peels. Each peel removes one more time step, which is one quarter for quarterly data unless peel_step = 4 asks for annual peels, and every peel must keep at least two time steps. Arguments in the call reach every fit, and ncores on this call runs the peels in parallel (Run a retrospective analysis). Read rb$fit_diagnostics first. It has one row per fit (Peel 0 is the full fit) with the numerical checks and any error. rb$rho_text$Rho gives Mohn's rho per quantity only when the full fit and all peels passed the checks and every terminal comparison is finite with a nonzero reference; otherwise it is NA with a warning, rb$errors lists the failed fits and rb$raw_rho_text keeps the unchecked mean for diagnosis. With the teaching data the four fits take about six to ten minutes, depending on the computer and its load, and all pass (retro_diagnostics_ALSCL.csv).

Bundled ALSCL retrospective example

Each line is one fit, colored by its last time step (under the default style the full fit is orange and the peels are grey); the open point marks the terminal estimate that rho compares with the full fit at the same time step. Lines on the full fit for most of the series that split only in the last years, as here, show that the largest visible revisions are near the end of the series. In the recorded run rho is 0.022 for biomass, 0.010 for spawning stock biomass (SSB), 0.016 for abundance and −0.0051 for recruitment (rho_ALSCL.csv); a positive value means the shorter fits gave higher terminal estimates on average, and a negative value lower ones. Terms of opposite sign cancel in the mean, so read rb$rho_by_peel as well. If no fit produced estimates, plot_retro() stops and asks you to read fit_diagnostics and errors.

2. Run the ACL analysis and compare the two models

ra <- retro_acl(x, nyear = 3, train_times = 2, silent = TRUE)
ra$fit_diagnostics
ra$rho_text
plot_retro(ra, rho_digits = 3)

Synthetic YTF: ACL retrospective trajectories

Both models use the same observations and three peels. For biomass, SSB and total abundance, ACL has the smaller absolute Mohn's rho (the signed ACL values are 0.0054, 0.0070 and −0.0018, respectively). For recruitment, rho is −0.0105 for ACL and −0.0051 for ALSCL. In both models the shorter fits therefore gave lower terminal recruitment estimates on average, and the absolute rho is larger for ACL. Inspect the individual terminal comparisons in rho_by_peel for their signs and magnitudes. ACL results · ALSCL results.

3. Save the record

dir.create("my_retrospective", showWarnings = FALSE)
write.csv(rb$results, "my_retrospective/alscl_trajectories.csv", row.names = FALSE)
write.csv(rb$rho_text, "my_retrospective/alscl_rho.csv", row.names = FALSE)
write.csv(rb$fit_diagnostics, "my_retrospective/fit_diagnostics.csv", row.names = FALSE)
write.csv(rb$rho_by_peel, "my_retrospective/rho_by_peel.csv", row.names = FALSE)
write.csv(ra$rho_text, "my_retrospective/acl_rho.csv", row.names = FALSE)
p_retro <- plot_retro(rb, rho_digits = 3)
acl_save_plot(p_retro, "my_retrospective/alscl.png")
saveRDS(list(ACL = ra, ALSCL = rb, fit_args = x$fit_args,
             fit_config = x$fit_config), "my_retrospective/results.rds")
writeLines(capture.output(sessionInfo()), "my_retrospective/session.txt")

The results are tables without a live TMB object, so saveRDS() keeps them whole and plot_retro() redraws them in a new session. acl_save_plot() saves a package plot at 300 dpi in the size that acl_figure_size() recommends for its layout. The folder records every fit's series, rho per quantity and peel, the numerical checks, the figure, the settings of x and the session information. For your own assessment, run the analysis with the settings of the fit you report, so that the peels differ from the full fit only in the removed observations; with quarterly data the four peels of nyear = 4 remove one to four quarters.

What next

What you want to do Read
Read every returned table and the rho formula Run a retrospective analysis
Repair a peel that failed the numerical checks Judge whether a fit can be used
Score predictions of the withheld time steps Can the fitted model reproduce observations and predict withheld time steps?
Run the peels on more cores Speed settings

Search documentation