Model Diagnostics for FLa4a

a4adiags is an open-source R package that provides a number of extra diagnostics for a4a stock assessment models, complementary of those already availabel in FLa4a.

(Carvalho et al. 2020)

It makes use of the S4 classes and methods developed by the FLR project (http://flr-project.org/R, (Kell et al. 2007)), which simplify the development, testing and use of statistical and simulation models for fisheries management advice.

Diagnostics in FLa4a

Example model fit

library(a4adiags)
#> Loading required package: ggplot2
#> Loading required package: FLCore
#> Loading required package: lattice
#> Loading required package: iterators
#> FLCore (Version 2.6.20.9308, packaged: 2024-11-14 23:24:18 UTC)
#> Loading required package: ggplotFL
#> Loading required package: FLa4a
#> Loading required package: triangle
#> This is FLa4a 1.9.0. For overview type 'help(package="FLa4a")'
library(FLa4a)
data("sol274")

# fmodel, mimics AAP

fmod <- ~te(replace(age, age > 8, 8), year, k = c(4, 22)) +
  s(replace(age, age > 8, 8), k=4) +
  s(year, k=22, by=as.numeric(age==1))

# qmodel (GAM, SNS)

qmod <- list(~s(age, k=3), ~s(age, k=3))

# vmodel (catch, GAM, SNS)

vmod <- list(
  ~s(age, k=3),
  ~s(age, k=3),
  ~s(age, k=3))

# srmodel

srmod <- ~factor(year)

# fit

fit <- sca(stock, indices[c("BTS", "SNS")],
  srmodel=srmod, fmodel=fmod, qmodel=qmod, vmodel=vmod)

Prediction skill by hindcasting cross-validation

library(doParallel)
ncores <- floor(detectCores() * .75)

if(Sys.info()["sysname"] %in% c("Darwin", "Linux")) {
  registerDoParallel(ncores)
} else if(Sys.info()["sysname"] %in% c("Windows")) {
  cl <- makeCluster(ncores)
  clusterEvalQ(cl = cl, expr = { library(FLa4a); library(FLasher) })
  registerDoParallel(cl)
}
xval <- a4ahcxval(stock, indices, nyears=5, nsq=3, srmodel=srmod, fmodel=fmod,
  qmodel=qmod, vmodel=vmod)
#> Warning: executing %dopar% sequentially: no parallel backend registered
mase(indices, xval$indices[-1])
#>       BTS       SNS 
#> 0.5362673 0.3369608
plotXval(xval$indices)

plotXval(indices, xval$indices)

plotXval(indices, xval$indices[-1])

plotXval(xval$indices[["data"]], xval$indices[-1])

plotXval(xval$indices[["data"]], xval$indices)

plot(xval$stocks)

mohnMatrix(xval$stocks, ssb)
#>          base       -1       -2       -3       -4       -5
#> 2012 28461.57 29865.56 30195.50 29562.62 30032.85 29778.79
#> 2013 34081.72 35428.59 35130.41 34567.14 34485.31 31997.13
#> 2014 30423.14 31155.84 31681.66 31191.75 29685.55 26520.74
#> 2015 28567.41 29631.27 30793.79 30899.53 28432.62       NA
#> 2016 35520.25 36541.37 38345.49 39220.43       NA       NA
#> 2017 33901.84 36332.29 38558.82       NA       NA       NA
#> 2018 30749.29 33455.18       NA       NA       NA       NA
#> 2019 30888.28       NA       NA       NA       NA       NA
icesAdvice::mohn(mohnMatrix(xval$stocks, ssb))
#> [1] 0.03930931
icesAdvice::mohn(mohnMatrix(xval$stocks, fbar))
#> [1] 0.0005614943

(Kell_2016?)

(Hyndman_2006?)

Runs test

plotRunstest(fit, indices)

plotRunstest(fit, indices, combine=FALSE)

More information

  • You can submit bug reports, questions or suggestions on FLPKG at the FLPKG issue page 1.
  • Or send a pull request to https://github.com/flr/a4adiags/
  • For more information on the FLR Project for Quantitative Fisheries Science in R, visit the FLR webpage 2.
  • The latest version of a4diags can always be installed using the devtools package, by calling
    library(devtools)
    install_github('flr/a4adiags')

Software Versions

  • R version 4.4.2 (2024-10-31)
  • FLCore: 2.6.20.9308
  • FLa4a: 1.9.0
  • ggplotFL: 2.7.0.9133
  • a4adiags: 0.1.6
  • Compiled: Wed Nov 20 05:37:29 2024
  • Git Hash: b551b57

Author information

Iago MOSQUEIRA. Wageningen Marine Research (WMR). Haringkade 1, Postbus 68. 1976CP, IJmuiden. The Netherlands

Henning WINKER. European Commission Joint Research Centre (EC JRC). Ispra, Italy.

References

Carvalho, Felipe, Henning Winker, Dean Courtney, Maia Kapur, Laurence Kell, Massimiliano Cardinale, Michael Schirripa, et al. 2020. “A Cookbook for Using Model Diagnostics in Integrated Stock Assessments.” Fisheries Research, Accepted manuscript under revision.
Kell, L. T., I. Mosqueira, P. Grosjean, J-M. Fromentin, D. Garcia, R. Hillary, E. Jardim, et al. 2007. “FLR: An Open-Source Framework for the Evaluation and Development of Management Strategies.” ICES Journal of Marine Science 64 (4): 640–46. https://doi.org/10.1093/icesjms/fsm012.