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=4, fig.width =6, 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
# Load packages library(ggplot2) library(plyr) library(reshape) library(popbio) library(FLCore) library(ggplotFL) library(FLBRP) library(FLasher) library(FLife) library(mydas) library(LBSPR)
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(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}}$
LBSPR is a R package for simulation and estimation using life-history ratios and length composition data
ak=alk(lh,cv=0.1)
lfd=lenSample(catch.n(om)[,20:65],ak,nsample=500)
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"])*1.5))
Figure r iFig=iFig+1; iFig
Observation error model for turbot.
source('~/Desktop/sea++/mydas/pkg/R/lbspr.R') prior=popdyn(lh) lb=lbspr(lfd,prior)
lb=lbspr(lfd[,ac(25:50)],prior) plot(as.FLQuant(lb["FM"])) plot(fbar(om[,ac(25:50)])) par=rbind(lh,prior["mk"]) fwd.lbspr(par,1)
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.
par=rbind(lh,prior["mk"]) fwd.lbspr(par,1) fwd.lbspr(propagate(par,2),1)
plot(fbar(om)/m(om)["4"]) prior =popdyn(lh) effort=fbar(om)%/%apply(fbar(om),6,mean) obs=as.FLQuant(ddply(melt(lfd),.(year,iter), with,data.frame(data=sum(as.numeric(len)*value)/sum(value)))) hat=maply(data.frame(year=30:65), function(year){ lb=FLQuant(lbspr(window(lfd,end=year),prior)) q=apply(lb["FM"]%/%effort[,dimnames(lb["FM"])$year],6,mean) hat=effort[,ac(iyr+1)]%*%q fwd.lbspr(par,c(hat))}) hat=as.FLQuant(transmute(melt(obs),year=year,params=params,data=value))
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.