mydas package

library(knitr)
## Global options
opts_chunk$set(cache     =!TRUE,
               echo      =TRUE,
               eval      =TRUE,
               prompt    =FALSE,
               comment   =NA,
               message   =FALSE,
               warning   =FALSE,
               tidy      =FALSE,
               fig.height=6,
               fig.width =8)

iFig=0
library(mydas)
theme_set(theme_bw())
options(digits=3)

Install FLR packages

To follow this tutorial a number of packages need to be installed, either from CRAN or from www.flr-project.org where variety of packages and tutorials are available.

install.packages(c("FLCore","FLFishery","FLasher","FLBRP","mpb","FLife"), 
             repos="http://flr-project.org/R")

devtools also needs to be installed and loaded so that the mydas package can be installed from the GitHub repository.

install.packages("devtools",dependencies=TRUE)
library(devtools)

devtools::install_github("lauriekell/mydas-pkg")

Load Libraries

library(FLCore)
library(FLasher)
library(FLBRP)
library(FLife)
library(mydas)

Life history parameters

Get fishbase data

stocks=data.frame(
   species=c("Psetta maxima","Scophthalmus rhombus","Raja clavata",
              "Pollachius pollachius","Sprattus sprattus sprattus"),
   name=   c("Turbot",       "Brill",               "Ray",        
             "Pollack",      "Sprat"))

load(url("https://github.com//fishnets//fishnets//blob//master//data//fishbase-web//fishbase-web.RData?raw=True"))

finfish=subset(fb,as.character(species)%in%as.character(stock$species))
names(lh)[c(14,17)] = c("l50","a50")
lh=lh[,c("linf","k","t0","a","b","a50","l50")]

head(lh)

Life history parameters

data(mydas)
library(GGally)

my_smooth <- function(data,mapping,...){
  ggplot(data=data,mapping=mapping)+
  geom_point(...,size=.5)+
  geom_smooth(...,method="lm",se=FALSE)}

my_density <- function(data,mapping,...){
  ggplot(data=data,mapping=mapping)+
  geom_density(...,lwd=1)}

ggpairs(transform(wklife[,-c(1:5)],linf=log(linf),k=log(k),l50=log(l50)),
  lower = list(continuous = wrap(my_smooth)),
  diag=list(continuous=wrap(my_density,alpha=0.2)),
  title = "")+
  theme(legend.position ="none",
  panel.grid.major =element_blank(),
  axis.ticks       =element_blank(),
  axis.text.x      =element_blank(),
  axis.text.y      =element_blank(),
  panel.border     =element_rect(linetype = 1, colour="black", fill=NA))

Figure r iFig=iFig+1; iFig Pairwise scatter plots of life history parameters.

Equilibrium Dynamics

Create an FLPar

wkpar=as(wklife[,6:13],"FLPar")
attributes(wkpar)[names(wklife)[1:5]]=wklife[,1:5]

Then use life history relationships to estimate missing values

par <- lhPar(wkpar)
units(par) <- c("", "", "cm", "", "cm", "cm", "cm", "cm")

and then to derive vectors for processses such as natural mortality

eql=lhEql(par)
sel<-function(x) 
  catch.sel(x)%/%fapex(catch.sel(x))

ggplot(FLQuants(eql,"m","catch.sel"=sel,"mat","catch.wt"))+
  geom_line(aes(age,data,col=attributes(wkpar)$name[iter]))+
  facet_wrap(~qname,scale="free")+
  scale_x_continuous(limits=c(0,15))+ 
  guides(colour=guide_legend(title="Species",title.position="top"))

Figure r iFig=iFig+1; iFig Vectors of m, selection pattern, maturity and weight-at-age.

and estimate equilibrium dynamics and reference points, e.g. for lemon sole

plot(iter(eql,3))

Figure r iFig=iFig+1; iFig Equilibrium curves for ling.

Simulation

Create a forward projection, i.e. an FLStock from an equilibrium object

lmsl=as(iter(eql,7),"FLStock")

units(mat(lmsl))="NA"
units(harvest(lmsl))="f"
plot(lmsl)

Figure r iFig=iFig+1; iFig Simulate a stock with increasing F

Software Versions

Author information

Laurence KELL. laurie.kell.es

Acknowledgements

This vignette and many of the methods documented in it were developed under the MyDas project funded by the Irish exchequer and EMFF 2014-2020. The overall aim of MyDas is to develop and test a range of assessment models and methods to establish Maximum Sustainable Yield (MSY) reference points (or proxy MSY reference points) across the spectrum of data-limited stocks.

References {#References}



laurieKell/mydas-pkg documentation built on Nov. 8, 2019, 10:58 p.m.