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(FLa4a)
#> Loading required package: FLCore
#> Loading required package: lattice
#> Loading required package: iterators
#> FLCore (Version 2.6.15.9016, packaged: 2021-01-18 20:35:15 UTC)
#> Loading required package: triangle
#> Loading required package: copula
#> Loading required package: coda
#> Loading required package: grid
#> Loading required package: gridExtra
#> 
#> Attaching package: 'gridExtra'
#> The following object is masked from 'package:FLCore':
#> 
#>     combine
#> Loading required package: latticeExtra
#> This is FLa4a 1.8.2. For overview type 'help(package="FLa4a")'
library(a4adiags)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'ggplot2'
#> The following object is masked from 'package:latticeExtra':
#> 
#>     layer
#> The following object is masked from 'package:FLCore':
#> 
#>     %+%
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)
}
res <- a4ahcxval(stock, indices, nyears=5, nsq=3, srmodel=srmod, fmodel=fmod,
  qmodel=qmod, vmodel=vmod)
#> Warning in a4ahcxval(stock, indices, nyears = 5, nsq = 3, srmodel = srmod, :
#> Submodels using s(year) or te(year) should have 'k' changed in retro
#> Warning: executing %dopar% sequentially: no parallel backend registered
mase(indices, res$indices[-1])
#>       BTS       SNS 
#> 0.8342634 0.6195470
plotXval(indices, res$indices)

(???)

(???)

Runs test

plotRunstest(fit, indices)

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.0.3 (2020-10-10)
  • FLCore: 2.6.15.9016
  • FLa4a: 1.8.2
  • ggplotFL: 2.6.8.9004
  • a4adiags: 0.1.1
  • Compiled: Tue Jan 19 08:52:29 2021
  • Git Hash: 6f3e1ac

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.