| 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.4 |
| Built: | 2026-10-24 06:16:26 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)
Biomass, harvest rate and catch from the biodyn, reference points
from mpb::refpts and the Pella-Tomlinson parameters, index fits
and residuals from the diags slot. The fitted index is
for every catch year, so a peel whose catch has
been projected one year beyond the last index observation provides a
one-step-ahead prediction for hindcasting. JABBA fits can be converted
with jabba2cmp, or via jabba2biodyn.
biodyn2cmp(object, name = "biodyn", peels = NULL)biodyn2cmp(object, name = "biodyn", peels = NULL)
object |
a |
name |
method label |
peels |
optional named list of |
a cmpAssess
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)
Autocorrelation of residuals for one or more assessments
cmpACF(x, type = c("resid", "process"), lag.max = 15)cmpACF(x, type = c("resid", "process"), lag.max = 15)
x |
a |
type |
|
lag.max |
maximum lag |
a ggplot
A cmpAssess is a list holding the outputs of an assessment in a
method-agnostic form, so that the cmp* plotting functions can
compare assessments from different methods. Converters are
spict2cmp, flbrp2cmp, biodyn2cmp
and jabba2cmp.
cmpAssess( name, ts, lower = NULL, upper = NULL, refpts = NULL, index = NULL, resid = NULL, process = NULL, curve = NULL, prior = NULL, peels = NULL )cmpAssess( name, ts, lower = NULL, upper = NULL, refpts = NULL, index = NULL, resid = NULL, process = NULL, curve = NULL, prior = NULL, peels = NULL )
name |
label for the method, used in legends |
ts |
|
lower, upper
|
optional |
refpts |
|
index |
data.frame of observations and fits with columns
|
resid |
data.frame of observation (e.g. one-step-ahead) residuals with
columns |
process |
data.frame of process residuals, columns as |
curve |
data.frame with columns |
prior |
data.frame of priors and posteriors, either densities
( |
peels |
named list of |
an object of class cmpAssess
Observations (points) and fits (lines, with ribbons when available) for
each series in the index element, coloured by method.
cmpFit(x, series = NULL)cmpFit(x, series = NULL)
x |
a |
series |
optional subset of series to plot |
a ggplot
Observations, the fits of each retrospective peel, and the
-year-ahead hindcast predictions with their confidence intervals,
with the MASE (see cmpMASE) annotated per method and series.
cmpHindcast(x, h = 1, nyears = 10, series = NULL)cmpHindcast(x, h = 1, nyears = 10, series = NULL)
x |
a |
h |
prediction horizon in years |
nyears |
number of years shown before the first hindcast year |
series |
optional subset of series |
a ggplot
For each peel with terminal year , takes the prediction of each
series years ahead () from the peel's index
element, and the observation for that year and the naive prediction
(the observation in year ) from the full run.
cmpHindcastDF(x, h = 1)cmpHindcastDF(x, h = 1)
x |
a |
h |
prediction horizon in years |
a data.frame with columns method, series, peel
(terminal year), year, obs, pred, lower,
upper and naive
Trajectories of against by method on the
red/yellow/green quadrants, with the terminal year and its 95%
confidence intervals as crosshairs.
cmpKobe(x, xlim = NULL, ylim = NULL, path = TRUE)cmpKobe(x, xlim = NULL, ylim = NULL, path = TRUE)
x |
a |
xlim, ylim
|
axis limits; default from the data |
path |
draw the trajectories |
a ggplot
MASE of hindcast predictions relative to a naive (random walk) prediction, on the log scale by default. MASE < 1 means the model predicts better than the naive prediction.
cmpMASE(obs, pred, naive, log = TRUE)cmpMASE(obs, pred, naive, log = TRUE)
obs |
observations |
pred |
model predictions |
naive |
naive predictions (e.g. the last observation) |
log |
calculate errors on the log scale |
numeric
Plots the prior element of each assessment. Densities are of
, plotted against on a log axis; draws are
converted to densities of . Priors are dashed and
posteriors solid, coloured by method.
cmpPriors(x, parameters = NULL)cmpPriors(x, parameters = NULL)
x |
a |
parameters |
optional subset of parameters |
a ggplot
Process residuals with runs tests for one or more assessments
cmpProcess(x, ncol = NULL)cmpProcess(x, ncol = NULL)
x |
a |
ncol |
number of panel columns |
a ggplot
The production function (or equilibrium yield curve) of each method,
with the realised surplus production computed
from its biomass and catch, and the MSY point.
cmpProduction(x, points = TRUE)cmpProduction(x, points = TRUE)
x |
a |
points |
show realised surplus production |
a ggplot
Normal QQ plot of residuals for one or more assessments
cmpQQ(x, type = c("resid", "process"))cmpQQ(x, type = c("resid", "process"))
x |
a |
type |
|
a ggplot
Peels of each method (peels element), with the confidence
interval of the full run and Mohn's rho annotated per method.
cmpRetro(x, quants = c("bbmsy", "ffmsy"))cmpRetro(x, quants = c("bbmsy", "ffmsy"))
x |
a |
quants |
quantities to plot |
a ggplot
Residuals (e.g. one-step-ahead for SPiCT, log(obs/hat) otherwise) with the 3-sigma band shaded green if the runs test is passed and red if not; points outside the band are outlined in red. One panel per method and series.
cmpRuns(x, ncol = NULL)cmpRuns(x, ncol = NULL)
x |
a |
ncol |
number of panel columns |
a ggplot
and with confidence intervals.
cmpStatus(x, ci = TRUE)cmpStatus(x, ci = TRUE)
x |
a |
ci |
show confidence intervals |
a ggplot
Annual estimates with 95% confidence intervals (ribbons), coloured by
method. Dashed lines are the reference points (,
, MSY, or 1 for the ratios) of each method.
cmpTS(x, quants = c("stock", "harvest", "catch"), refs = TRUE, ci = TRUE)cmpTS(x, quants = c("stock", "harvest", "catch"), refs = TRUE, ci = TRUE)
x |
a |
quants |
quantities to plot, from |
refs |
show reference points |
ci |
show confidence intervals |
a ggplot
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 )
Biomass is spawning stock or exploitable biomass, F is either the harvest
rate (catch/biomass, comparable with biomass dynamic models) or
, and the reference points and equilibrium yield curve come
from the FLBRP. and are the Pella-Tomlinson
parameters with the same MSY, and (if
FLRebuild is available). Iters in the FLStock give CIs.
flbrp2cmp( stk, brp, name = "FLBRP", biomass = c("eb", "ssb"), harvest = c("hr", "fbar"), index = NULL )flbrp2cmp( stk, brp, name = "FLBRP", biomass = c("eb", "ssb"), harvest = c("hr", "fbar"), index = NULL )
stk |
an |
brp |
an |
name |
method label |
biomass |
|
harvest |
|
index |
optional |
a cmpAssess
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, timing = 0, ... )## 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, timing = 0, ... )
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)
Coerce a JABBA fit to a biodyn
jabba2biodyn( object, phase = c(b0 = -1, r = 4, k = 3, p = -2, q = 2, sigma = 1), min = 0.1, max = 10 )jabba2biodyn( object, phase = c(b0 = -1, r = 4, k = 3, p = -2, q = 2, sigma = 1), min = 0.1, max = 10 )
object |
a JABBA fit (list returned by |
phase |
named vector of estimation phases. |
min, max
|
multipliers for the parameter bounds. |
a biodyn.
Uses the timeseries (posterior median and 95% CIs of B, F,
and ), estimates, diags
(index fits and residuals), pfunc (production function),
timeseries[, , "procB"] (process deviations) and
pars_posterior elements of a JABBA::fit_jabba result. Priors
for , and are taken from the JABBA input when
available (log-normal, as c(mean, log sd)).
jabba2cmp(object, name = "JABBA")jabba2cmp(object, name = "JABBA")
object |
a JABBA fit, or a list with elements |
name |
method label |
a cmpAssess
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)
Mean relative difference between the terminal-year estimate of each retrospective peel and the estimate for the same year in the reference (full) run.
mohnsRho(ref, peels)mohnsRho(ref, peels)
ref |
|
peels |
list of |
numeric
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)
Wrappers that convert a SPiCT fit with spict2cmp and call
the generic comparison plots: plotSpictTS (cmpTS),
plotSpictStatus (cmpStatus), plotSpictKobe
(cmpKobe), plotSpictProduction
(cmpProduction), plotSpictFit (cmpFit),
plotSpictRuns (cmpRuns, one-step-ahead residuals),
plotSpictProcess (cmpProcess), plotSpictACF
(cmpACF), plotSpictQQ (cmpQQ),
plotSpictRetro (cmpRetro), plotSpictHindcast
(cmpHindcast) and plotSpictPriors
(cmpPriors). The retrospective and hindcast use
spict::retro, run if fit$retro is missing. OSA and process
residuals are calculated if missing.
plotSpictTS(fit, scale = 1, ...) plotSpictStatus(fit, ...) plotSpictKobe(fit, ...) plotSpictProduction(fit, scale = 1, ...) plotSpictFit(fit, scale = 1, ...) plotSpictRuns(fit, ...) plotSpictProcess(fit, ...) plotSpictACF(fit, type = c("resid", "process"), ...) plotSpictQQ(fit, type = c("resid", "process"), ...) plotSpictRetro(fit, nretroyear = 5, ...) plotSpictHindcast(fit, nretroyear = 5, ...) plotSpictPriors(fit, ...)plotSpictTS(fit, scale = 1, ...) plotSpictStatus(fit, ...) plotSpictKobe(fit, ...) plotSpictProduction(fit, scale = 1, ...) plotSpictFit(fit, scale = 1, ...) plotSpictRuns(fit, ...) plotSpictProcess(fit, ...) plotSpictACF(fit, type = c("resid", "process"), ...) plotSpictQQ(fit, type = c("resid", "process"), ...) plotSpictRetro(fit, nretroyear = 5, ...) plotSpictHindcast(fit, nretroyear = 5, ...) plotSpictPriors(fit, ...)
fit |
a fitted SPiCT object |
scale |
multiplier for biomass and catch |
... |
passed to the generic plot |
type |
|
nretroyear |
number of peels if |
a ggplot
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
rebuildTime( object, target = NULL, nInitial = 100, growthRate = 0.25, minVal = 1e-06, maxVal = 1, burnin = 20, truncate = TRUE, ... )rebuildTime( 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)
Runs test for randomness and 3-sigma limits, as in
ss3diags::ssruns_sig3, implemented here so that it does not
depend on any assessment package.
runsTest(x, mixing = "less")runsTest(x, mixing = "less")
x |
residuals |
mixing |
alternative hypothesis, |
a list with p (runs test p-value) and lim (3-sigma
limits)
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)
Functions used by the spict vignette to fit SPiCT to an
FLStock with priors from the equilibrium reference points of an
FLBRP, and to compare the fit with the age-structured model.
spict, FLRebuild, ggplot2 and patchwork are
suggested packages and are checked when needed.
spictPar(fit, nm, i = 1) spictPriors( stk, brp, quant = c("eb", "ssb"), cv = c(r = 0.3, K = 0.5, n = 0.3, psi = 0.3), scale = 1 ) spictInp( stk, brp, quant = c("eb", "ssb"), scale = 1000, dteuler = 1/4, cv = c(r = 0.3, K = 0.5, n = 0.3, psi = 0.3), sdi = c(0.1, 0.5) ) spict2biodyn(fit, scale = 1) spictPrd(fit, xMax = 1.3, nX = 200) prdResid(B, C, year, pFn) plotPE(dat, cols = NULL) recoverBD(par, nyr = 50, b0 = 0.3)spictPar(fit, nm, i = 1) spictPriors( stk, brp, quant = c("eb", "ssb"), cv = c(r = 0.3, K = 0.5, n = 0.3, psi = 0.3), scale = 1 ) spictInp( stk, brp, quant = c("eb", "ssb"), scale = 1000, dteuler = 1/4, cv = c(r = 0.3, K = 0.5, n = 0.3, psi = 0.3), sdi = c(0.1, 0.5) ) spict2biodyn(fit, scale = 1) spictPrd(fit, xMax = 1.3, nX = 200) prdResid(B, C, year, pFn) plotPE(dat, cols = NULL) recoverBD(par, nyr = 50, b0 = 0.3)
fit |
a fitted SPiCT object (class |
nm |
parameter name, e.g. |
i |
row (time step) to return. |
stk |
an |
brp |
an |
quant |
biomass the biomass dynamic model represents, exploitable
( |
cv |
CVs of the log-normal priors on r, K, n and initial depletion. |
scale |
divisor for biomass and catch (e.g. 1000 for thousand tonnes). |
dteuler |
Euler time step. |
sdi |
mean and log-scale SD of the prior on the index observation
SD; |
xMax, nX
|
range (relative to K) and number of points for the curve. |
B, C, year
|
biomass, catch and year vectors. |
pFn |
production function of biomass, |
dat |
data.frame with year, b, rsdl and source. |
cols |
optional named vector of colours by source. |
par |
|
nyr |
number of years to project. |
b0 |
starting biomass relative to BMSY. |
spictPar: numeric vector of estimate and CV.
spictPriors: list with the Pella-Tomlinson parameters
(pars), initial depletion (psi), a summary table
(table) and SPiCT prior vectors (priors).
spictInp: a checked SPiCT input list.
spict2biodyn: a biodyn with r, K, p=n-1 and b0
from the fit, and the catch, index and annual SPiCT biomass, rescaled by
scale.
spictPrd: list with the production curve (pf) and the
annual trajectory (traj: year, b, bRel, sp, rsdl). Residuals are
SPiCT process residuals rescaled to annual log deviations.
prdResid: data.frame with year, b, sp and rsdl, the log
deviation of B[t+1] from a one-year step B[t]+pFn(B[t])-C[t].
plotPE: a patchwork of four ggplots.
recoverBD: data.frame of year and B/BMSY.
spictPar(): Estimate and CV of a SPiCT parameter
spictPriors(): Pella-Tomlinson priors for SPiCT from an FLBRP
spictInp(): SPiCT input from an FLStock, with priors from an FLBRP
spict2biodyn(): Coerce a SPiCT fit to a biodyn
spictPrd(): Production curve, realised surplus production and
process residuals from a SPiCT fit
prdResid(): Realised surplus production and process residuals
for a biomass and catch series and a production function
plotPE(): Four-panel process-error diagnostic (over time,
against biomass, autocorrelation and distribution), as used at WKBMSYSPiCT4
recoverBD(): Recovery at zero catch from a fraction of BMSY
Uses only the exported SPiCT API (spict::get.par) and the
inp, osar, process.resid and retro elements of
the fit. Biomass and F are at the start of each year; and
are the SPiCT estimates (with their own CIs); the reference
points are the deterministic ones. The index fit is , extended
one year past the last observation for hindcasting. Retrospective peels
are taken from fit$retro (see spict::retro).
spict2cmp( fit, name = "SPiCT", scale = 1, process = c("spict", "generic"), peels = TRUE )spict2cmp( fit, name = "SPiCT", scale = 1, process = c("spict", "generic"), peels = TRUE )
fit |
a fitted SPiCT object (class |
name |
method label |
scale |
multiplier for biomass, catch and index (e.g. 1000 if the fit is in thousand tonnes) |
process |
|
peels |
convert retrospective peels if present |
a cmpAssess
Returns annual estimates of biomass, F, catch, and
as FLQuants. If iter is given the
uncertainty is represented by independent log-normal draws in each year
(using the SPiCT standard errors on the log scale), so that
ggplotFL::plot() shows median and ribbons.
spict2FLQuants( fit, quants = c("B", "F", "Catch", "BBmsy", "FFmsy"), iter = NULL, seed = 1234 )spict2FLQuants( fit, quants = c("B", "F", "Catch", "BBmsy", "FFmsy"), iter = NULL, seed = 1234 )
fit |
a fitted SPiCT object |
quants |
quantities to return, see |
iter |
number of iterations; |
seed |
random seed used when |
FLQuants
Extracts annual (start of year) estimates and 95% confidence intervals of biomass, fishing mortality, catch and the MSY ratios from a SPiCT fit.
spictTS(fit, quants = c("B", "F", "Catch", "BBmsy", "FFmsy"))spictTS(fit, quants = c("B", "F", "Catch", "BBmsy", "FFmsy"))
fit |
a fitted SPiCT object (class |
quants |
which quantities, any of |
a data.frame with columns qname, year, data
(estimate), lower, upper and sd (log scale)
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)