library(knitr) source("R/ini.R")
library(knitr) ## Global options opts_chunk$set(cache =TRUE, echo =FALSE, eval =TRUE, prompt =FALSE, comment =NA, message =FALSE, warning =FALSE, tidy =TRUE, fig.height=6, fig.width =8, fig.path ="tex/simtest/len-", cache.path="cache/simtest/len/")
options(digits=3) iFig=0
This tutorial describes how to simuation test data limited methods in FLR
using a variety of other packages.
To follow this tutorial you should have installed the following packages:
for example
install.packages(c("FLCore"), repos="http://flr-project.org/R") install.packages(c("FLBRP"), repos="http://flr-project.org/R") install.packages(c("FLasher"), repos="http://flr-project.org/R") install.packages(c("FLife"), repos="http://flr-project.org/R")
# Load packages library(ggplot2) library(plyr) library(reshape) library(FLCore) library(ggplotFL) library(FLBRP) library(FLasher) library(FLife) library(MLZ)
Turbot
lh=FLPar(c(linf= 59.1, k=0.28, t0=-0.4, a=0.01111,b=3.15,a50=4.0, l50=43.25),units="NA") lh=lhPar(lh) eq=lhEql(lh) gTime=c(round(mydas:::gt(eq))) fbar(eq)=refpts(eq)["msy","harvest"]%*%FLQuant(c(rep(.1,19), seq(.1,2,length.out=30)[-30], seq(2,1.0,length.out=gTime)[-1], rep(1.0,61)))[,1:105] om=as(eq,"FLStock") om=fwd(om,f=fbar(om)[,-1], sr=eq)
plot(FLQuants(om, "f" = function(x) fbar(x)%/%refpts(eq)["msy","harvest"], "ssb" = function(x) ssb(x)%/%refpts( eq)["msy","ssb"], "catch"=function(x) landings(x)%/%refpts(eq)["msy","yield"], "rec" = function(x) rec(x)%/%refpts( eq)["msy","rec"])) + geom_hline(aes(yintercept=1),col="red",linetype=2)+ theme_bw()
Figure r iFig=iFig+1; iFig
Time series relative to MSY benchmarks.
Based on Beverton and Holt $L_{F} = \frac{L\infty +\frac{F+M}{K}L_c}{1+\frac{F+M}{K}}$
MLZ is a package that facilitates data preparation and estimation of mortality with statistical diagnostics using the mean length-based mortality estimator and several extensions.
library(MLZ) library(popbio)
#source('~/Desktop/flr/mydas/R/omOut.R') ts =mydas:::omSmry(om,eq,lh) mnLen=as.FLQuant(with(ts,data.frame(data=cln,year=year,iter=iter))) plot(mnLen)
Figure r iFig=iFig+1; iFig
Mean length of catch turbot.
#source('~/Desktop/flr/mydas/R/popdyn.R') #growth<-vonB prior=mydas:::popdyn(lh)
#source('~/Desktop/flr/mydas/R/mlz.R') res=mydas:::mlz(mnLen[,ac(40:60)],prior) res
LBSPR is a R package for simulation and estimation using life-history ratios and length composition data
library(LBSPR)
ak=mydas:::invAlk(lh)
lfd=mydas:::lenSample(catch.n(om)[,20:65],ak,nsample=500)
save(lfd,file="lfd.RData") ggplot(melt(lfd[,seq(1,45,10)]))+ geom_histogram(aes(len,weight=value),binwidth=1)+ facet_grid(year~iter,scale="free")+ xlab("Length (cm)")+ylab("Frequency")+ coord_cartesian(xlim=c(0,mean(lh["linf"])))
Figure r iFig=iFig+1; iFig
Observation error model for turbot.
library(LBSPR) library(mydas) library(popbio) #growth=vonB prior=popdyn(lh) #source("/home/laurence-kell/Desktop/flr/mydas/R/lbspr.R") lb=mydas:::lbspr(lfd,prior)
ggplot(melt(sweep(lb[["spr"]],c(1,3),lb[["spr"]][,"40"],"/")))+ geom_boxplot(aes(ac(year),value))+ scale_x_discrete(breaks=seq(20,60,10))+ ylab("SPR")+xlab("Year")+theme_bw()
Figure r iFig=iFig+1; iFig
Estimates of SPR for turbot.
ggplot(melt(sweep(lb[["fm"]],c(1,3),lb[["fm"]][,"40"],"/")))+ geom_boxplot(aes(ac(year),value))+ scale_x_discrete(breaks=seq(20,60,10))+ ylab("F")+xlab("Year")+theme_bw()
Figure r iFig=iFig+1; iFig
Estimates of $F/M$ for turbot.
r version$version.string
r packageVersion('FLCore')
r packageVersion('FLasher')
r date()
This document is licensed under the Creative Commons Attribution-ShareAlike 4.0 International license.
Laurence KELL. laurie@seaplusplus.co.uk
This vignette and 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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.