setwd("~/Desktop/gitTest/erp_mac/rmd")
The Operating Model is based on the ICES stock assessment, where natural mortality is split into predation (M2) and background (M1) mortality, based on hypotheses from the Ecosystem Models. The assessment is then refitted, and a stock recruitment relationship estimated using priors from FishLife (Thorson et al. 2017).
A Reference Case Operating Model is conditioned first, then to evaluate robustness a range of plausible scenarios are used to condition a Robustness Set. These are a limited set of scenarios which are likely to to have major impacts on the performance of the management strategies.
All coding is done using R (R Core Team 2021) and FLR (Kell et al. 2007) in Rmarkdown (Xie, Allaire, and Grolemund 2018), and summarised in as vignettes. The information (data, files, etc.) required to re-do the analysis, is available at ???, including the ICES assessment data set, and the inputs and outputs from the ecosystem models.
Code for cleaning the input data, and R libraries used for the analysis, are contained in the ‘Rmd’ files such as this one. Only Key steps in the analysis are shown in the documents generated, code used for plotting are not echoed in the output but can be found in the ‘Rmd’ file.
This vignette is divided into sections for Installation of the required libraries, sourcing bespoke functions, and loading the data, before the Operating Condition is conducted. Hypotheses about Natural Mortality and Stock Rcruitment are then fitted.
Details on Funding, Software Versions andReferences can be found at the end of the document.
Libraries (i.e. packages) can be installed from gihtub using the
remotes
package:
install.packages("remotes")
library(remotes)
install.packages("ggplot2")
install.packages("plyr")
install.packages("dplyr")
install.packages("reshape")
remotes::install_github("flr/FLCore")
remotes::install_github("flr/ggplotFL")
remotes::install_github("flr/FLBRP")
remotes::install_github("flr/FLasher")
remotes::install_github("flr/FLAssess")
remotes::install_github("flr/FLife")
remotes::install_github("flr/mydas")
remotes::install_github("flr/FLCandy")
remotes::install_github("flr/FLSRTMB")
install.packages("patchwork")
remotes::install_github("james-thorson/FishLife")
remotes::install_github('fishfollower/SAM/stockassessment', ref='components')
remotes::install_github("flr/FLfse/FLfse")
library(FLCore)
library(ggplotFL)
library(FLBRP)
library(FLasher)
library(FLAssess)
library(plyr)
library(dplyr)
library(reshape)
library(FLife)
library(FLBRP)
library(FLCandy)
library(FLSRTMB)
library(patchwork)
library(stockassessment)
library(FLfse)
library(FishLife)
theme_set(theme_bw(16))
The data are the ICES inputs and historical estimates (ICES 2023) generated by “10_ICES” which runs the ICES assessment
load("../data/om/icesAssessment.RData")
Functions are used to run key parts of the analysis, this makes it easier to document and debug code, and replicate key steps. The ICES assessment is run uisng the function ‘runSam’, this means that the assessment can be redone in a comparable way when new data become available or based on alternative hypotheses, and steps are documented.
source("../source/runSam.R")
In the ICES assessment natural mortality (\(M\)) is assumed to be 0.15 for a ll ages in all year. However, mass-at-age of mackerel has varied over time.
Figure1 Predation mortality (M2) estimates for Mackerel from ecosystem models of the Northern Barents Sea (NorBar), West Coast of Scotand (WCofS) and North Sea. The dashed horizontal line at M=0.15 represents the assumed M in the ICES stock assessment for North Atlantic mackerel.”}
Natural mortality (M) has been shown to be a function of size-at-age (Lorenzen 2022), e.g. \(M=aW^b\),
In this study \(a\) was chosen so that M at age-at-maturity (\(A_{50}\)) is a given value (e.g. 0.15) then M1 (0.025) is subtracted to derive M2. Based on the stock weights-at-age M-at-age was then re-estimated
ddM<-function(wt,par){
par["m1"]%*%(wt%^%par["m2"])}
M1Fn=function(x,y=0.025) FLQuant(y,dimnames=dimnames(m(x)))
M2Fn=function(x) m(x) - M1Fn(x)
par=FLPar(m1=c(0.15/(0.300^-0.288)),
m2= -0.288)
Assume that M is a function of mass-at-age and has varied over time, and model M-at-age in the ICES assessment as a function of mass-at-age, there are no values for th 0-group in the stock so replace with the catch values.
load("../data/om/icesAssessment.RData")
om=ices
stock.wt(om)["0"]=catch.wt(om)["0"]
m(om)=ddM(stock.wt(om),par)
Figure2 Time series of mass-at-age.
Figure3 Time series of natural mortality at age.
Check the relationship between mass and M-at-age
Figure4 Plot of mass verse M.
Figure5 Time series of natural mortality at age based on Norwegian and Barents Seas predation mortalities.
Change M and then rerun the assessment the ICES catch numbers-at-age (using ‘runSam()’) to re-estimate numbers and fishing mortality-at-age.
There are four scenarios, the ICES assessment (M=0.15), the case where M is a function of mass-at0age (Reference), and two sensitivity tests where M varied based on the Barents Sea data (Environmental Driver) and where M was increased (High M).
m=t(m(om)[drop=T])
m=rbind(m,m[rep(41,2),])
cat(c("Natural Mortality",
"1 5",
"1980 2022",
"0 12",
"1"), sep="\n",file="../data/inputs/ices/nm-1.dat")
write(t(m),file="../data/inputs/ices/nm-1.dat",ncol=13,append=T)
m=t(m(oms[["Environmental\nDriver"]])[drop=T])
m=rbind(m,m[rep(41,2),])
cat(c("Natural Mortality",
"1 5",
"1980 2022",
"0 12",
"1"), sep="\n",file="../data/inputs/ices/nm-2.dat")
write(t(m),file="../data/inputs/ices/nm-2.dat",ncol=13,append=T)
m=t(m(om)[drop=T])
m=rbind(m,m[rep(41,2),])*1.25
cat(c("Natural Mortality",
"1 5",
"1980 2022",
"0 12",
"1"), sep="\n",file="../data/inputs/ices/nm-3.dat")
write(t(m),file="../data/inputs/ices/nm-3.dat",ncol=13,append=T)
res=list("M=0.15" =runSam("nm" ,dir="../data/inputs/ices"),
"Reference" =runSam("nm-1",dir="../data/inputs/ices"),
"Environmental\nDriver"=runSam("nm-2",dir="../data/inputs/ices"),
"High M" =runSam("nm-3",dir="../data/inputs/ices"))
## function returns both assessment outputs and an FLStock object
## FLStock object is used for running the MSE
oms =FLStocks(llply(res, function(x) x[[1]]))
sams=llply(res, function(x) x[[2]])
save(oms, file="../data/om/oms.RData")
save(sams,file="../data/om/sams.RData")
Figure6 SAMs
[,1] [,2]
[1,] "K" "M"
[2,] "Winfinity" "Loo"
[3,] "tmax" "tm"
[4,] "Lm" "Temperature"
[5,] "ln_margsd" "rho"
[6,] "logitbound_h" "ln_r"
Figure 7 Priors from FishBase
0: 34.465065: 15.3876 -0.916291 0.218005
1: 31.658899: 15.4851 -0.834069 0.244373
2: 29.992221: 15.5759 -0.758716 0.189164
3: 25.862006: 15.6747 -0.681923 0.225442
4: 25.627391: 15.7335 -0.660245 0.214782
5: 25.483474: 15.7529 -0.720645 0.218443
6: 25.481076: 15.7467 -0.719491 0.217788
7: 25.478268: 15.7466 -0.713176 0.218493
8: 25.478189: 15.7476 -0.711280 0.217747
9: 25.477559: 15.7467 -0.710682 0.218134
10: 25.477546: 15.7456 -0.711104 0.218119
11: 25.477541: 15.7459 -0.710707 0.218129
12: 25.477540: 15.7460 -0.710829 0.218136
13: 25.477540: 15.7460 -0.710882 0.218133
14: 25.477540: 15.7460 -0.710877 0.218133
Figure 8 Stock recruitment relationship fits
Figure 9 Recruitment residuals, with regimes indicated by box.
Based on the residuals increase the expected recruitment
source("../source/eqFn.R")
eqs=eqFn(oms[["Reference"]],s=hpar[1,1],sd=hpar[1,2])
0: 40.286159: 15.5488 -0.916291 0.218005
1: 36.839968: 15.6328 -0.837746 0.247229
2: 32.745959: 15.7110 -0.766192 0.194020
3: 28.281545: 15.7979 -0.692163 0.226382
4: 27.288552: 15.8984 -0.631085 0.210558
5: 26.611207: 15.9991 -0.692100 0.224744
6: 26.520052: 16.0219 -0.722870 0.214341
7: 26.404487: 16.0315 -0.684425 0.216996
8: 26.398284: 16.0316 -0.684468 0.218266
9: 26.394886: 16.0364 -0.686127 0.217724
10: 26.391516: 16.0407 -0.688826 0.218586
11: 26.388264: 16.0509 -0.687452 0.218277
12: 26.388165: 16.0512 -0.688848 0.218196
13: 26.388156: 16.0518 -0.688648 0.218182
14: 26.388156: 16.0517 -0.688670 0.218186
15: 26.388156: 16.0517 -0.688669 0.218185
Figure 10 M-at-age 4
Figure 11 Stock Recruitment Relationship
R version 4.2.1 (2022-06-23)
FLCore: 2.6.19.9097
ggplotFL: 2.7.0.9131
FLBRP: 2.5.9.9020
FLasher: 0.7.1.9218
FLAssess: 2.6.3
FLife: 3.4.0
mydas: 1.2.2
FLCandy: 0.1.0
FLSRTMB: 1.1.4.9013
plyr: 1.8.9
dplyr: 1.1.3
reshape: 0.8.9
FLfse: 1.0.2
stockassessment: 0.5.4
FishLife: 2.6.3
patchwork: 1.1.3
Compiled: Tue Nov 21 10:22:12 2023
Git Hash: 52e4837