library(FLCore)
library(FLBRP)
library(FLasher)
library(FLife)
library(ggplotFL)
library(FLCandy)
library(rfishbase)
library(SPMpriors)
library(FishLife)
library(plyr)
library(dplyr)
library(reshape)
library(ggplot2)
theme_set(theme_bw())
library(ggpubr)
library(ggcorrplot)
library(GGally)
Compare performance against management objectives
par=lhPar(FLPar(linf=30))
eq=lhEql(par)
om=as(eq,"FLStock")
om=window(fwd(om,fbar=m(om)[4,-1],sr=eq),start=19)
[1] "maxfbar has been changed to accomodate new plusgroup"
dimnames(om)$year =an(dimnames(om)$year)+1980
range(om)["plusgroup"]=range(om)["maxage"]
om=fwd(om,fbar=fbar(om)[,-1]%=%mean(m(om)),sr=eq)
om=window(om,start=2010,end=2041)
nits=101
om =propagate(om,nits)
recDevs=rlnorm(nits,rec(om)%=%0,0.3)
om=fwd(om,fbar=window(fbar(om)[,-1]),sr=eq,residuals=recDevs)
plot(om,iter=17)
source("~/Desktop/flr/FLCandy/R/seasonalise.R")
om4=seasonalise(iter(om,1),season=1:4)
plot(om4)
sr.par=FLPar(NA, dimnames=list(params=dimnames(params(eq))$params, season=1:4, iter=1))
sr.par[,2]=params(eq)[,1]
sr4=predictModel(model=model(eq), params=sr.par)
F=window(fbar(om4),start=2021)
F[,,,-4]=F[,,,-4]/10
F[,,, 4]=F[,,, 4]*4
control=as(FLQuants("f"=F),"fwdControl")
recDevs=rlnorm(nits,rec(om4)%=%0,0.3)
om4=propagate(om4, nits)
om4=fwd(om4,control=control,sr=sr4,residuals=recDevs)
plot(om4)
idxSeason=4
idxDevs =rlnoise(nits,stock(om4)[,,,idxSeason,,1]%=%0,0.3,0)%*%
qmin(rlnoise(nits,stock(om4)[,,,idxSeason,,1]%=%0,0.5,0.6),1)
btrig =0.5*apply(ssb(om4)[,ac(2011:2020)],6,mean)
targetF=mean(m(om4))*0.25
histF =mean(m(om4))
XY0=runXoY(rtar=targetF/histF,lag=0,
ref=2020,2021:2040,om4,sr,btrig,idxSeason,devRecs=recDevs,idxDevs)
plot(XY0, metrics=list(F =function(x) ssb(x)[,,,3],
SSB =function(x) ssb(x)[,,,3],
Catch=function(x) apply(catch(x),c(2,6),sum)), iter=c(17,23))
R version 4.2.1 (2022-06-23)
knitr: 1.43
FLCore: 2.6.19.9105
FLBRP: 2.5.9.9022
FLasher: 0.7.1.9221
FLife: 3.4.0
ggplotFL: 2.7.0.9132
FLCandy: 0.1.0
rfishbase: 3.1.9.99
SPMpriors: 1.0.4
FishLife: 3.0.0
plyr: 1.8.9
dplyr: 1.1.4
reshape: 0.8.9
ggplot2: 3.4.4
ggpubr: 0.6.0
ggcorrplot: 0.1.3
GGally: 2.1.2
Compiled: Mon Jan 22 14:02:06 2024