| Title: | Management Procedures |
|---|---|
| Description: | mpb is an R package for running and simulation testing biomass based stock assessment models. |
| Authors: | Laurence Kell [aut, cre] |
| Maintainer: | Laurence Kell <[email protected]> |
| License: | GPL-2 |
| Version: | 3.5.0 |
| Built: | 2026-06-04 07:54:57 UTC |
| Source: | https://github.com/lauriekell/mpb |
Returns length age data from Multifan-CL as a list with four data frames
alkMFCL(lfile, ffile, i = 1, df = TRUE)alkMFCL(lfile, ffile, i = 1, df = TRUE)
lfile |
the |
ffile |
the |
i |
fleet to read in |
df |
return data as a data.frame |
a list with elements caa numbers by age, len, season and year, laa length by age season and year,
obs observed length samples by season and year and hat fitted lengths by season and year,
lfile="/home/laurie/Desktop/gcode/mse4mfcl/ALB/papers/SCRS/SCRS2013-ALK/Inputs/length09.fit" rfile="/home/laurie/Desktop/gcode/mse4mfcl/ALB/papers/CSRS/SCRS2013-ALK/Inputs/plot-09.par.rep" ffile="/home/laurie/Desktop/Dropbox/collaboration/Shelton/ALBN/4B/2009/albN.frq"
Coerces an FLStock into a biodyn object.
## S4 method for signature 'FLQuant' rate(object)## S4 method for signature 'FLQuant' rate(object)
Create an object of the aspic class representing a biomass dynamic stock assessment model.
aspic(object, value, ...)aspic(object, value, ...)
object |
can be |
... |
named parameter being passed to slots |
aspic object
## Not run: asp=aspic() ## End(Not run)## Not run: asp=aspic() ## End(Not run)
A class that represents the ASPIC biomass dynamic stock assessment model.
The Class is intended to be used as part of an MSE and includes methods for diagnostics, calculating reference points and other quantities used when providing management advice.
aspics object
namecharacter with the name of the stock
conditioningfactor
optionsnumeric
indexdata.frame
stopmesscharacter
rndnumeric
modelfactor
catchFLQuant
stockFLQuant
diagsdata.frame
paramsFLPar
controlFLPar
priorsarray
vcovFLPar
hessianFLPar
objFnFLPar
mngFLPars
namecharacter
desccharacter
rangenumeric
## Not run: aspic()## Not run: aspic()
Create a list of aspic objects
features that give a little more structure to list objects. First the
elements of aspics must all be of the same class biodyn.
Second it implements lock mechanism that, when turned on, does not allow
the user to increase
or decrease the object length.
aspics(object, ...) ## S4 method for signature 'list' aspics(object, ...)aspics(object, ...) ## S4 method for signature 'list' aspics(object, ...)
object |
can be |
... |
additional |
aspics object
The data. list.
Names of the list elements. character.
Description of the object. character.
Lock mechanism, if turned on the length of the list can not be
modified by adding or removing elements. logical.
The FLR Team
[, [<-, [[<-, $<-, coerce, lapply, window, list
## Not run: aspics(aspic()) ## End(Not run) ## Not run: asp <- aspics("1"=aspic(),"2"=aspic()) ## End(Not run)## Not run: aspics(aspic()) ## End(Not run) ## Not run: asp <- aspics("1"=aspic(),"2"=aspic()) ## End(Not run)
aspics a class that contains a list of ASPIC biomass dynamic stock assessment model classes
objectCreates an object of the biodyn class representing a biomass dynamic stock assessment model.
biodyn(object, params, ...)biodyn(object, params, ...)
object |
can be |
... |
named parameter being passed to slots |
biodyn object
## Not run: bd=biodyn(params=FLPar(r=0.6,k=50000,p=1,b0=1)) ## End(Not run)## Not run: bd=biodyn(params=FLPar(r=0.6,k=50000,p=1,b0=1)) ## End(Not run)
A class that implement a biomass dynamic stock assessment model.
The Class is intended to be used as part of an MSE and includes methods for diagnostics, calculating reference points and other quantities used when providing management advice.
nameA character with the name of the stock
descA character providing a fuller description of the object
rangeA numeric vector containing the quant and year ranges
modelA factor giving name of production function, for now this is only 'pellat'
objfactor that determines the objective function type -LL or LAV
catchAn FLQuant with total catch by year
indexAn FLQuants with indices year
stockAn FLQuant which will hold the estimated stock by year
controlAn FLPar which sets initial guess (val) and bounds (min and max) for each parameter. The phase allows a parameter to be fixed if less <0 and for paramters to be estimated sequentially
hcrA data.frame with harvest control rule options
priorsAn array which sets penalties for parameters
paramsAn FLPar with parameter estmates
vcovAn FLPar with the covariance matrix of the parameter estimates
hessianAn FLPar with the hessian of the estimated parameters
refA numeric with parameters for estimating mng quantities
mngFLPar with derived quatities of management interest
mngVcovAn FLPar with the variance matrix of management quanties
diagsA data.frame with residuals and covariates from fit of CPUE to stock
objFnFLPar with objective function
llFLPar with negative log likelihood by data component
profiledata.frame not yet implemented
hstdata.frame not yet implemented
All slots in the class have accessor and replacement methods that provide validation and protection of their data.
## Not run: biodyn()## Not run: biodyn()
Creates a biodyn object initialized with biomass at BMSY and catch at MSY
## S4 method for signature 'FLPar,missing' biodyn(object, nyrs = 50)## S4 method for signature 'FLPar,missing' biodyn(object, nyrs = 50)
nyrs |
Number of years for projection (default = 50) |
params |
An FLPar object containing parameters r, k, and p |
A biodyn object initialized for the specified number of years
params=FLPar(r=0.5, k=1000, p=1) bd=biodyn(params)params=FLPar(r=0.5, k=1000, p=1) bd=biodyn(params)
biodyns creates a list of biodyn objects
## S4 method for signature 'biodyn' biodyns(object)## S4 method for signature 'biodyn' biodyns(object)
objectFits the aspic model to catch and catch per unit effort data
Bootstraps the ASPIC biomass dynamic model.
Bootstraps the aspic model
object; |
an |
dir; |
an optional |
An aspic object with fitted values and parameter estimates
An aspic object with fitted values and parameter estimates
## Not run: data(asp) asp=boot(asp) ## End(Not run)## Not run: data(asp) asp=boot(asp) ## End(Not run)
Bootstraps the aspic model
## S4 method for signature 'biodyn' boot(object, run = TRUE)## S4 method for signature 'biodyn' boot(object, run = TRUE)
object; |
a |
boot
## Not run: data(asp) asp=boot(asp) ## End(Not run)## Not run: data(asp) asp=boot(asp) ## End(Not run)
sets initial guess and lower and upper bounds
## S4 method for signature 'biodyn' control(object)## S4 method for signature 'biodyn' control(object)
object |
|
FLPar
## Not run: control(biodyn())## Not run: control(biodyn())
sets in biodyn initial guess and lower and upper bounds
## S4 replacement method for signature 'biodyn,FLPar' control(object) <- value## S4 replacement method for signature 'biodyn,FLPar' control(object) <- value
biodyn with new control slot
## Not run: control(biodyn())## Not run: control(biodyn())
A utility function to help set up the control slot in biodyn
controlFn(object)controlFn(object)
r |
a |
k |
a |
p |
a |
b0 |
a |
phaseR |
a |
phaseK |
a |
phaseP |
a |
phaseB0 |
a |
min |
a |
max |
|
a control object
## Not run: sim() ## End(Not run)## Not run: sim() ## End(Not run)
Slot for estimates
diags(object)diags(object)
object |
either biodyn or aspic class |
value |
|
... |
any other parameter |
Estimates parameters biodyn class by fitting catch and CPUE indices
diagsFn(res)diagsFn(res)
object |
an object of class |
index |
an |
... |
other arguments |
## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) ## End(Not run)## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) ## End(Not run)
calculates time series of quantities useful for management
fapexAge(object)fapexAge(object)
object |
either FLStock biodyn or aspic classes |
Checks that the parameters can be taken given the catch time series
## S4 method for signature 'FLPar,FLQuant' feasible(object, catch, min = 0.01)## S4 method for signature 'FLPar,FLQuant' feasible(object, catch, min = 0.01)
object |
an |
catch |
an |
min |
the minimum permissable population level, used to check that the catch can be taken. |
... |
any other parameters |
a FLPar a subset of params with parameter values that can explain the catch
## Not run: params=feasibleFn(catch,params) ## End(Not run)## Not run: params=feasibleFn(catch,params) ## End(Not run)
A generic method for fitting catch and index of relative abundance for both biodyn and aspic.
fit(object, index, ...)fit(object, index, ...)
object |
either biodyn or aspic class |
index |
with relative abundance, FLQuant or FLQuants, if object is of type bodyn |
... |
any other parameter |
-mcmc 100000 -mcsave 100'
fitPella( object, dir = tempdir(), cmdOps = paste("-maxfn 500 -iprint 0"), lav = FALSE, maxF = 2.5, silent = !TRUE )fitPella( object, dir = tempdir(), cmdOps = paste("-maxfn 500 -iprint 0"), lav = FALSE, maxF = 2.5, silent = !TRUE )
FLQuantJKs is a list of FLQuant objects.
It is very similar to the standard list class.
It implements a lock mechanism that, when turned on, does
not allow the user to increase or decrease the object length.
The elements of FLQuantJKs must all be of class FLQuant.
The data. list.
Names of the list elements. character.
Description of the object. character.
Lock mechanism, if turned on the length of the list can not be modified by adding or removing elements. logical.
Outputs as a data.frame a summary of parameters and RSS etc by data component generated when doing a profile
fnProfile(x)fnProfile(x)
x: |
an |
a data frame with results by data component.
## Not run: data(asp) dcK=profile(asp,which=c("k"),range=seq(0.2,2.0,length.out=21),fn=fnProfile) ggplot(dcK)+geom_line(aes(k,value,group=variable,col=variable))+ theme_ms(12,legend.position="bottom")+ ylab("Residual Sum of Squares")+xlab("K") ## End(Not run)## Not run: data(asp) dcK=profile(asp,which=c("k"),range=seq(0.2,2.0,length.out=21),fn=fnProfile) ggplot(dcK)+geom_line(aes(k,value,group=variable,col=variable))+ theme_ms(12,legend.position="bottom")+ ylab("Residual Sum of Squares")+xlab("K") ## End(Not run)
Projects a biodyn object (i.e. a biomass dynamic model)
for a given future catch, harvest rate, or stock biomass. Only
one of these has to be supplied as an argument.
## S4 method for signature 'biodyn,missing,missing' fwd( object, fishery, control, catch = NULL, harvest = NULL, f = NULL, stock = NULL, hcr = NULL, pe = NULL, peMult = TRUE, minF = 0, maxF = 2, bounds = list(catch = c(Inf, Inf)), lag = 0, end = NULL, starvationRations = 0.75, ... )## S4 method for signature 'biodyn,missing,missing' fwd( object, fishery, control, catch = NULL, harvest = NULL, f = NULL, stock = NULL, hcr = NULL, pe = NULL, peMult = TRUE, minF = 0, maxF = 2, bounds = list(catch = c(Inf, Inf)), lag = 0, end = NULL, starvationRations = 0.75, ... )
object |
an object of class |
control |
missing |
... |
any other parameters |
## Not run: bd=simBidyn() harvest=rlnorm(100,log(harvest(bd))[,-dims(bd)$year],.1) bdHat =fwd(bdHat,harvest=harvest) plot(bdHat,worm=c(2,8))+ theme(legend.position="bottom") ## End(Not run)## Not run: bd=simBidyn() harvest=rlnorm(100,log(harvest(bd))[,-dims(bd)$year],.1) bdHat =fwd(bdHat,harvest=harvest) plot(bdHat,worm=c(2,8))+ theme(legend.position="bottom") ## End(Not run)
harvest rate
## S4 method for signature 'biodyn,missing' harvest(object)## S4 method for signature 'biodyn,missing' harvest(object)
object |
either biodyn or aspic classes |
Harvest Control Rule, calculates F, or Total Allowable Catch (TAC) based on a hockey stock harvest control rule.
Harvest Control Rule, calculates F, or Total Allowable Catch (TAC) based on a hockey stock harvest control rule.
## S4 method for signature 'biodyn,FLPar' hcr( object, refs = hcrParam(ftar = 0.7 * mpb:::fmsy(refs), btrig = 0.8 * mpb:::bmsy(refs), fmin = 0.01 * mpb:::fmsy(refs), blim = 0.4 * mpb:::bmsy(refs)), params = refs, stkYrs = max(as.numeric(dimnames(stock(object))$year)), refYrs = max(as.numeric(dimnames(catch(object))$year)), hcrYrs = max(as.numeric(dimnames(stock(object))$year)), tac = TRUE, bndF = NULL, bndTac = NULL, maxF = 2, ... ) ## S4 method for signature 'FLStock,FLBRP' hcr( object, refs, params = hcrParam(ftar = 0.7 * fmsy(refs), btrig = 0.8 * bmsy(refs), fmin = 0.01 * fmsy(refs), blim = 0.4 * bmsy(refs)), stkYrs = max(as.numeric(dimnames(stock(object))$year)), refYrs = max(as.numeric(dimnames(catch(object))$year)), hcrYrs = max(as.numeric(dimnames(stock(object))$year)), tac = TRUE, tacMn = TRUE, bndF = NULL, bndTac = NULL, maxF = 2, ... )## S4 method for signature 'biodyn,FLPar' hcr( object, refs = hcrParam(ftar = 0.7 * mpb:::fmsy(refs), btrig = 0.8 * mpb:::bmsy(refs), fmin = 0.01 * mpb:::fmsy(refs), blim = 0.4 * mpb:::bmsy(refs)), params = refs, stkYrs = max(as.numeric(dimnames(stock(object))$year)), refYrs = max(as.numeric(dimnames(catch(object))$year)), hcrYrs = max(as.numeric(dimnames(stock(object))$year)), tac = TRUE, bndF = NULL, bndTac = NULL, maxF = 2, ... ) ## S4 method for signature 'FLStock,FLBRP' hcr( object, refs, params = hcrParam(ftar = 0.7 * fmsy(refs), btrig = 0.8 * bmsy(refs), fmin = 0.01 * fmsy(refs), blim = 0.4 * bmsy(refs)), stkYrs = max(as.numeric(dimnames(stock(object))$year)), refYrs = max(as.numeric(dimnames(catch(object))$year)), hcrYrs = max(as.numeric(dimnames(stock(object))$year)), tac = TRUE, tacMn = TRUE, bndF = NULL, bndTac = NULL, maxF = 2, ... )
object |
an object of class |
... |
other parameters, i.e.
refs |
FLPar object with value(s) for F or TAC if tac==TRUE
FLPar object with value(s) for F or TAC if tac==TRUE
## Not run: bd =sim() bd=window(bd,end=29) for (i in seq(29,49,1)) bd=fwd(bd,harvest=hcr(bd,yr=i,yr=i+1)$hvt) ## End(Not run) ## Not run: bd =sim() bd=window(bd,end=29) for (i in seq(29,49,1)) bd=fwd(bd,harvest=hcr(bd,yr=i,yr=i+1)$hvt) ## End(Not run)## Not run: bd =sim() bd=window(bd,end=29) for (i in seq(29,49,1)) bd=fwd(bd,harvest=hcr(bd,yr=i,yr=i+1)$hvt) ## End(Not run) ## Not run: bd =sim() bd=window(bd,end=29) for (i in seq(29,49,1)) bd=fwd(bd,harvest=hcr(bd,yr=i,yr=i+1)$hvt) ## End(Not run)
Combines reference points into the HCR breakpts
hcrParam(ftar, btrig, fmin, blim)hcrParam(ftar, btrig, fmin, blim)
ftar |
an object of class |
btrig |
an object of class |
fmin |
an object of class |
blim |
an object of class |
## Not run: tac('logistic',FLPar(msy=100,k=500)) ## End(Not run)## Not run: tac('logistic',FLPar(msy=100,k=500)) ## End(Not run)
harvest rate
## S4 method for signature 'biodyn' hrate(object)## S4 method for signature 'biodyn' hrate(object)
object |
either biodyn or aspic classes |
Checks class type and returns TRUE if object is of type biodyn
is.aspic(x)is.aspic(x)
x |
biodyn class |
TRUE or FALSE
## Not run: is.aspic(aspic()) ## End(Not run)## Not run: is.aspic(aspic()) ## End(Not run)
Checks class type and returns TRUE if object is of type biodyn
is.biodyn(x)is.biodyn(x)
x |
biodyn class |
TRUE or FALSE
## Not run: is.biodyn(biodyn()) ## End(Not run)## Not run: is.biodyn(biodyn()) ## End(Not run)
A generic method for jack knifing a fit to catch and index of relative abundance for both biodyn and aspic.
Fits the aspic model to catch and catch per unit effort data removing 1 cpue observation at a time
jk(object, index, ...) chkIters(object)jk(object, index, ...) chkIters(object)
object |
either biodyn or aspic class |
index |
with relative abundance of type FLQuantJK or FLQuantJKs, if object is of type biodyn |
... |
any other parameter |
object; |
a character string giving an aspic "inp" file |
dir; |
an optional |
An aspic object with fitted values and parameter estimates
## Not run: data(asp) asp=jk(asp) ## End(Not run)## Not run: data(asp) asp=jk(asp) ## End(Not run)
Calculates $k$ given msy, r and K for a Pella-Tomlinson biomass dynamic model
K(msy, r = 0.6, p = 1, params = FLPar(r = r, p = p))K(msy, r = 0.6, p = 1, params = FLPar(r = r, p = p))
msy |
a guess for MSY |
r |
a guess for $r$ the population growth rate |
p |
a guess for $p$ the shape parameter |
params |
provide $r$ and $p$ as |
an FLPar object with an estimate for $k$
## Not run: K(5000,r=.6,p=1.0) ## End(Not run)## Not run: K(5000,r=.6,p=1.0) ## End(Not run)
Creates time series of stock relative to BMSY and harvest rate relative to FMSY
## S4 method for signature 'biodyn,missing' kobe( object, what = c("sims", "trks", "pts", "smry", "wrms")[1], probs = c(0.75, 0.5, 0.25), year = NULL, nwrms = 10, sim = NULL, drop = TRUE )## S4 method for signature 'biodyn,missing' kobe( object, what = c("sims", "trks", "pts", "smry", "wrms")[1], probs = c(0.75, 0.5, 0.25), year = NULL, nwrms = 10, sim = NULL, drop = TRUE )
object |
biodyn object |
method |
missing |
... |
other arguments |
data.frame or list of data.frames
## Not run: sim() ## End(Not run)## Not run: sim() ## End(Not run)
Returns von Bertalannfy growth parameters from Multifan-CL
mfclGrw(parfile = getoutputparfile("plot.rep"))mfclGrw(parfile = getoutputparfile("plot.rep"))
parfile |
the par file output from Multifan-cl |
a numeric vector
Simulates a normal density function from an FLQuant
mixnorm(n, mn, sd, bin, left = T)mixnorm(n, mn, sd, bin, left = T)
mn |
an |
sd |
an |
an FLPar with expected probability for lengths-at-age
## Not run: mn=FLQuant( 1:5, dimnames=list(age=1:5,year=1991:2000,unit=1:2)) sd=FLQuant((1:5)/5,dimnames=list(age=1:5,year=1991:2000)) md=mixnorm(mn,sd,(1:20)/4) ggplot(as.data.frame(md))+ geom_line(aes(len,data,group=age))+ facet_wrap(year~unit) ggplot(as.data.frame(apply(md,1,sum)))+ geom_line(aes(as.numeric(as.character(params)),data)) ## End(Not run)## Not run: mn=FLQuant( 1:5, dimnames=list(age=1:5,year=1991:2000,unit=1:2)) sd=FLQuant((1:5)/5,dimnames=list(age=1:5,year=1991:2000)) md=mixnorm(mn,sd,(1:20)/4) ggplot(as.data.frame(md))+ geom_line(aes(len,data,group=age))+ facet_wrap(year~unit) ggplot(as.data.frame(apply(md,1,sum)))+ geom_line(aes(as.numeric(as.character(params)),data)) ## End(Not run)
Runs a full MSE using an FLStock object as the Operating Model and biodyn as the Mangement Procedure
mseBiodyn( om, eql, srDev, uDev, mp, start = range(om)["maxyear"], end = start + 30, interval = 3, oem = oem, hcrPar = function(mp, ftar = 0.7, btrig = 0.6, fmin = 0 - 1, blim = 0.001) { hcrParam(ftar = ftar * fmsy(mp), btrig = btrig * bmsy(mp), fmin = fmin * fmsy(mp), blim = blim * bmsy(mp)) }, bndF = NULL, bndTac = NULL, maxF = 1, omega = 1, refB = 1, qTrend = 0 )mseBiodyn( om, eql, srDev, uDev, mp, start = range(om)["maxyear"], end = start + 30, interval = 3, oem = oem, hcrPar = function(mp, ftar = 0.7, btrig = 0.6, fmin = 0 - 1, blim = 0.001) { hcrParam(ftar = ftar * fmsy(mp), btrig = btrig * bmsy(mp), fmin = fmin * fmsy(mp), blim = blim * bmsy(mp)) }, bndF = NULL, bndTac = NULL, maxF = 1, omega = 1, refB = 1, qTrend = 0 )
om |
an |
srDev |
a |
uDev |
an |
mp |
an |
range |
a |
ftar |
a |
fmin |
a |
blim |
a |
btrig |
a |
what |
a |
mult |
a |
a list of data.frames with performance measures from OM and summaries from MP, if con!=NULL will
also write to a MYSQL database
## Not run: library(mpb) library(FLash) library(FLBRP) load(om) load(eql) om=mpb::fwdWindow(om,eql,end=2030) om=propagate(om,100) srDev=FLQuant(0,dimnames=list(year=2000:2030)) srDev=rlnorm(100,srDev,0.3) om=mpb::fwd(om,catch=catch(om)[,ac(2000:2011)],sr=eql,sr.residuals=srDev) library(popbio) mp=mpb::FLBRP2biodyn( eql,"biodyn") mp=mpb::FLStock2biodyn(om, "biodyn") ## End(Not run)## Not run: library(mpb) library(FLash) library(FLBRP) load(om) load(eql) om=mpb::fwdWindow(om,eql,end=2030) om=propagate(om,100) srDev=FLQuant(0,dimnames=list(year=2000:2030)) srDev=rlnorm(100,srDev,0.3) om=mpb::fwd(om,catch=catch(om)[,ac(2000:2011)],sr=eql,sr.residuals=srDev) library(popbio) mp=mpb::FLBRP2biodyn( eql,"biodyn") mp=mpb::FLStock2biodyn(om, "biodyn") ## End(Not run)
Takes a fitted biodyn object and uses the covariance matrix (in the vcov slot) and the
parameter estimates (params slot) to use Monte Carlo simulation to generate new
parameters
mvn( object, n, nms = dimnames(object@control[object@control[, "phase", ] > 0, ])$params, fwd = FALSE, params = TRUE )mvn( object, n, nms = dimnames(object@control[object@control[, "phase", ] > 0, ])$params, fwd = FALSE, params = TRUE )
object |
a |
n |
|
nms |
the parameters for Monte Carlo simulation |
fwd |
|
params |
actual parameters |
biodyn with simuated time series
## Not run: x=1 ## End(Not run)## Not run: x=1 ## End(Not run)
Checks that the parameters can be taken given the catch time series
## S4 method for signature 'FLQuant,FLQuant,FLPar' nll(object, index, params, min = 0.01)## S4 method for signature 'FLQuant,FLQuant,FLPar' nll(object, index, params, min = 0.01)
object |
an |
params |
an |
min |
the minimum permissable population level, used to check that the catch can be taken. |
... |
any other parameters |
a FLPar a subset of params with parameter values that can explain the catch
## Not run: params=nllFn(catch,params) ## End(Not run)## Not run: params=nllFn(catch,params) ## End(Not run)
nmcFn(x, s, E = 5, z = 1.96)nmcFn(x, s, E = 5, z = 1.96)
x |
|
E |
|
z |
...other arguments |
FLQuant with number of iters required by number of iters
Calculates the number of iterations needed in Monte Carlo Simulation to achieve a given precision.
## Not run: data(ple4) ssb=rlnorm(2000,log(ssb(ple4)),0.5) nmc(ssb) ## End(Not run)An example Operating Model, based on North Atlantic Albacore
Reference points and expected dynamics, for Operating Model based on North Atlantic Albacore
An FLStock object
numbers-at.age, FLQuant
mass-at-age, FLQuant
...
An FLBRP object
mass-at-age, FLQuant
...
A dataset containing the historic stock estimates, derived from the ICCAT multifan-CL assessment
A dataset containing the average estimates of biological parameters and selection patterns, derived from the ICCAT multifan-CL assessment
Laurence Kell [email protected]
http://http://iccat.int/Documents/CVSP/CV070_2014/n_4/CV070041365.pdf/
http://http://iccat.int/Documents/CVSP/CV070_2014/n_4/CV070041365.pdf/
Plots time series of biomass, harvest rate and catch for a biodyn object, using ggplot2.
## S4 method for signature 'biodyn,missing' plot( x, y, probs = c(0.9, 0.75, 0.5, 0.25, 0.1), na.rm = FALSE, type = 7, worm = NULL, fn = list(Stock = function(x) stock(x), Harvest = function(x) harvest(x), Yield = function(x) catch(x)), facet = facet_wrap(~qname, scales = "free", ncol = 1), ... ) ## S4 method for signature 'FLQuants' plotCcf(data, ...)## S4 method for signature 'biodyn,missing' plot( x, y, probs = c(0.9, 0.75, 0.5, 0.25, 0.1), na.rm = FALSE, type = 7, worm = NULL, fn = list(Stock = function(x) stock(x), Harvest = function(x) harvest(x), Yield = function(x) catch(x)), facet = facet_wrap(~qname, scales = "free", ncol = 1), ... ) ## S4 method for signature 'FLQuants' plotCcf(data, ...)
x |
an object of class |
y |
second argument |
probs |
numeric vector of probabilities with values in [0,1]. |
na.rm |
a logical value indicating whether NA values should be stripped before computation. |
type |
an integer between 1 and 9 selecting one of the quantile algorithms to be used. |
worm |
iter(s) to plot as lines |
fn |
functions |
facet |
facet for panelling |
an ggplot2 object
an ggplot2 object
## Not run: bd =sim() plot(bd) ## End(Not run) ## Not run: ## End(Not run)## Not run: bd =sim() plot(bd) ## End(Not run) ## Not run: ## End(Not run)
Creates a ggplot2 object that plots time series of biomass, harvest rate and catch. The basic object can then be modified by adding ggpot2 layers.
## S4 method for signature 'biodyn,missing' plotEql(data, biomass, ...)## S4 method for signature 'biodyn,missing' plotEql(data, biomass, ...)
biomass |
an object of holding biomass at beginning of year |
... |
other arguments |
x |
an object of class |
an ggplot2 object
## Not run: refpts('logistic',FLPar(msy=100,k=500)) ## End(Not run)## Not run: refpts('logistic',FLPar(msy=100,k=500)) ## End(Not run)
Plots a hockey stick HCR with break pointts
## S4 method for signature 'biodyn' plotHcr( object, params = FLPar(ftar = 0.7, btrig = 0.7, fmin = 0.01, blim = 0.2), maxB = 1, rel = TRUE )## S4 method for signature 'biodyn' plotHcr( object, params = FLPar(ftar = 0.7, btrig = 0.7, fmin = 0.01, blim = 0.2), maxB = 1, rel = TRUE )
object |
an object of class |
params |
|
maxB |
=1 |
rel |
=TRUE |
a FLPar object with value(s) for HCR
## Not run: simBiodyn() ## End(Not run)## Not run: simBiodyn() ## End(Not run)
plotIndex
## S4 method for signature 'FLQuants' plotIndex(data, ...)## S4 method for signature 'FLQuants' plotIndex(data, ...)
data |
an object of class |
an ggplot2 object
plotIndexResidual
## S4 method for signature 'FLQuants' plotIndexResidual(data, ...)## S4 method for signature 'FLQuants' plotIndexResidual(data, ...)
data |
an object of class |
an ggplot2 object
Create a ggplot2 plot based on a jack knifed biodyn and plots
time series of biomass and harvest rate.
The basic object can then be modified by adding ggpot2 layers.
plotJack(x, ncol = 1)plotJack(x, ncol = 1)
x |
an object of class |
ncol |
number of colums in plot panel |
plotJack
an ggplot2 object
## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) plotJack(bdJK) bd =randJack(100,bd) ## End(Not run)## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) plotJack(bdJK) bd =randJack(100,bd) ## End(Not run)
Creates a ggplot2 object that plots absolute and relative to MSY benchmarks time series of
ssb, biomass, harvest rate and catch for FLStock and biodyn objects
The basic object can then be modified by adding ggpot2 layers.
plotMSEfn(mp, om, brp = "missing")plotMSEfn(mp, om, brp = "missing")
x |
an object of class |
y |
an object of class |
z |
an object of class |
... |
other arguments |
an ggplot2 object
Creates a ggplot2 object that plots equilibrium values of biomass, harvest rate and catch against each other.
The basic object can then be modified by adding ggpot2 layers.
plotProduction(data, biomass, ...) ## S4 method for signature 'biodyn,missing' plotProduction(data, biomass, ...)plotProduction(data, biomass, ...) ## S4 method for signature 'biodyn,missing' plotProduction(data, biomass, ...)
biomass |
optional argument, an FLQuant with biomass at beginning of year |
... |
other arguments |
object |
an object of class |
plotProduction
an ggplot2 object
## Not run: refpts('logistic',FLPar(msy=100,k=500)) ## End(Not run)## Not run: refpts('logistic',FLPar(msy=100,k=500)) ## End(Not run)
Estimates production for a given biomass
productionFn( object, biomass = "missing", slots = c("landings.sel", "discards.sel", "stock.wt", "landings.wt", "discards.wt", "m", "mat", "harvest.spwn", "m.spwn") )productionFn( object, biomass = "missing", slots = c("landings.sel", "discards.sel", "stock.wt", "landings.wt", "discards.wt", "m", "mat", "harvest.spwn", "m.spwn") )
object |
either biodyn or FLBRP class |
biomass |
an FLQuant |
... |
any other parameter |
Performs a profile using residual sum of squares, fixes some parameters for a range of values and then estimate the others
profileFn(r = 0.5, k = 1000, p = 0.001, b0 = 0.75, min = 0.1, max = 10)profileFn(r = 0.5, k = 1000, p = 0.001, b0 = 0.75, min = 0.1, max = 10)
fitted: |
an |
which: |
|
range; |
|
fn: |
|
run: |
|
a data frame with results turned by fn by values in which.
Simulates a biodyn object for a catch series, given the parameter estimates in the param
slot and variance covariance matrix
http://young.physics.ucsc.edu/jackboot.pdf
randFn(n, object, sim)randFn(n, object, sim)
n |
|
object |
|
sim |
a |
... |
other arguments |
biodyn with estimates of stock based on catch time series
## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) bdRnd =rand(100,bd,bdJK) plot(rand(100,stock(bd)[,40:45],stock(bdJK)[,40:45])) ## End(Not run)## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) bdRnd =rand(100,bd,bdJK) plot(rand(100,stock(bd)[,40:45],stock(bdJK)[,40:45])) ## End(Not run)
Simulates a biodyn object for a catch series, given the parameter estimates in the param
slot and variance covariance matrix
http://young.physics.ucsc.edu/jackboot.pdf
randJackFn(n, object, sim)randJackFn(n, object, sim)
n |
|
object |
|
sim |
a |
... |
other arguments |
biodyn with estimates of stock based on catch time series
## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) bdRnd =randJack(100,bd,bdJK) plot(randJack(100,stock(bd)[,40:45],stock(bdJK)[,40:45])) ## End(Not run)## Not run: #simulate an object with known properties bd=sim() bd=window(bd,end=49) #simulate a proxy for stock abundance cpue=(stock(bd)[,-dims(bd)$year]+stock(bd)[,-1])/2 cpue=rlnorm(1,log(cpue),.2) #set parameters setParams(bd) =cpue setControl(bd)=params(bd) control(bd)[3:4,"phase"]=-1 #fit bd=fit(bd,cpue) bdJK=fit(bd,jackknife(cpue)) bdRnd =randJack(100,bd,bdJK) plot(randJack(100,stock(bd)[,40:45],stock(bdJK)[,40:45])) ## End(Not run)
Read ASPIC text files, either inp for inputs, or output files, produced by the executable version of ASPIC
readAspic(object, ...)readAspic(object, ...)
object |
an file path |
... |
any other parameter |
readFLStock, writeAspic
## Not run: readAspic("aspic.inp") ## End(Not run)## Not run: readAspic("aspic.inp") ## End(Not run)
Projects stock rebuilding trajectories from different initial depletion levels
rebuild( object, target = NULL, nInitial = 100, growthRate = 0.25, minVal = 1e-06, maxVal = 1, burnin = 20, truncate = TRUE, ... )rebuild( object, target = NULL, nInitial = 100, growthRate = 0.25, minVal = 1e-06, maxVal = 1, burnin = 20, truncate = TRUE, ... )
object |
A biodyn object |
target |
Target biomass (default = BMSY) |
nInitial |
Number of initial depletion levels (default = 100) |
growthRate |
Growth rate for depletion sequence (default = 0.3) |
minVal |
Minimum depletion value (default = 1e-6) |
maxVal |
Maximum depletion value (default = 1) |
nx |
Number of interpolation points (default = 101) |
A data frame with columns:
year |
Projection year |
initial |
Initial depletion level relative to BMSY |
bd=biodyn(FLPar(r=0.5, k=1000, p=1)) rebuild_data=rebuild(bd)bd=biodyn(FLPar(r=0.5, k=1000, p=1)) rebuild_data=rebuild(bd)
Calculates maximum sustainable yield (MSY) reference points given the model parameters, for yield, biomass and harvest rate
Calculates msy based reference points
refptSD(object, params, ...) ## S4 method for signature 'biodyn' msy(x, ...)refptSD(object, params, ...) ## S4 method for signature 'biodyn' msy(x, ...)
object |
an object of class |
... |
any other parameters |
object |
a |
an FLPar object with benchmark
an FLPar object with an estimate for $msy$
## Not run: msy('logistic',FLPar(msy=100,k=500)) ## Not run: msy(bd) ## End(Not run)## Not run: msy('logistic',FLPar(msy=100,k=500)) ## Not run: msy(bd) ## End(Not run)
Resamples from a distribution to generate a frequency table
Resamples from a distribution to generate a frequency table
## S4 method for signature 'FLQuant' resample(x, dim = 2:6, size, replace = T, ...) ## S4 method for signature 'FLQuant' resample(x, dim = 2:6, size, replace = T, ...)## S4 method for signature 'FLQuant' resample(x, dim = 2:6, size, replace = T, ...) ## S4 method for signature 'FLQuant' resample(x, dim = 2:6, size, replace = T, ...)
dim |
dimensions of |
size |
sum of frequency disribution |
replace |
sample with replacement?, defaults to |
... |
any other parameters |
object |
an |
a FLQuant with simulated frequency distribution
a FLQuant with simulated frequency distribution
## Not run: library(FLCore) data(ple4sex) apply(resample(catch.n(ple4sex)[,1:4],2, 100),2, sum) apply(resample(catch.n(ple4sex)[,1:4],2:3,100),2:3,sum) apply(resample(catch.n(ple4sex)[,1:4],1:2,100),1:2,sum) ## End(Not run) ## Not run: library(FLCore) data(ple4sex) apply(resample(catch.n(ple4sex)[,1:4],2, 100),2, sum) apply(resample(catch.n(ple4sex)[,1:4],2:3,100),2:3,sum) apply(resample(catch.n(ple4sex)[,1:4],1:2,100),1:2,sum) ## End(Not run)## Not run: library(FLCore) data(ple4sex) apply(resample(catch.n(ple4sex)[,1:4],2, 100),2, sum) apply(resample(catch.n(ple4sex)[,1:4],2:3,100),2:3,sum) apply(resample(catch.n(ple4sex)[,1:4],1:2,100),1:2,sum) ## End(Not run) ## Not run: library(FLCore) data(ple4sex) apply(resample(catch.n(ple4sex)[,1:4],2, 100),2, sum) apply(resample(catch.n(ple4sex)[,1:4],2:3,100),2:3,sum) apply(resample(catch.n(ple4sex)[,1:4],1:2,100),1:2,sum) ## End(Not run)
Sets the control slot in a biodyn object given the parameters in the params
slot. The starting values val are set to those in params and the min and
max bounds to .1 and 10 times these.
## S4 replacement method for signature 'biodyn,FLPar' setControl(object, min = 0.1, max = 10) <- value## S4 replacement method for signature 'biodyn,FLPar' setControl(object, min = 0.1, max = 10) <- value
object |
an object of class |
value |
|
... |
any other parameter |
## Not run: bd=sim() setControl(bd)=params(bd) ## End(Not run)## Not run: bd=sim() setControl(bd)=params(bd) ## End(Not run)
Sets catchability q and CV sigma in the params FLPar slot
for CPUE provided either an FLQuant or FLQuants
setParams(object) <- valuesetParams(object) <- value
object |
|
value |
CPUE as |
setParams<-
## Not run: setParams(bd)=cpue ## End(Not run)## Not run: setParams(bd)=cpue ## End(Not run)
Creates a biodyn object with known properties
## S4 method for signature 'missing,missing' sim( params = FLPar(r = 0.5, k = 1000, p = 1, b0 = 1), harvest = FLQuant(c(seq(0, 1.5, length.out = 30), rev(seq(0.5, 1.5, length.out = 15))[-1], rep(0.5, 5)) * (params["r"] * (1/(1 + params["p"])))), bounds = c(0.1, 10), p = NULL, b0 = NULL, ... )## S4 method for signature 'missing,missing' sim( params = FLPar(r = 0.5, k = 1000, p = 1, b0 = 1), harvest = FLQuant(c(seq(0, 1.5, length.out = 30), rev(seq(0.5, 1.5, length.out = 15))[-1], rep(0.5, 5)) * (params["r"] * (1/(1 + params["p"])))), bounds = c(0.1, 10), p = NULL, b0 = NULL, ... )
params |
surplus production parameters |
harvest |
|
bounds |
on |
... |
other arguments |
model |
character corresponding to model |
biodyn object with simulated time series
## Not run: bd=sim() ## End(Not run)## Not run: bd=sim() ## End(Not run)
Calculates the Total Allowable Catch for a biodyn object and target harvest rate
by projecting the last year.
## S4 method for signature 'biodyn' tac(object, harvest, ...)## S4 method for signature 'biodyn' tac(object, harvest, ...)
object |
an object of class |
harvest |
an |
... |
other arguments |
FLQuant object with TAC value(s)
## Not run: tac(bd,FLQuant(0.1,dimnames=list(year=dims(bd)$maxyear))) ## End(Not run)## Not run: tac(bd,FLQuant(0.1,dimnames=list(year=dims(bd)$maxyear))) ## End(Not run)
calculates time series of quantities useful for management
## S4 method for signature 'FLStock,FLPar' timeSeries(object, params, df = TRUE)## S4 method for signature 'FLStock,FLPar' timeSeries(object, params, df = TRUE)
object |
either FLStock biodyn or aspic classes |
Writes the ASPIC text input file inp to a file or connection.
The executable version of ASPIC uses an input file, this method generates that file
writeAspic(object, ...)writeAspic(object, ...)
object |
an apic object |
... |
any other parameter |
writeFLStock, readAspic
## Not run: writeAspic(albn,"aspic.inp") ## End(Not run)## Not run: writeAspic(albn,"aspic.inp") ## End(Not run)
Performs a cross-validation uisng a hindcast
## S4 method for signature 'biodyn,ANY' xval( object, index, minyear = range(object)["maxyear"] - 4, maxyear = range(object)["maxyear"] )## S4 method for signature 'biodyn,ANY' xval( object, index, minyear = range(object)["maxyear"] - 4, maxyear = range(object)["maxyear"] )
object |
an object of class |
index |
an |
minyear |
last year to fit data to |
maxyear |
last year to project to, by default is the last year in the catch |
Returns a data.frame with index, year, obs and hat
## Not run: data(bd) ## End(Not run)## Not run: data(bd) ## End(Not run)
Performs a cross-validation uisng a hindcast
## S4 method for signature 'biodyn,missing' xval( object, minyear = range(object)["maxyear"] - 4, maxyear = range(object)["maxyear"] )## S4 method for signature 'biodyn,missing' xval( object, minyear = range(object)["maxyear"] - 4, maxyear = range(object)["maxyear"] )
object |
an object of class |
minyear |
last year to fit data to |
maxyear |
last year to project to, by default is the last year in the catch |
index |
an |
xval
Returns a data.frame with index, year, obs and hat
## Not run: data(bd) ## End(Not run)## Not run: data(bd) ## End(Not run)