| Title: | Reference point computation for advice rules |
|---|---|
| Description: | Blah |
| Authors: | Henning Winker [aut, cre] |
| Maintainer: | Henning Winker <[email protected]> |
| License: | EUPL |
| Version: | 1.14 |
| Built: | 2026-10-15 17:33:56 UTC |
| Source: | https://github.com/Henning-Winker/FLRef |
ABItgt() Computes ABI for target F, e.g. ABImsy (Griffith et al. 2023)
ABItgt(stock, ftgt = NULL, thresh = 0.9, ...)ABItgt(stock, ftgt = NULL, thresh = 0.9, ...)
stock |
object of class FLStock or FLStockR |
ftgt |
target F at equilibrium, e.g. Fmsy |
thresh |
quantile ageref treshold, default 0.9 |
*FLQuant*
data(ple4) ABImsy = ABItgt(ple4,ftgt=0.22,thresh=0.9) plot(ABImsy)+ylim(0,2)+ geom_hline(yintercept = c(0.8,1),col=c(2,1),linetype=c(2,1))+ylab(expression(ABI[MSY]))data(ple4) ABImsy = ABItgt(ple4,ftgt=0.22,thresh=0.9) plot(ABImsy)+ylim(0,2)+ geom_hline(yintercept = c(0.8,1),col=c(2,1),linetype=c(2,1))+ylab(expression(ABI[MSY]))
Combines numbers-at-age with an inverse age-length key and conditions the result on length to obtain age proportions within each length class.
ALK(N_a, iALK)ALK(N_a, iALK)
N_a |
Numeric vector of numbers-at-age for one sampling event. |
iALK |
Inverse age-length key returned by [iALK()]. |
An 'FLPar' containing age proportions by length class.
## Not run: alk <- ALK(N_a = c(100, 80, 50, 20), iALK = ialk) ## End(Not run)## Not run: alk <- ALK(N_a = c(100, 80, 50, 20), iALK = ialk) ## End(Not run)
Generates multinomial age samples within length classes from annual age-length keys. The number sampled in each length class is limited by 'nbin' and by the corresponding length-frequency sample.
alk.sample(lfds, alks, nbin = 20, n.sample = 1)alk.sample(lfds, alks, nbin = 20, n.sample = 1)
lfds |
An 'FLQuant' containing length-frequency data by year and iteration. |
alks |
An 'FLPars' object containing annual age-length keys, typically returned by [ALKs()]. |
nbin |
Maximum number of age observations sampled per length class. Defaults to '20'. |
n.sample |
Optional total length-sample size used to rescale 'lfds'. A value of '1' uses the supplied frequencies without rescaling. |
An 'FLPars' object containing sampled annual age-length keys.
## Not run: sampled_alks <- alk.sample(lfds, alks, nbin = 20) ## End(Not run)## Not run: sampled_alks <- alk.sample(lfds, alks, nbin = 20) ## End(Not run)
Combines annual numbers-at-age with an inverse age-length key and returns age proportions within each length class for every year and iteration.
ALKs(object, iALK)ALKs(object, iALK)
object |
An 'FLQuant' containing numbers-at-age by year and iteration. |
iALK |
Inverse age-length key returned by [iALK()]. |
An 'FLPars' object with one age-length key per year.
## Not run: alks <- ALKs(stock.n(stk), ialk) ## End(Not run)## Not run: alks <- ALKs(stock.n(stk), ialk) ## End(Not run)
Applies annual age-length keys to length-frequency data to estimate numbers-at-age by year and iteration.
applyALK(lfds, alks)applyALK(lfds, alks)
lfds |
An 'FLQuant' containing numbers-at-length. |
alks |
An annual 'FLPars' collection returned by [ALKs()], or a single 'FLPar' applied to every year. |
An 'FLQuant' containing estimated numbers-at-age.
## Not run: numbers_at_age <- applyALK(lfds, alks) ## End(Not run)## Not run: numbers_at_age <- applyALK(lfds, alks) ## End(Not run)
applyAR() Function to apply ICES Advice rule for F < MSY Btrigger
applyAR(b, btrigger, fmsy, bmin = 0, fmin = 0.001)applyAR(b, btrigger, fmsy, bmin = 0, fmin = 0.001)
b |
biomass |
btrigger |
if b below btrigger F is reduced |
fmsy |
Fmsy target |
bmin |
Option for de facto fishing closure (e.g. bmin = blim) |
fmin |
F below bmin |
F advice
Converts equilibrium reference-point information from an FLBRP object
into approximate Pella-Tomlinson surplus production model parameters. The
function derives the shape parameter m from the equilibrium ratio
Bmsy / B0, and derives the intrinsic productivity parameter r
from the harvest rate at MSY.
asem2spm( object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE, spcurve = FALSE ) asem2spm( object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE, spcurve = FALSE )asem2spm( object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE, spcurve = FALSE ) asem2spm( object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE, spcurve = FALSE )
object |
An |
quant |
Character. Biomass metric used to derive the SPM approximation.
Options are |
fmsy |
Optional fishing mortality at MSY. If |
rel |
Logical. If |
spcurve |
Logical. If |
The biomass quantity used for the approximation can be either vulnerable
biomass, quant = "vb", or spawning-stock biomass, quant = "ssb".
Optionally, the function can also return the equilibrium surplus production
curve implied by the supplied FLBRP object.
The function approximates the age-structured equilibrium yield curve with a Pella-Tomlinson production function:
The shape parameter m is solved numerically from the relationship:
and r is calculated from:
where Hmsy = MSY / Bmsy. For quant = "vb", Bmsy
and B0 are based on vulnerable biomass calculated by
vbbrp(). For quant = "ssb", they are based on
ssb().
This approximation is useful for deriving SPM-compatible prior means for
r and m, or for computing SPM-style process deviations from
age-structured stochastic projections.
prior means for r and m *FLPar*
If spcurve = FALSE, an FLPar object with approximate
surplus production parameters:
rIntrinsic productivity parameter of the Pella-Tomlinson surplus production model.
mPella-Tomlinson shape parameter.
BmsyKEquilibrium biomass ratio Bmsy / B0.
HmsyHarvest rate at MSY, calculated as
MSY / Bmsy.
MSYMaximum sustainable yield.
BmsyBiomass at MSY for the selected biomass metric.
B0Unfished biomass for the selected biomass metric.
FmsyFishing mortality at MSY.
If spcurve = TRUE, a list is returned with:
parsThe FLPar object described above.
curveA data frame with columns Biomass,
SP, and quant. If rel = TRUE, Biomass
is scaled by B0 and SP by MSY.
data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholt),spr0=mean(spr0y(ple4))) brp = brp(FLBRP(ple4,sr)) asem2spm(brp) plot_pf(brp) plot_pf(brp,rel=TRUE) ## Not run: data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = mean(spr0y(ple4)) ) brp <- brp(FLBRP(ple4, sr)) # Approximate SPM parameters using vulnerable biomass pars_vb <- asem2spm(brp, quant = "vb") pars_vb # Approximate SPM parameters using spawning biomass pars_ssb <- asem2spm(brp, quant = "ssb") pars_ssb # Return the surplus production curve in absolute units sp <- asem2spm(brp, quant = "vb", spcurve = TRUE) head(sp$curve) # Return the surplus production curve in relative units sp_rel <- asem2spm(brp, quant = "vb", spcurve = TRUE, rel = TRUE) head(sp_rel$curve) plot_pf(brp) plot_pf(brp, rel = TRUE) ## End(Not run)data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholt),spr0=mean(spr0y(ple4))) brp = brp(FLBRP(ple4,sr)) asem2spm(brp) plot_pf(brp) plot_pf(brp,rel=TRUE) ## Not run: data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = mean(spr0y(ple4)) ) brp <- brp(FLBRP(ple4, sr)) # Approximate SPM parameters using vulnerable biomass pars_vb <- asem2spm(brp, quant = "vb") pars_vb # Approximate SPM parameters using spawning biomass pars_ssb <- asem2spm(brp, quant = "ssb") pars_ssb # Return the surplus production curve in absolute units sp <- asem2spm(brp, quant = "vb", spcurve = TRUE) head(sp$curve) # Return the surplus production curve in relative units sp_rel <- asem2spm(brp, quant = "vb", spcurve = TRUE, rel = TRUE) head(sp_rel$curve) plot_pf(brp) plot_pf(brp, rel = TRUE) ## End(Not run)
generates FLIndexBiomass with random observation error from an FLStock
bioidx.sim(object, sel = catch.sel(object), sigma = 0.2, q = 0.001, rho = 0)bioidx.sim(object, sel = catch.sel(object), sigma = 0.2, q = 0.001, rho = 0)
object |
FLStock |
sel |
FLQuant with selectivity.pattern |
sigma |
observation error for log(index) |
q |
catchability coefficient for scaling |
FLIndexBiomass
data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=1.5,S95=2.1,Smax=4.5,Dcv=1,Dmin=0.1)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") object = propagate(ple4,10) sel = newselex(catch.sel(object),FLPar(S50=2.5,S95=3.2,Smax=3.5,Dcv=0.6,Dmin=0.2)) idx = bioidx.sim(object,sel=sel,q=0.0001) # Checks ggplot([email protected])+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") ggplot(idx@index)+geom_line(aes(year,data,col=ac(iter)))+theme(legend.position = "none")+ylab("Index")data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=1.5,S95=2.1,Smax=4.5,Dcv=1,Dmin=0.1)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") object = propagate(ple4,10) sel = newselex(catch.sel(object),FLPar(S50=2.5,S95=3.2,Smax=3.5,Dcv=0.6,Dmin=0.2)) idx = bioidx.sim(object,sel=sel,q=0.0001) # Checks ggplot(idx@sel.pattern)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") ggplot(idx@index)+geom_line(aes(year,data,col=ac(iter)))+theme(legend.position = "none")+ylab("Index")
Uses a bisection algorithm to find the value of a forecast control quantity
that gives a specified target value for a performance statistic. Typical use
cases include finding the constant fbar that gives a chosen risk level,
such as , over a projection period.
bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, refpts, statistic, years, pyears = years, tune, prob, tol = 0.01, maxit = 15, verbose = TRUE )bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, refpts, statistic, years, pyears = years, tune, prob, tol = 0.01, maxit = 15, verbose = TRUE )
stock |
An |
sr |
A stock-recruitment object or model passed to |
deviances |
Recruitment deviances used in the stochastic forecast.
Defaults to |
metrics |
A named list of metric functions passed to
|
refpts |
Reference points passed to |
statistic |
A named list defining the performance statistic to evaluate,
passed to |
years |
Projection years over which the forecast control is applied. |
pyears |
Years over which the performance statistic is evaluated.
Defaults to |
tune |
A named numeric vector or list giving the forecast quantity to
tune and its lower and upper bounds. For example,
|
prob |
Numeric. Target value of the performance statistic. For example,
|
tol |
Numeric. Absolute tolerance used to decide whether the target
statistic has been reached. Default is |
maxit |
Integer. Maximum number of bisection iterations. Default is
|
verbose |
Logical. If |
The function evaluates the forecast at the lower and upper bounds supplied in
tune. If the requested probability lies between the two outcomes, the
interval is repeatedly bisected until the performance statistic is within
tol of prob, or until maxit iterations are reached.
The bisection search requires that the target objective is bracketed by the
two values supplied in tune. In practice, this means that:
where is the performance statistic produced by forecasting with
control value , and is the target value supplied by
prob. If both bounds give performance statistics on the same side of
the target, the function cannot identify a unique bracketed solution.
The function is most useful for risk-based advice calculations, such as
finding the fishing mortality that gives a pre-specified probability of
falling below Blim over a future evaluation period.
If a solution is found, an FLStock object returned by
fwd() or ffwd() for the tuned control value. If the requested
target is already achieved at the lower or upper bound, the corresponding
forecast object is returned. If the supplied range does not bracket the
target statistic, a list with elements min and max is
returned, containing the forecasts at the lower and upper bounds.
Burden, R. L. and Faires, J. D. (1985). Numerical Analysis. 3rd edition. PWS Publishers. Section 2.1: The Bisection Algorithm.
## Not run: data(ple4) # Extend and propagate stock stock <- propagate(stf(ple4, end = 2118), 100) # Define a Beverton-Holt stock-recruitment relationship srr <- predictModel( model = rec ~ a * ssb * exp(-b * ssb), params = FLPar(a = 5.20, b = 1.65e-6) ) # Generate autocorrelated recruitment deviances devs <- ar1rlnorm( rho = 0.4, years = 2018:2118, iters = 100, meanlog = 0, sdlog = 0.5 ) # Define an ICES-style risk statistic statistic <- list( FP05 = list( ~ yearMeans((SB / SBlim) < 1), name = "P.05", desc = "ICES P.05" ) ) # Find fbar that gives P(SSB < Blim) = 0.05 fp05fwd <- bisect( stock = stock, sr = srr, deviances = devs, metrics = list(SB = ssb), refpts = FLPar(SBlim = 150000), statistic = statistic, years = 2018:2118, pyears = 2069:2118, tune = list(fbar = c(0.1, 1.0)), prob = 0.05 ) ## End(Not run)## Not run: data(ple4) # Extend and propagate stock stock <- propagate(stf(ple4, end = 2118), 100) # Define a Beverton-Holt stock-recruitment relationship srr <- predictModel( model = rec ~ a * ssb * exp(-b * ssb), params = FLPar(a = 5.20, b = 1.65e-6) ) # Generate autocorrelated recruitment deviances devs <- ar1rlnorm( rho = 0.4, years = 2018:2118, iters = 100, meanlog = 0, sdlog = 0.5 ) # Define an ICES-style risk statistic statistic <- list( FP05 = list( ~ yearMeans((SB / SBlim) < 1), name = "P.05", desc = "ICES P.05" ) ) # Find fbar that gives P(SSB < Blim) = 0.05 fp05fwd <- bisect( stock = stock, sr = srr, deviances = devs, metrics = list(SB = ssb), refpts = FLPar(SBlim = 150000), statistic = statistic, years = 2018:2118, pyears = 2069:2118, tune = list(fbar = c(0.1, 1.0)), prob = 0.05 ) ## End(Not run)
function to assign B[y+1] to B[y]. Warning correlation structure of B[y+1] and F[y] is meaningless
blag(mvn, verbose = TRUE)blag(mvn, verbose = TRUE)
mvn |
output list of quant posteriors and mle's
Henning Winker (GFCM)
Constructs, for each gear of a multigear operating model, the selectivity-at-length, the ALK-integrated selectivity-at-age, the capture-conditioned inverse age-length key, and (optionally) the Fbar-standardised selectivity and the gear's share of total F-at-age.
build_gear( gear_cfg, lhpar, age, amin = min(age), amax = max(age), lmin = 5, lmax_mult = 1.2, bin = 1, cv = 0.1, timing = 0, fbar_range = NULL, scale = TRUE )build_gear( gear_cfg, lhpar, age, amin = min(age), amax = max(age), lmin = 5, lmax_mult = 1.2, bin = 1, cv = 0.1, timing = 0, fbar_range = NULL, scale = TRUE )
gear_cfg |
Named list of gear configurations. Each gear must contain 'type' ('"logistic"', '"normal"' or '"dnormal"'), 'f_mult', 'ess_age' and 'ess_len'. Optional sampling-design entries:
All remaining entries are that type's selectivity parameters ('L50'/'L95'; 'Lpeak'/'sd'; 'Lpeak'/'sd_left'/'sd_right'). |
lhpar |
'FLPar' with at least 'linf', 'k' and 't0'. |
age |
Numeric vector of ages (the OM's age dimension). |
amin, amax
|
Minimum and maximum ages passed to [sel_la()]. |
lmin |
Lower limit of the length grid. Default '5'. |
lmax_mult |
Multiplier on 'linf' for the upper (plus-group) length. Default '1.2'. |
bin |
Length-bin width. Default '1'. |
cv |
Coefficient of variation of length-at-age. Default '0.1'. |
timing |
Within-year timing (fraction of a year) at which length-at-age is evaluated; growth uses 't0 - timing'. Use the mid-point of the fishing / sampling season (e.g. '0.5'). Default '0'. Can be overridden per gear by a 'timing' entry in 'gear_cfg'. |
fbar_range |
Optional ages defining Fbar, either the full vector ('3:19') or 'c(minfbar, maxfbar)'. When supplied, each gear additionally carries 'sel_a_fbar' and 'f_share' (see Value). Required by [f_age_gear()], [joint_sel()] and the static form of [catch_n_gear()]. |
scale |
Logical; scale 'sel_len' and 'sel_a' to a maximum of one. |
With the biological inverse ALK at 'timing' :
F partition. With the Fbar ages and
= 'f_mult', gear Fbar trajectories in the OM are
. Gear F-at-age and the share of total F
are then
which does not depend on year or iteration: as long as all gears follow proportional Fbar trajectories, the F-share (and hence the gear split of catch-at-age) is a property of the gear configuration and belongs here. If gear trajectories diverge, compute time-varying shares with [f_share_gear()] instead.
All quantities live on one length grid, [len_grid()] (= [iALK()]'s grid, last bin a plus group); selectivity is evaluated at its bin mid-points with [sel_logistic_len()], [sel_normal_len()] or [sel_dnormal_len()]. 'amin'/'amax' are kept for backward compatibility and are unused.
A named list, one element per gear, each a list with
Gear name.
Selectivity type.
'FLQuant' selectivity-at-length on the
reconciled length grid (lower bin limits as dimnames).
'FLQuant' ALK-integrated selectivity-at-age
, max-scaled if 'scale = TRUE'.
'FLQuant' ,
i.e. selectivity scaled to mean one over the Fbar ages, so that
. 'NULL' without
'fbar_range'.
'FLQuant' static share of total F-at-age taken by this
gear, (see Details). Sums to one over gears at every
age with non-zero F. 'NULL' without 'fbar_range'.
Data frame of lower, upper and mid lengths.
Matrix , ages in rows.
As supplied in 'gear_cfg'.
Sampling design (defaults '"fishery"', '1').
'lhpar', used as the default 'params' of [lfd.sim()].
Length-weight parameters 'c(a, b)' taken from 'lhpar' ('NULL' if 'lhpar' has no 'a'/'b').
Named vector of weight at length,
at bin mid-points (same units as
'a'/'b'), used by [lfd_sop()] to raise length samples to catch
weight.
List of 'lmin', 'lmax_mult', 'bin', 'cv', 'timing', 'fbar_range' used to build the gear. Downstream helpers ([plot_condALK_bias()], [lfd.sim()] when rebuilding the ALK) should default to these instead of repeating the arguments.
[joint_sel()], [f_age_gear()], [catch_n_gear()], [lfd.sim()]
## Not run: gear_cfg <- list( Trawl = list(type = "dnormal", Lpeak = 23.4, sd_left = 3.2, sd_right = 11.2, f_mult = 0.9, ess_age = 50, ess_len = 150), Gillnet = list(type = "logistic", L50 = 29.7, L95 = 34.1, f_mult = 0.1, ess_age = 30, ess_len = 100) ) om_gears <- build_gear(gear_cfg, lhpar = lhpars, age = 0:20, timing = 0.5, fbar_range = c(3, 19)) gear_par(om_gears, "f_mult") joint_sel(om_gears) ## End(Not run)## Not run: gear_cfg <- list( Trawl = list(type = "dnormal", Lpeak = 23.4, sd_left = 3.2, sd_right = 11.2, f_mult = 0.9, ess_age = 50, ess_len = 150), Gillnet = list(type = "logistic", L50 = 29.7, L95 = 34.1, f_mult = 0.1, ess_age = 30, ess_len = 100) ) om_gears <- build_gear(gear_cfg, lhpar = lhpars, age = 0:20, timing = 0.5, fbar_range = c(3, 19)) gear_par(om_gears, "f_mult") joint_sel(om_gears) ## End(Not run)
Generate catch.n with lognormal annual and multinomial age composition observation error
ca.sim( object, ess = 200, u = NULL, what = c("catch", "landings", "discards")[1], rescale = FALSE )ca.sim( object, ess = 200, u = NULL, what = c("catch", "landings", "discards")[1], rescale = FALSE )
object |
'FLQuant' of true numbers/catch-at-age. |
ess |
Effective sample size for the age-composition sample. |
u |
Optional. A '[ess, year, iter]' array of pre-generated 'Uniform(0,1)' deviates (e.g. from [rUnif_lfd()]) for CRN-safe sampling via [rmultinom_crn()]. If 'NULL' (default), sampling falls back to 'stats::rmultinom()' against the live RNG, i.e. the original 'ca.sim()' behaviour is unchanged. |
what |
One of '"catch"', '"landings"', '"discards"' (currently unused inside the function body, kept for interface compatibility with the original 'ca.sim()'). |
rescale |
Logical. If 'TRUE', rescale the sampled age composition back to the abundance scale of 'object' (sampled proportions x true total), rather than returning raw counts on the 'ess' scale. |
'FLQuant', same dimensions as 'object', with sampled catch-at-age (or rescaled proportions x true total, if 'rescale=TRUE').
## Not run: data(ple4) object <- propagate(catch.n(ple4), 10) ## original behaviour, unchanged ca1 <- ca.sim(object, ess = 200) ## CRN-safe: same u -> same sample, even if called twice u <- array(runif(200 * dim(object)[2] * 10), dim = c(200, dim(object)[2], 10)) ca2 <- ca.sim(object, ess = 200, u = u) ca3 <- ca.sim(object, ess = 200, u = u) stopifnot(identical(ca2, ca3)) ## End(Not run)## Not run: data(ple4) object <- propagate(catch.n(ple4), 10) ## original behaviour, unchanged ca1 <- ca.sim(object, ess = 200) ## CRN-safe: same u -> same sample, even if called twice u <- array(runif(200 * dim(object)[2] * 10), dim = c(200, dim(object)[2], 10)) ca2 <- ca.sim(object, ess = 200, u = u) ca3 <- ca.sim(object, ess = 200, u = u) stopifnot(identical(ca2, ca3)) ## End(Not run)
Sums gear catches over a window of years and normalises across gears:
Supplying the realised catch split over the LFD window (rather than the nominal 'f_mult') mirrors what an assessment would actually be given, and reflects that a gear's catch share differs from its Fbar share whenever gears select different ages.
catch_by_gear( catch_n, wt = NULL, years = NULL, iter = NULL, type = c("weight", "numbers") )catch_by_gear( catch_n, wt = NULL, years = NULL, iter = NULL, type = c("weight", "numbers") )
catch_n |
'FLQuants' of catch numbers-at-age by gear (from [catch_n_gear()]). |
wt |
'FLStock' (its 'catch.wt' is used) or an 'FLQuant' of weight-at-age. Ignored for 'type = "numbers"'. |
years |
Years to sum over (e.g. 'lfd_years'). Default all. |
iter |
Optional iteration(s). With a single 'iter' a named vector is returned; otherwise an 'iter x gear' matrix (one row per fit). |
type |
'"weight"' (default) or '"numbers"'. |
Named numeric vector or matrix of catch shares (rows sum to one).
## Not run: catch_by_gear(catch_n, om_hist, years = lfd_years, iter = 1) cbg <- catch_by_gear(catch_n, om_hist, years = lfd_years) # all iters fiticc(lfd_i, stklen_i, sel_fun = sel_fun, catch_by_gear = cbg[i, ]) ## End(Not run)## Not run: catch_by_gear(catch_n, om_hist, years = lfd_years, iter = 1) cbg <- catch_by_gear(catch_n, om_hist, years = lfd_years) # all iters fiticc(lfd_i, stklen_i, sel_fun = sel_fun, catch_by_gear = cbg[i, ]) ## End(Not run)
Catch by gear and year
catch_gear(catch_n, wt = NULL, type = c("weight", "numbers"))catch_gear(catch_n, wt = NULL, type = c("weight", "numbers"))
catch_n |
'FLQuants' of catch numbers-at-age by gear (from [catch_n_gear()]). |
wt |
'FLStock' (its 'catch.wt' is used) or an 'FLQuant' of weight-at-age. Ignored for 'type = "numbers"'. |
type |
'"weight"' (default) or '"numbers"'. |
'FLQuants' of annual catch by gear (age summed).
Splits the catch implied by the stock's realised total F among gears:
Because shares sum to one, equals the Baranov total
catch exactly. This is the canonical definition used by the OM and by the
OEM ('sampling.lfd.oem()'), which should call this function rather than
reproduce it.
catch_n_gear(stock, shares, years = dimnames(stock)$year, check = TRUE)catch_n_gear(stock, shares, years = dimnames(stock)$year, check = TRUE)
stock |
'FLStock' with realised 'stock.n', 'harvest' and 'm'. |
shares |
Either a list returned by [build_gear()] (static 'f_share', recycled over years and iterations) or 'FLQuants' of shares from [f_share_gear()]. |
years |
Years to compute. Default all years of 'stock'. |
check |
Logical; verify that gear catches sum to the Baranov total (relative tolerance '1e-8'). Default 'TRUE'. |
'FLQuants' of catch numbers-at-age by gear. The Baranov total is attached as 'attr(, "total")'.
## Not run: cn <- catch_n_gear(om_hist, om_gears, years = 1972:2024) # static shares cn <- catch_n_gear(om_hist, f_share_gear(f_age)) # time-varying ## End(Not run)## Not run: cn <- catch_n_gear(om_hist, om_gears, years = 1972:2024) # static shares cn <- catch_n_gear(om_hist, f_share_gear(f_age)) # time-varying ## End(Not run)
Combines gear-specific selectivity-at-age curves into a single joint selectivity-at-age curve using relative apical partial fishing mortality weights by gear.
combine_sel_age(object, fapic_rel, normalise_fapic = FALSE, scale = TRUE)combine_sel_age(object, fapic_rel, normalise_fapic = FALSE, scale = TRUE)
object |
A named list of gear-specific selectivity objects, such as 'sels$siganus_sutor'. Each gear object should contain 'sel_a' or 'sel_age'. |
fapic_rel |
Numeric vector of relative apical partial F contributions by gear. Preferably named, with names matching gears in 'object', for example 'c(traps = 1, gillnet = 0.3, linefish = 0.1)'. If unnamed, its length must match 'length(object)', and names are assigned from 'names(object)' in their existing order. |
normalise_fapic |
Logical. Should 'fapic_rel' be normalised to sum to one before combining curves? Default is 'FALSE'. For the final scaled selectivity shape this has no effect when 'scale = TRUE', but it may be useful for interpretation. |
scale |
Logical. Should the combined curve be scaled to a maximum of one? Default is 'TRUE'. |
Gear-specific selectivity curves are assumed to be scaled to a maximum of one. The combined raw fishing-mortality shape is calculated as:
'sel[a] = sum_g fapic_rel[g] * sel_g[a]'
If 'scale = TRUE', the combined curve is scaled to a maximum of one:
'sel[a] = sel[a] / max(sel)'
The weights are interpreted as relative apical partial F contributions by gear, not relative Fbar contributions. This avoids dependence on an arbitrary Fbar age range and is consistent with constructing fleet-specific fishing mortality as:
'F_g[a, y] = Fapic_g[y] * sel_g[a]'
before summing across gears.
An 'FLQuant' containing the combined selectivity-at-age.
## Not run: ## Preferred: named vector fapic_rel <- c(traps = 1, gillnet = 0.3, linefish = 0.1) sel_joint <- combine_sel_age( object = sels$siganus_sutor, fapic_rel = fapic_rel ) plot_sel_age(sel_joint) ## Convenience: unnamed vector matched to names(object) sel_joint <- combine_sel_age( object = sels$siganus_sutor, fapic_rel = c(1, 0.3, 0.1) ) ## End(Not run)## Not run: ## Preferred: named vector fapic_rel <- c(traps = 1, gillnet = 0.3, linefish = 0.1) sel_joint <- combine_sel_age( object = sels$siganus_sutor, fapic_rel = fapic_rel ) plot_sel_age(sel_joint) ## Convenience: unnamed vector matched to names(object) sel_joint <- combine_sel_age( object = sels$siganus_sutor, fapic_rel = c(1, 0.3, 0.1) ) ## End(Not run)
computeFbrp() Computes biological reference points corresponding to the proxy Fbrp
computeFbrp( stock, sr = "missing", proxy = NULL, x = NULL, blim = 0.1, type = c("b0", "btgt", "value"), btri = "missing", bpa = "missing", bthresh = "missing", verbose = T, fmax = 10, ... )computeFbrp( stock, sr = "missing", proxy = NULL, x = NULL, blim = 0.1, type = c("b0", "btgt", "value"), btri = "missing", bpa = "missing", bthresh = "missing", verbose = T, fmax = 10, ... )
stock |
object of class FLStock |
sr |
stock recruitment model of class FLSR |
proxy |
choice of Fmsy proxies (combinations permitted)
|
x |
basis in percent for sprx and bx, e.g. 40 for spr40 |
blim |
values < 1 are taken as fraction to B0 and blim > 1 as absolute values unless specified otherwise |
type |
type of blim input, values < 1 are
|
btri |
Btrigger can specified as absolute value |
bpa |
Bpa can specified as absolute value |
bthresh |
Bthresh (GFCM) interchangeable use with Bpa |
verbose |
|
fmax |
maximum Flim = max(Flim,fmax*Fbrp) |
brp object of class FLBRP with computed Fbrp reference points
data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1"),blim=0.1,type="b0") ploteq(brp,obs=TRUE,refpts="msy")data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1"),blim=0.1,type="b0") ploteq(brp,obs=TRUE,refpts="msy")
computeFbrps() Computes biological reference points corresponding to the proxy Fbrp
computeFbrps( stock, sr = "missing", proxy = c("sprx", "bx", "all"), fmsy = FALSE, f0.1 = TRUE, fmax = 5, verbose = T, ... )computeFbrps( stock, sr = "missing", proxy = c("sprx", "bx", "all"), fmsy = FALSE, f0.1 = TRUE, fmax = 5, verbose = T, ... )
stock |
object of class FLStock |
sr |
stock recruitment model of class FLSR |
fmsy |
if TRUE, Fmsy is computed (not suggest for segreg or geomean sr) |
f0.1 |
if TRUE, F0.1 is computed |
fmax |
maximum Flim = minfmax*Fbrp) |
verbose |
|
proxies |
choice of Fmsy proxies
|
brp object of class FLBRP with computed Fbrp reference points
Reweights an inverse age-length key by selectivity-at-length and normalises each age row to obtain the conditional distribution of length among fish caught by a gear.
condition_alk(ialk_mat, sel_len_vec)condition_alk(ialk_mat, sel_len_vec)
ialk_mat |
Numeric matrix with ages in rows and length classes in columns. Each age row should sum to one. |
sel_len_vec |
Named numeric vector of selectivity-at-length. Values are reordered to match 'colnames(ialk_mat)'. |
A numeric matrix with the same dimensions as 'ialk_mat'. Rows sum to one, except ages with zero selected probability, which are returned as zero rows.
with the Fbar-standardised selectivity stored by
[build_gear()]. By construction ‘fbar()' of each gear’s F-at-age equals the
input trajectory.
f_age_gear(stock, om_gears, fbar_gear)f_age_gear(stock, om_gears, fbar_gear)
stock |
'FLStock' providing the age / year / iter template (typically the propagated OM before 'fwd()'). |
om_gears |
Named list returned by [build_gear()] with 'fbar_range'. |
fbar_gear |
'FLQuants' of gear Fbar trajectories (year x iter), named as 'om_gears'. |
'FLQuants' of F-at-age by gear over the years of 'fbar_gear'.
## Not run: fbar_gear <- FLQuants(lapply(gear_par(om_gears, "f_mult"), function(w) f_hist_base * w)) f_age <- f_age_gear(stki, om_gears, fbar_gear) harvest(stki)[, dimnames(fbar_gear[[1]])$year] <- Reduce(`+`, f_age) ## End(Not run)## Not run: fbar_gear <- FLQuants(lapply(gear_par(om_gears, "f_mult"), function(w) f_hist_base * w)) f_age <- f_age_gear(stki, om_gears, fbar_gear) harvest(stki)[, dimnames(fbar_gear[[1]])$year] <- Reduce(`+`, f_age) ## End(Not run)
Fbrp() Extract Fbrp based reference points from output of computeFbrp
Fbrp(brp)Fbrp(brp)
brp |
input of class FLBRP from ComputeFbrp |
FLPar object with computed Fbrp reference points
Fe40() Patterson estimator for Fmsy
Fe40(stock, nyears = 3)Fe40(stock, nyears = 3)
stock |
input of class FLStock |
nyears |
number of years to average |
value
flr2stars()
flr2stars(object, uncertainty = NULL, quantiles = c(0.05, 0.95))flr2stars(object, uncertainty = NULL, quantiles = c(0.05, 0.95))
object |
of class FLStockR (MLE) |
uncertainty |
of class FLStock with iters |
quantities |
default is 90CIs as c(0.05,0.95) |
STARS list with $timeseris and $refpts
Fmmy() Uses opt.bisect to derive the F at Maximum Median Yield from stochastic simulations
Fmmy( brp, sigmaR = 0.5, rho = 0, nyears = 100, iters = 250, yrs.eval = NULL, range = "missing", tol = 0.001, maxit = 15, verbose = TRUE )Fmmy( brp, sigmaR = 0.5, rho = 0, nyears = 100, iters = 250, yrs.eval = NULL, range = "missing", tol = 0.001, maxit = 15, verbose = TRUE )
brp |
output object from computeFbrp() of class FLBRP |
sigmaR |
lognormal recruitment standard deviation |
rho |
AR1 recruitment autocorrelation coefficient |
nyears |
number of simulation years |
iters |
number simulation iterations |
yrs.eval |
last years to be used evaluation period, default nyears/2 |
range |
range of Fbar value to be evaluated |
tol |
tolerance |
maxit |
number of steps |
verbose |
cat comments |
list of FLPar, FLStock and FLBRP objects
data(ple4) bh = srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=spr0y(ple4)) brp = computeFbrp(ple4,bh,proxy=c("bx","msy"),x=35,blim=0.1) fmmy = Fmmy(brp,sigmaR=0.7,rho=0.3) getF(fmmy) # FMMY value plotFsim(fmmy) brpfmmy = computeFbrp(ple4,bh,proxy=getF(fmmy),blim=0.1) fsim = Fsim(brpfmmy,sigmaR=0.7,rho=0.3) plotFsim(fsim)data(ple4) bh = srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=spr0y(ple4)) brp = computeFbrp(ple4,bh,proxy=c("bx","msy"),x=35,blim=0.1) fmmy = Fmmy(brp,sigmaR=0.7,rho=0.3) getF(fmmy) # FMMY value plotFsim(fmmy) brpfmmy = computeFbrp(ple4,bh,proxy=getF(fmmy),blim=0.1) fsim = Fsim(brpfmmy,sigmaR=0.7,rho=0.3) plotFsim(fsim)
Calculates the Fbar value giving a maximum probability of ssb being below Blim of 5 percent
Fp05( object, iters = "missing", range = "missing", tol = 0.001, maxit = 20, verbose = TRUE )Fp05( object, iters = "missing", range = "missing", tol = 0.001, maxit = 20, verbose = TRUE )
object |
output from Fsim() |
iters |
Number of iterations, cannot exceed input object |
range |
range of Fbar value to be evaluated |
verbose |
Should progress be shown, TRUE. |
list
data(ple4) bh = srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=spr0y(ple4)) brp = computeFbrp(ple4,bh,proxy="bx",x=35,blim=0.2) # set Blim higher fsim = Fsim(brp,sigmaR=0.7,rho=0.3,iters=500) plotFsim(fsim) fp.05 = Fp05(fsim) plotFsim(fp.05,panels=c(2,4)) # black line is Fp0.05 getF(fp.05)data(ple4) bh = srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=spr0y(ple4)) brp = computeFbrp(ple4,bh,proxy="bx",x=35,blim=0.2) # set Blim higher fsim = Fsim(brp,sigmaR=0.7,rho=0.3,iters=500) plotFsim(fsim) fp.05 = Fp05(fsim) plotFsim(fp.05,panels=c(2,4)) # black line is Fp0.05 getF(fp.05)
Fsim() Simulates stochastic stock dynamics under under constant Fbrp
Fsim( brp, Ftgt = NULL, sigmaR = 0.5, rho = 0, nyears = 100, iters = 250, yrs.eval = NULL, verbose = TRUE )Fsim( brp, Ftgt = NULL, sigmaR = 0.5, rho = 0, nyears = 100, iters = 250, yrs.eval = NULL, verbose = TRUE )
brp |
output object from computeFbrp() of class FLBRP |
sigmaR |
lognormal recruitment standard deviation |
rho |
AR1 recruitment autocorrelation coefficient |
nyears |
number of simulation years |
iters |
number simulation iterations |
yrs.eval |
last years to be used evaluation period, default nyears/2 |
verbose |
cat comments |
list of FLPar, FLStock and FLBRP objects
data(ple4) hs = srrTMB(as.FLSR(ple4,model=segreg),spr0=spr0y(ple4),lplim=0.05,uplim=0.25) blim = params(hs)[[2]] brp = computeFbrp(ple4,hs,proxy=c("sprx","f0.1","msy"),x=40,blim=blim) ploteq(brp) fsim = Fsim(brp,sigmaR=0.7,rho=0.3) plotFsim(fsim) plotFsim(fsim,panels=2)data(ple4) hs = srrTMB(as.FLSR(ple4,model=segreg),spr0=spr0y(ple4),lplim=0.05,uplim=0.25) blim = params(hs)[[2]] brp = computeFbrp(ple4,hs,proxy=c("sprx","f0.1","msy"),x=40,blim=blim) ploteq(brp) fsim = Fsim(brp,sigmaR=0.7,rho=0.3) plotFsim(fsim) plotFsim(fsim,panels=2)
Runs stochastic FLR forward projections with ffwd() over a grid of
fishing mortality values. By default, the grid is taken from
fbar(brp), with the first value replaced by Fmsy. For each
F value, a corresponding FLBRP, FLStock, and FLSR
object is constructed, propagated over iterations, and projected forward
using recruitment deviances generated by rlnormar1().
Fsim_grid( brp, Fgrid = NULL, sigmaR = 0.5, rho = 0, nyears = 100, iters = 10, yrs.eval = NULL, parallel = FALSE, workers = NULL, progress = TRUE, verbose = TRUE )Fsim_grid( brp, Fgrid = NULL, sigmaR = 0.5, rho = 0, nyears = 100, iters = 10, yrs.eval = NULL, parallel = FALSE, workers = NULL, progress = TRUE, verbose = TRUE )
brp |
An |
Fgrid |
Optional numeric vector of fishing mortality values. If
|
sigmaR |
Numeric. Lognormal recruitment standard deviation. |
rho |
Numeric. AR(1) autocorrelation coefficient for recruitment deviances. |
nyears |
Integer. Number of projection years. |
iters |
Integer. Number of stochastic iterations. |
yrs.eval |
Optional integer. Number of final years intended for
evaluation. If |
parallel |
Logical. If |
workers |
Optional integer. Number of parallel workers. |
verbose |
Logical. If |
keep.stock |
Logical. Currently unused; retained for compatibility. |
The function is intended for exploring the emergent biomass process error
implied by an age-structured operating model under different constant
fishing mortality levels. The output can be passed to pe_sampler()
to obtain a data frame of depletion and process-error estimates.
The function constructs one FLBRP object per F value by replacing
fbar(brp) with a constant F. These objects are then converted to
FLStock and FLSR objects before stochastic forward projection.
Recruitment deviances are generated once using rlnormar1() and then
passed to each ffwd() call. This allows the F scenarios to be compared
under the same recruitment-deviation structure.
An FLStocks object containing one projected FLStock
per F value in the grid. The stocks are named using the corresponding
F values.
## Not run: data(ple4) ple4 <- merge_catch(ple4) bh <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = spr0y(ple4), r0 = NULL ) brp <- computeFbrp(ple4, bh, proxy = c("msy")) sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 20, parallel = TRUE, workers= 12 ) class(sim) names(sim) ## End(Not run)## Not run: data(ple4) ple4 <- merge_catch(ple4) bh <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = spr0y(ple4), r0 = NULL ) brp <- computeFbrp(ple4, bh, proxy = c("msy")) sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 20, parallel = TRUE, workers= 12 ) class(sim) names(sim) ## End(Not run)
generates an up-down-constant F-pattern
fudc( object, fref = 0.2, fhi = 2.5, flo = 0.8, sigmaF = 0.2, breaks = c(0.5, 0.75) )fudc( object, fref = 0.2, fhi = 2.5, flo = 0.8, sigmaF = 0.2, breaks = c(0.5, 0.75) )
object |
An *FLStock* |
fref |
reference denominator for fbar |
fhi |
factor for high F as fhi = fbar/fref |
flo |
factor for low F as flo = fbar/fref |
sigmaF |
variation on fbar |
breaks |
relative location of directional change |
FLQuant
data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fmsy = Fbrp(brp)["Fmsy"] stki = propagate(ple4,100) fy = fudc(ple4,fhi=2,flo=0.9,fref=fmsy,sigmaF=0) fyi = fudc(stki,fhi=2,flo=0.9,fref=fmsy,sigmaF=0.2) plot(fy,fyi)+ylab("F") #Forcasting om <- FLStockR(ffwd(stki,sr,fbar=fyi)) om@refpts = Fbrp(brp) plotAdvice(window(om,start=1960))data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fmsy = Fbrp(brp)["Fmsy"] stki = propagate(ple4,100) fy = fudc(ple4,fhi=2,flo=0.9,fref=fmsy,sigmaF=0) fyi = fudc(stki,fhi=2,flo=0.9,fref=fmsy,sigmaF=0.2) plot(fy,fyi)+ylab("F") #Forcasting om <- FLStockR(ffwd(stki,sr,fbar=fyi)) om@refpts = Fbrp(brp) plotAdvice(window(om,start=1960))
Function to summarise forecast results
Function to summarise ICES fishing opportunities
fwd2ices(stock, uncertainty, eval.yrs = NULL, dB = NULL, refyr = NULL) fwd2ices(stock, uncertainty, eval.yrs = NULL, dB = NULL, refyr = NULL)fwd2ices(stock, uncertainty, eval.yrs = NULL, dB = NULL, refyr = NULL) fwd2ices(stock, uncertainty, eval.yrs = NULL, dB = NULL, refyr = NULL)
uncertainty |
*FLStocks* with list of *FLStockR* objects and iters |
eval.yrs |
evaluation years of forecast |
dB |
computes change in percentage biomass to refyr |
refyr |
change in percentage biomass to refyr |
object |
*FLStocks* with list of *FLStockR* objects |
rel |
if TRUE ratios B/Btgt and F/Ftgt are shown |
stk |
*FLStocks* with list of *FLStockR* objects |
data.frame
data.frame
Function to summarise forecast results
fwd2stars(object, eval.yrs = NULL, rel = NULL, dB = NULL, refyr = NULL)fwd2stars(object, eval.yrs = NULL, rel = NULL, dB = NULL, refyr = NULL)
object |
*FLStocks* with list of *FLStockR* objects |
eval.yrs |
evaluation years of forecast |
rel |
if TRUE ratios B/Btgt and F/Ftgt are shown |
dB |
computes change in percentage biomass to refyr |
data.frame
Function to summarise Type 1 GFCM fishing opportunities
fwd2type1( stock, uncertainty = NULL, eval.yrs = NULL, dB = NULL, refyr = NULL, rel = NULL, osa = FALSE, maxdec = 2 )fwd2type1( stock, uncertainty = NULL, eval.yrs = NULL, dB = NULL, refyr = NULL, rel = NULL, osa = FALSE, maxdec = 2 )
uncertainty |
*FLStocks* with list of *FLStockR* objects and iters |
eval.yrs |
evaluation years of forecast |
refyr |
change in percentage biomass to refyr |
rel |
values of biomass and F are expressed relative to the target |
osa |
one-step-ahead for the biomass evaluation year |
maxdec |
maximum decimal |
stk |
*FLStocks* with list of *FLStockR* objects |
data.frame
fwdF4B () Bisection Function to search F for a given biomass
fwdF4B( stock, sr, btgt, nfy = 3, niy = 1, ival = niy, imet = "TAC", ftune = c(0, 2), tol = 0.001, verbose = TRUE, ssbQ = 1, recQ = 1 )fwdF4B( stock, sr, btgt, nfy = 3, niy = 1, ival = niy, imet = "TAC", ftune = c(0, 2), tol = 0.001, verbose = TRUE, ssbQ = 1, recQ = 1 )
stock |
FLStock object |
sr |
stock recruitment relationship |
btgt |
target biomass of the search |
nfy |
number of forecast (default 3) |
niy |
number of intermediate years (default 1) |
ival |
intermediate year value |
imet |
intermediate year metric ("TAC","F") |
ftune |
tuning limits for F search c(0.1,2) |
tol |
precision tolerance |
verbose |
*FLStock*
Builds with exactly the grid, CV and timing stored in
'gear$grid', so its columns always match 'gear$sel_len' and
'gear$condALK'. The upper limit is passed to [iALK()] explicitly via
‘max', so 'iALK()'’s own 'lmax' default can no longer diverge.
gear_ialk( gear, age = as.numeric(rownames(gear$condALK)), timing = gear$grid$timing %||% 0, params = gear$lhpar, model = vonbert, reflen = NULL )gear_ialk( gear, age = as.numeric(rownames(gear$condALK)), timing = gear$grid$timing %||% 0, params = gear$lhpar, model = vonbert, reflen = NULL )
gear |
A gear object from [build_gear()] (needs 'lhpar', 'grid'). |
age |
Ages. Default: rows of 'gear$condALK'. |
timing |
Within-year time; default 'gear$grid$timing'. |
params |
'FLPar' with 'linf', 'k', 't0'; default 'gear$lhpar'. |
model, reflen
|
Passed to [iALK()]. |
Age x length matrix (rows sum to one).
Extract a scalar gear entry across all gears
gear_par(om_gears, what)gear_par(om_gears, what)
om_gears |
Named list returned by [build_gear()]. |
what |
Name of a scalar entry, e.g. '"f_mult"', '"ess_age"', '"ess_len"', '"type"'. |
Named vector (numeric, or character for '"type"').
## Not run: gear_par(om_gears, "f_mult")## Not run: gear_par(om_gears, "f_mult")
Helper functio to extract F from various FLRef output
getF(x)getF(x)
x |
output object from computeFbrp() of class FLBRP |
huecol
huecol(n, alpha = 1)huecol(n, alpha = 1)
n |
number of colors |
alpha |
transluscency |
Constructs the probability distribution of length conditional on age from a growth model and a coefficient of variation in length-at-age.
iALK( params, model = vonbert, age, cv = 0.1, lmin = 5, lmax = 1.2, bin = 1, max = ceiling(linf * lmax), reflen = NULL )iALK( params, model = vonbert, age, cv = 0.1, lmin = 5, lmax = 1.2, bin = 1, max = ceiling(linf * lmax), reflen = NULL )
params |
Growth parameters coercible to an 'FLPar'. Parameters required by 'model' must be named; the default von Bertalanffy model uses 'linf', 'k', and 't0'. |
model |
Growth function or model object used to predict mean length-at-age. Defaults to 'vonbert'. |
age |
Numeric vector of ages. |
cv |
Numeric coefficient of variation in length-at-age. Defaults to '0.1'. |
lmin |
Numeric lower limit of the length grid. Defaults to '5'. |
lmax |
Numeric multiplier applied to 'linf' when calculating the upper length limit. Defaults to '1.2'. |
bin |
Numeric length-bin width. Defaults to '1'. |
max |
Numeric upper limit of the length grid. Defaults to 'ceiling(linf * lmax)'. |
reflen |
Optional reference length used to define a constant standard deviation as 'cv * reflen'. When 'NULL', the standard deviation is 'cv' times predicted length-at-age. |
An 'FLPar' containing an age-by-length inverse age-length key. Rows represent ages, columns represent length classes, and each age row sums to one.
## Not run: ialk <- iALK( params = FLPar(linf = 45, k = 0.4, t0 = -0.3), age = 0:5, lmin = 5, lmax = 1.2, bin = 1 ) ## End(Not run)## Not run: ialk <- iALK( params = FLPar(linf = 45, k = 0.4, t0 = -0.3), age = 0:5, lmin = 5, lmax = 1.2, bin = 1 ) ## End(Not run)
generates FLIndex with lognormal annual and multinomial age composition observation error
idx.sim( object, sel = catch.sel(object), ages = NULL, years = NULL, ess = 200, sigma = 0.2, q = 0.01 )idx.sim( object, sel = catch.sel(object), ages = NULL, years = NULL, ess = 200, sigma = 0.2, q = 0.01 )
object |
FLStock |
sel |
FLQuant with selectivity.pattern |
ages |
define age range |
years |
define year range |
ess |
effective sample size for age composition sample |
sigma |
annual observation error for log(q) |
q |
catchability coefficient for scaling |
FLIndex
data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=1.5,S95=2.1,Smax=4.5,Dcv=1,Dmin=0.1)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") object = propagate(ple4,10) idx = idx.sim(object,sel=sel,ess=200,sigma=0.2,q=0.01,years=1994:2017) # Checks ggplot([email protected])+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") ggplot(idx@index)+geom_line(aes(year,data,col=ac(iter)))+facet_wrap(~age,scales="free_y")+ theme(legend.position = "none")+ylab("Index")data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=1.5,S95=2.1,Smax=4.5,Dcv=1,Dmin=0.1)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") object = propagate(ple4,10) idx = idx.sim(object,sel=sel,ess=200,sigma=0.2,q=0.01,years=1994:2017) # Checks ggplot(idx@sel.pattern)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") ggplot(idx@index)+geom_line(aes(year,data,col=ac(iter)))+facet_wrap(~age,scales="free_y")+ theme(legend.position = "none")+ylab("Index")
jabba2FLStockR()
jabba2FLStockR()
jabba2FLStockR(jabba, blim = 0.3, bthr = 0.5, thin = 10, rel = FALSE) jabba2FLStockR(jabba, blim = 0.3, bthr = 0.5, thin = 10, rel = FALSE)jabba2FLStockR(jabba, blim = 0.3, bthr = 0.5, thin = 10, rel = FALSE) jabba2FLStockR(jabba, blim = 0.3, bthr = 0.5, thin = 10, rel = FALSE)
jabba |
fit from JABBA fit_jabba() or jabba$kbtrj |
blim |
biomass limit reference point as fraction of Bmsy |
thin |
thinnig rate of retained iters |
rel |
if TRUE ratios BBmsy and FFmsy are stored |
bpa |
biomass precautionary reference point as fraction of Bmsy |
FLStockR with refpts
FLStockR with refpts
jabba2stars()
jabba2stars(jabba, quantiles = c(0.05, 0.95), blim = 0.3, bthr = 0.5)jabba2stars(jabba, quantiles = c(0.05, 0.95), blim = 0.3, bthr = 0.5)
jabba |
fit from JABBA fit_jabba() or jabba$kbtrj |
quantiles |
default is 90CIs as c(0.05,0.95) |
blim |
biomass limit point as fraction of Bmsy, default 0.3Bmsy (ICES) |
bthr |
biomass precautionary point as fraction of Bmsy, default 0.5Bmsy (ICES) |
STARS list with $timeseris and $refpts
Combines gear selectivities on the Fbar scale, weighted by each gear's share of Fbar ('f_mult'):
This is the selectivity of total F implied by [f_age_gear()], and is what the aggregate 'FLBRP'/'FLStock' must carry for the equilibrium reference points to be consistent with the multigear dynamics.
joint_sel(om_gears, scale = TRUE)joint_sel(om_gears, scale = TRUE)
om_gears |
Named list returned by [build_gear()] with 'fbar_range'. |
scale |
Logical; scale to a maximum of one. Default 'TRUE'. |
Note that [combine_sel_age()] weights *max-scaled* curves by relative *apical* F; the two agree only if the weights are converted between bases. Use 'joint_sel()' whenever 'f_mult' is defined as a share of Fbar.
'FLQuant' of joint selectivity-at-age.
Lower bin limits 'seq(lmin, ceiling(linf * lmax_mult), bin)', exactly as
[iALK()] builds them; the last bin is the plus group
.
len_grid(linf, lmin = 5, lmax_mult = 1.2, bin = 1)len_grid(linf, lmin = 5, lmax_mult = 1.2, bin = 1)
linf |
Asymptotic length. |
lmin, lmax_mult, bin
|
Grid settings. |
Background: before this helper, 'sel_la()' (exclusive upper limit) and 'iALK()' (plus-group upper limit) built their grids differently, and every helper that rebuilt an 'iALK()' ('plot_condALK()', 'plot_condALK_bias()', 'lfd.sim(timing = )', 'sel_a_seasonal_avg()', 'wt_a_seasonal()', 'plot_sel_a_seasonal()') used its own default 'lmax_mult = 1.2'. With 'build_gear(lmax_mult = 1.3)' those helpers built a shorter grid than the gear's (e.g. 63 vs 69 bins for Linf = 55.7), and 'ialk take the grid from 'gear$grid' (via [gear_ialk()] or an explicit 'max').
Numeric vector of lower bin limits.
Projects numbers-at-age through an inverse age-length key at one or more within-year sampling times and draws a multinomial length sample. When a gear is supplied, the inverse key is conditioned on its selectivity-at-length.
len.sim( N_a, params, model = vonbert, ess = 250, timing = seq(0, 11/12, 1/12), unit = "cm", scale = TRUE, reflen = NULL, bin = gear$grid$bin %||% 1, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax = gear$grid$lmax_mult %||% 1.2, gear = NULL, u = NULL )len.sim( N_a, params, model = vonbert, ess = 250, timing = seq(0, 11/12, 1/12), unit = "cm", scale = TRUE, reflen = NULL, bin = gear$grid$bin %||% 1, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax = gear$grid$lmax_mult %||% 1.2, gear = NULL, u = NULL )
N_a |
An 'FLQuant' containing numbers-at-age or catch-at-age. |
params |
Growth parameters coercible to an 'FLPar'; the default growth model requires 'linf', 'k', and 't0'. |
model |
Growth function or model object. Defaults to 'vonbert'. |
ess |
Integer effective sample size. It is divided equally, after rounding, among the values in 'timing'. Defaults to '250'. |
timing |
Numeric vector of sampling times expressed as fractions of a year. Growth at time 't' is evaluated using 't0 - t'. Defaults to monthly sampling times from '0' to '11/12'. |
unit |
Character label for the length unit. Defaults to '"cm"'. |
scale |
Logical; if 'TRUE', rescale each year and iteration to the corresponding total in 'N_a'. |
reflen, bin, cv, lmin, lmax
|
Arguments passed to [iALK()] ('lmax' is the multiplier on 'linf'). When 'gear' is supplied, 'bin', 'cv', 'lmin' and 'lmax' default to 'gear$grid'. |
gear |
Optional gear object as returned by [build_gear()]. If supplied, 'gear$sel_len' is incorporated through [condition_alk()]. |
u |
Optional list of common-random-number arrays, one per timing event, as returned by [rUnif_len()]. If 'NULL', multinomial samples are drawn from the current random-number stream. |
This is a single-stage length sampler. In contrast, [lfd.sim()] first samples catch-at-age at low effective sample size and then conditions the length draw on that sampled age composition.
An 'FLQuant' containing sampled length frequencies by year and iteration.
## Not run: lfd_survey <- len.sim(stock.n(om)[, "2024"], params = lhpar, ess = 300, timing = 0.5) u_len <- rUnif_len(trawl, timing = seq(0, 11/12, 1/12), years = an(dimnames(N_a)$year), nsim = dims(N_a)$iter, seed = 456) lfd_survey_g <- len.sim(N_a, params = lhpar, ess = trawl$ess_len, timing = seq(0, 11/12, 1/12), gear = trawl, u = u_len) ## End(Not run)## Not run: lfd_survey <- len.sim(stock.n(om)[, "2024"], params = lhpar, ess = 300, timing = 0.5) u_len <- rUnif_len(trawl, timing = seq(0, 11/12, 1/12), years = an(dimnames(N_a)$year), nsim = dims(N_a)$iter, seed = 456) lfd_survey_g <- len.sim(N_a, params = lhpar, ess = trawl$ess_len, timing = seq(0, 11/12, 1/12), gear = trawl, u = u_len) ## End(Not run)
Builds 'observations$lfd' and 'observations$catch_gear' for [sampling.lfd.oem()] over 'years' (typically 'y0:fy') and fills the historical years with samples drawn by [sample_lfd_gears()], i.e. with the same code and, when 'u_lfd' is given, the same common random numbers the OEM will use. Templates have the season dimension implied by 'season', so they always match the OEM's output.
lfd_obs_init( stock, om_gears, years, hist_years, u_lfd = NULL, season = FALSE, f_share = NULL )lfd_obs_init( stock, om_gears, years, hist_years, u_lfd = NULL, season = FALSE, f_share = NULL )
stock |
OM 'FLStock' (all units). |
om_gears |
Gears: a named gear list (applied to every unit) or a list by unit of gear lists, as for [sampling.lfd.oem()]. |
years |
All years of the observation series. |
hist_years |
Years to fill with historical samples. |
u_lfd |
Common random numbers as for 'deviances$lfd' of [sampling.lfd.oem()]. |
season, f_share
|
As in [sampling.lfd.oem()]. |
A list with 'lfd' and 'catch_gear' ('FLQuants' by gear).
Length analogue of 'FLRef::sops()' (which raises catch-at-age with 'catch.wt'): scales each year/unit/iteration of a length sample so that its sum of products with weight-at-length equals the catch weight,
Years/units with zero sample or zero catch return zero. For a seasonal sample (season dimension > 1) and annual catch, one raising factor per year is computed from the sample pooled over seasons and applied to every season.
lfd_sop(lfd, wt_len, catch)lfd_sop(lfd, wt_len, catch)
lfd |
'FLQuant' length sample (len x year x unit x season x ... x iter). |
wt_len |
Named numeric weight-at-length (names = length bins of 'lfd'), e.g. 'gear$wt_len' from [build_gear()], or a gear object. |
catch |
'FLQuant' catch weight (year x unit x ... x iter) in the same units as 'wt_len'. |
'FLQuant' of raised numbers-at-length, with 'attr(, "raising")' the raising factor per year/unit/iter.
[sampling.lfd.oem()] ('lfd.raising = TRUE')
Empty length-sample template for a gear
lfd_template(gear, years, nsim, units = "unique", season = FALSE)lfd_template(gear, years, nsim, units = "unique", season = FALSE)
gear |
Gear object from [build_gear()]. |
years, nsim
|
Years and number of iterations. |
units |
'unit' dimnames (e.g. '"unique"', areas or sexes). |
season |
Logical; give gears with 'n_seasons > 1' a season dimension (as [sample_lfd_gears()] with 'season = TRUE'). |
'FLQuant' of zeros, len x year x unit x season x area x iter.
Generates fishery-dependent length-frequency data from gear-specific catch-at-age using a two-stage sampling design.
lfd.sim( object, gear, ess_age = gear$ess_age, ess_len = gear$ess_len, u_age = NULL, u_len = NULL, scale = TRUE, timing = NULL, params = gear$lhpar, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )lfd.sim( object, gear, ess_age = gear$ess_age, ess_len = gear$ess_len, u_age = NULL, u_len = NULL, scale = TRUE, timing = NULL, params = gear$lhpar, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )
object |
An 'FLQuant' containing true catch-at-age or numbers-at-age for one gear. |
gear |
Gear object returned by [build_gear()]. |
ess_age |
Integer effective sample size for the catch-at-age draw. |
ess_len |
Integer effective sample size for the length draw. |
u_age |
Optional common-random-number array with dimensions '[ess_age, year, iter]' for the age draw. |
u_len |
Optional common-random-number array for one sampling time, or a list of arrays when 'timing' contains multiple values. |
scale |
Logical; if 'TRUE', rescale each sampled length distribution to the corresponding total in 'object'. |
timing |
Optional numeric vector of within-year sampling times. If 'NULL', use the conditional ALK stored in 'gear'. Otherwise, rebuild the conditional ALK at each time using 't0 - timing'. |
params |
Growth parameters coercible to an 'FLPar'. Required when 'timing' is supplied. |
model |
Growth function or model object. Defaults to 'vonbert'. |
reflen, cv, lmin, lmax_mult, bin
|
Arguments for rebuilding the conditional ALK when 'timing' is supplied; 'cv', 'lmin', 'lmax_mult' and 'bin' default to 'gear$grid', so the rebuilt key always matches the gear. |
Sampling proceeds as follows:
A catch-at-age composition is sampled with effective sample size 'ess_age' using [ca.sim()].
The sampled age composition is projected through
and sampled at effective sample size 'ess_len'.
An 'FLQuant' containing sampled length frequencies by year and iteration.
## Not run: lfd_trawl <- lfd.sim(catch_n_gear$Trawl, trawl) devs <- rUnif_lfd(om_gears, years = an(dimnames(catch_n_gear$Trawl)$year), nsim = dim(catch_n_gear$Trawl)[6], seed = 456) lfd_trawl_crn <- lfd.sim( catch_n_gear$Trawl, trawl, u_age = devs$age$Trawl, u_len = devs$len$Trawl ) ## End(Not run)## Not run: lfd_trawl <- lfd.sim(catch_n_gear$Trawl, trawl) devs <- rUnif_lfd(om_gears, years = an(dimnames(catch_n_gear$Trawl)$year), nsim = dim(catch_n_gear$Trawl)[6], seed = 456) lfd_trawl_crn <- lfd.sim( catch_n_gear$Trawl, trawl, u_age = devs$age$Trawl, u_len = devs$len$Trawl ) ## End(Not run)
Applies [lfd.sim()] separately to each season of a season-structured catch-at-age object. Seasonal midpoint timing is '(season - 0.5) / n_seasons'.
lfd.sim.season( object, gear, n_seasons = dim(object)[4], ess_age = gear$ess_age, ess_len = gear$ess_len, params = gear$lhpar, u_age = NULL, u_len = NULL, season = TRUE, ... )lfd.sim.season( object, gear, n_seasons = dim(object)[4], ess_age = gear$ess_age, ess_len = gear$ess_len, params = gear$lhpar, u_age = NULL, u_len = NULL, season = TRUE, ... )
object |
An 'FLQuant' containing catch-at-age with a populated season dimension, e.g. annual gear catch-at-age multiplied by [season_fraction()]. |
gear |
Gear object returned by [build_gear()]. |
n_seasons |
Integer number of seasons. Defaults to the size of the season dimension in 'object'. |
ess_age, ess_len
|
Effective sample sizes. A scalar is the annual total, split among seasons so that the seasonal values sum exactly to it (largest remainder, [split_ess()]); a vector of length 'n_seasons' specifies season-specific values (e.g. 'c(0, 200, 200, 100)'). |
params |
Growth parameters coercible to an 'FLPar'; must contain 'linf', 'k', and 't0'. Defaults to 'gear$lhpar'. |
u_age, u_len
|
Optional common-random-number streams: lists of length 'n_seasons', element 's' a '[draw, year, iter]' array with 'ess_age[s]' ('ess_len[s]') draws, as returned by [rUnif_lfd()] for a gear with 'n_seasons > 1', subset to the years of 'object'. |
season |
Logical. 'TRUE' (default, as before) returns the samples in the season dimension; 'FALSE' returns the annual sample pooled over seasons with 'seasonSums()'. |
... |
Additional arguments passed to [lfd.sim()] (e.g. 'scale'). |
Each season is an independent sampling event: a stage-1 age sample of size 'ess_age[s]' and a stage-2 length sample of size 'ess_len[s]', with the conditional ALK rebuilt at the season mid-point. Together with [season_fraction()] this emulates continuous (monthly or quarterly) length sampling of a fishery from an annual operating model.
Scalar sample sizes were previously split with 'round(ess / n_seasons)', which does not preserve the total (e.g. 50 / 12 gave 48); they are now split exactly.
An 'FLQuant' of sampled length frequencies by season (or pooled over seasons when 'season = FALSE'), year and iteration.
## Not run: lfd.sim.season(obj, trawl, n_seasons = 4, params = lhpars) lfd.sim.season(obj, trawl, n_seasons = 4, ess_len = c(0, 200, 200, 100), params = lhpars) ## End(Not run)## Not run: lfd.sim.season(obj, trawl, n_seasons = 4, params = lhpars) lfd.sim.season(obj, trawl, n_seasons = 4, ess_len = c(0, 200, 200, 100), params = lhpars) ## End(Not run)
Converts an FLStock object with total catch numbers into a
landings-only stock by assigning catch.n to landings.n and
setting discards.n to zero. Landings and discards weights are then
recomputed.
merge_catch(stock)merge_catch(stock)
stock |
An |
This is a convenience function for cases where catch should be treated as landed catch, for example before forward projection or when preparing simplified single-fleet inputs. The function modifies:
landings.n(stock): set equal to catch.n(stock)
discards.n(stock): set to zero
landings(stock): recomputed with computeLandings()
discards(stock): recomputed with computeDiscards()
An FLStock object where all catch numbers are assigned to
landings and discards are set to zero.
## Not run: stock <- merge_catch(stock) # Check that discards have been removed range(discards.n(stock)) discards(stock) ## End(Not run)## Not run: stock <- merge_catch(stock) # Check that discards have been removed range(discards.n(stock)) discards(stock) ## End(Not run)
computes Lorenzen M with scaling option
Mlorenzen(object, Mref = "missing", Aref = 2)Mlorenzen(object, Mref = "missing", Aref = 2)
object |
weight-at-age of class *FLQuant* |
Mref |
reference M for scaling |
Aref |
reference Age for scaling |
FLQuant m()
data(ple4) Ml = Mlorenzen(stock.wt(ple4)) # Scale Ms = Mlorenzen(stock.wt(ple4),Mref=0.2,Aref=2) flqs = FLQuants(Lorenzen=Ml,Scaled=Ms)data(ple4) Ml = Mlorenzen(stock.wt(ple4)) # Scale Ms = Mlorenzen(stock.wt(ple4),Mref=0.2,Aref=2) flqs = FLQuants(Lorenzen=Ml,Scaled=Ms)
generates flexible 5-paramater selex curves
newselex(object, selexpars)newselex(object, selexpars)
object |
FLQuant from catch.sel() or sel.pattern() |
selexpars |
Selectivity Parameters selexpars S50, S95, Smax, Dcv, Dmin
|
FLquant with selectivity pattern
data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=2,S95=3,Smax=4.5,Dcv=0.6,Dmin=0.3)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") # Simulate harvest(ple4)[] = sel sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fbar(brp) = FLQuant(rep(0.01,70)) stk = as(brp,"FLStock") units(stk) = standardUnits(stk) its = 100 stk <- FLStockR(propagate(stk, its)) stk@refpts= Fbrp(brp) b0=an(Fbrp(brp)["B0"]) control = FLPar(Feq=0.15,Frate=0.1,Fsigma=0.15,SB0=b0,minyear=2,maxyear=70,its=its) run <- rffwd(stk, sr=sr,control=control,deviances=ar1rlnorm(0.3, 1:70, its, 0, 0.6)) plotAdvice(run)data(ple4) sel = newselex(catch.sel(ple4),FLPar(S50=2,S95=3,Smax=4.5,Dcv=0.6,Dmin=0.3)) ggplot(sel)+geom_line(aes(age,data))+ylab("Selectivity")+xlab("Age") # Simulate harvest(ple4)[] = sel sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fbar(brp) = FLQuant(rep(0.01,70)) stk = as(brp,"FLStock") units(stk) = standardUnits(stk) its = 100 stk <- FLStockR(propagate(stk, its)) stk@refpts= Fbrp(brp) b0=an(Fbrp(brp)["B0"]) control = FLPar(Feq=0.15,Frate=0.1,Fsigma=0.15,SB0=b0,minyear=2,maxyear=70,its=its) run <- rffwd(stk, sr=sr,control=control,deviances=ar1rlnorm(0.3, 1:70, its, 0, 0.6)) plotAdvice(run)
The plain bisection algorithm (Burden & Douglas, 1985) is employed here to find the value of a given forecast target quantity (e.g. 'fbar') for which a selected value of a performance statistic is obtained over a chosen period.
opt.bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, statistic, years, pyears = years, tune, tol = 0.001, maxit = 15, log = TRUE, verbose = TRUE )opt.bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, statistic, years, pyears = years, tune, tol = 0.001, maxit = 15, log = TRUE, verbose = TRUE )
stock |
object class FLStock |
sr |
object class FLSR |
metrics |
FLQuant of FLStock to be defined |
statistic |
|
years |
years to be evaluated |
tune |
range for input x |
tol |
tolerance level |
maxit |
number of optimisation steps |
log |
if TRUE, optimise on log-scale |
Credits to Iago Mosqueira
Burden, Richard L.; Faires, J. Douglas (1985), "2.1 The Bisection Algorithm", Numerical Analysis (3rd ed.), PWS Publishers, ISBN 0-87150-857-5
data(ple4) stock <- propagate(stf(ple4, end=2118), 200) srr <- predictModel(model=rec ~ ifelse(ssb <= b, a * ssb, a * b), params=FLPar(a=1.29, b=1.35e+06)) # GENERATE SRR deviances devs <- ar1rlnorm(rho=0.4, 2018:2118, iters=200, meanlog=0, sdlog=0.5) # DEFINE MMY statistic statistic <- list(MMY=list(~apply(L,1,median), name="MMY", desc="ICES Maximum Median Yield")) # CALL bisect over 100 years, Fmmy calculated over last 50. fmmy <- opt.bisect(stock, sr=srr, deviances=devs, metrics=list(L=landings), statistic=statistic, years=2018:2118, pyears=2069:2118, tune=list(fbar=c(0.01, 0.2))) # fmmy mean(fbar(fmmy)[,ac(2069:2118)])data(ple4) stock <- propagate(stf(ple4, end=2118), 200) srr <- predictModel(model=rec ~ ifelse(ssb <= b, a * ssb, a * b), params=FLPar(a=1.29, b=1.35e+06)) # GENERATE SRR deviances devs <- ar1rlnorm(rho=0.4, 2018:2118, iters=200, meanlog=0, sdlog=0.5) # DEFINE MMY statistic statistic <- list(MMY=list(~apply(L,1,median), name="MMY", desc="ICES Maximum Median Yield")) # CALL bisect over 100 years, Fmmy calculated over last 50. fmmy <- opt.bisect(stock, sr=srr, deviances=devs, metrics=list(L=landings), statistic=statistic, years=2018:2118, pyears=2069:2118, tune=list(fbar=c(0.01, 0.2))) # fmmy mean(fbar(fmmy)[,ac(2069:2118)])
Applies sample_proc_dev() to each projected stock in an
FLStocks object and returns a compact data frame of F, depletion,
and process-error estimates.
pe_sampler(stks, brp, biomass = c("vb", "ssb"), eps = 1e-12)pe_sampler(stks, brp, biomass = c("vb", "ssb"), eps = 1e-12)
stks |
An |
brp |
An |
biomass |
Character. Biomass metric to use. Either |
eps |
Numeric. Small positive value used to avoid logarithms of zero or negative predicted biomass. |
This is a convenience wrapper around sample_proc_dev(). It is useful
for producing the main diagnostic relationship:
The output can be plotted directly to visualise how the emergent biomass process error changes with stock depletion or fishing pressure.
A data.frame with one row per F scenario and columns:
Median fishing mortality in the projected stock.
Sampled biomass process-error standard deviation.
Median biomass relative to Bmsy.
Median biomass relative to B0.
## Not run: data(ple4) bh <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = spr0y(ple4), r0 = NULL ) brp <- computeFbrp(ple4, bh, proxy = c("msy")) sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 100, parallel = TRUE, workers = 4 ) ps <- pe_sampler(sim, brp, biomass = "vb") head(ps) plot_pe(ps) ## End(Not run)## Not run: data(ple4) bh <- srrTMB( as.FLSR(ple4, model = bevholt), spr0 = spr0y(ple4), r0 = NULL ) brp <- computeFbrp(ple4, bh, proxy = c("msy")) sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 100, parallel = TRUE, workers = 4 ) ps <- pe_sampler(sim, brp, biomass = "vb") head(ps) plot_pe(ps) ## End(Not run)
sets plus group on FLQuant
pgquant(object, pg)pgquant(object, pg)
object |
FLQuant |
pg |
FLQuant
UPDATED: the optional mean-length overlay is built with [gear_ialk()], so it uses the gear's own grid (any 'lmax_mult') and timing. Previously a hard-coded 'lmax_mult = 1.2' gave a non-conformable ' was built with a different 'lmax_mult', and 't = 0' biology was compared to 't = timing' catch.
plot_condALK(gear, params = NULL, low = "#FFFFCC", high = "#7F0000", ...)plot_condALK(gear, params = NULL, low = "#FFFFCC", high = "#7F0000", ...)
gear |
Gear object from [build_gear()]. |
params |
Optional 'FLPar' ('linf', 'k', 't0'). If supplied (or 'TRUE', meaning 'gear$lhpar'), overlays biological vs. capture-conditioned mean length-at-age. |
low, high
|
Fill colours. |
... |
Ignored; accepts the former 'cv', 'lmin', 'lmax_mult', 'bin' arguments, now taken from 'gear$grid'. |
A 'ggplot' object.
UPDATED: the raw biological line is now evaluated at the same within-year 'timing' (and grid) the gears were built with. Previously it was evaluated at 'timing = 0' while 'condALK' used 't0 - timing', so for 'timing = 0.5' half a year of growth appeared as "selectivity bias".
plot_condALK_bias( om_gears, params = om_gears[[1]]$lhpar, timing = om_gears[[1]]$grid$timing %||% 0, cv = om_gears[[1]]$grid$cv %||% 0.1, lmin = om_gears[[1]]$grid$lmin %||% 5, lmax_mult = om_gears[[1]]$grid$lmax_mult %||% 1.2, bin = om_gears[[1]]$grid$bin %||% 1 )plot_condALK_bias( om_gears, params = om_gears[[1]]$lhpar, timing = om_gears[[1]]$grid$timing %||% 0, cv = om_gears[[1]]$grid$cv %||% 0.1, lmin = om_gears[[1]]$grid$lmin %||% 5, lmax_mult = om_gears[[1]]$grid$lmax_mult %||% 1.2, bin = om_gears[[1]]$grid$bin %||% 1 )
om_gears |
Named list returned by [build_gear()]. |
params |
‘FLPar' with 'linf', 'k', 't0'. Default the gear’s 'lhpar'. |
timing, cv, lmin, lmax_mult, bin
|
Default to 'om_gears[[1]]$grid'. |
A 'ggplot' object.
Overlays the annual length composition (proportions) obtained under different sampling designs, e.g. one mid-year sample against monthly sampling pooled over the year, optionally with the expected composition. Seasonal samples are pooled with 'seasonSums()'.
plot_lfd_designs(designs, year, iter = 1, expected = NULL)plot_lfd_designs(designs, year, iter = 1, expected = NULL)
designs |
Named list of length-sample 'FLQuant's (same length bins). |
year |
Year to plot. |
iter |
Iteration. Default '1'. |
expected |
Optional named numeric vector of expected proportions (names = length bins), drawn as a dashed line. |
A 'ggplot' object.
Displays annual or seasonal length-frequency distributions along a continuous time axis, with one panel per gear. Optional von Bertalanffy cohort trajectories can be overlaid for reference.
plot_lfd_ridgeline( panels, lhpar = NULL, scale = 0.9, cohort_pad = 15, annual = FALSE )plot_lfd_ridgeline( panels, lhpar = NULL, scale = 0.9, cohort_pad = 15, annual = FALSE )
panels |
Named list of length-frequency 'FLQuant' objects. List names determine panel order and labels. |
lhpar |
Optional growth parameters containing 'linf', 'k', and 't0' for cohort reference lines. |
scale |
Numeric ridge-height multiplier. Defaults to '0.9'. |
cohort_pad |
Integer number of additional cohorts generated beyond each end of the plotted time range. Defaults to '15'. |
annual |
Logical; if 'TRUE', sum the season dimension before plotting. |
For seasonal data, ridge positions are calculated as 'year + (season - 0.5) / n_seasons'. When 'annual = TRUE', seasonal data are aggregated with 'seasonSums()'.
A 'ggplot' object.
## Not run: plot_lfd_ridgeline(lfds, lhpar = lhpars) plot_lfd_ridgeline(lfd_season, annual = TRUE, lhpar = lhpars) ## End(Not run)## Not run: plot_lfd_ridgeline(lfds, lhpar = lhpars) plot_lfd_ridgeline(lfd_season, annual = TRUE, lhpar = lhpars) ## End(Not run)
Plots seasonal length-frequency distributions for a selected year, with seasons distinguished by colour and gears shown in separate panels.
plot_lfd_season(lfd_season, year, iter = 1)plot_lfd_season(lfd_season, year, iter = 1)
lfd_season |
Named list of seasonal length-frequency 'FLQuant' objects. |
year |
Character or numeric year to plot. |
iter |
Integer simulation iteration. Defaults to '1'. |
A 'ggplot' object.
## Not run: plot_lfd_season(list(Trawl = lfd_season_trawl, Gillnet = lfd_season_gillnet), year = "2020") ## End(Not run)## Not run: plot_lfd_season(list(Trawl = lfd_season_trawl, Gillnet = lfd_season_gillnet), year = "2020") ## End(Not run)
Plots sampled biomass process error against biomass relative to Bmsy. Optionally both axes can be normalised relative to a reference row, typically row 1, which corresponds to the Fmsy scenario in Fsim_grid().
plot_pe(ps, rel = TRUE, ref = 1, line = TRUE, points = TRUE, reverse_x = FALSE)plot_pe(ps, rel = TRUE, ref = 1, line = TRUE, points = TRUE, reverse_x = FALSE)
ps |
data.frame returned by pe_sampler(), with columns sigma and bbmsy. |
rel |
Logical. If TRUE, both B/Bmsy and sigma are divided by their reference values. |
ref |
Integer. Reference row used for normalisation. Defaults to 1. |
line |
Logical. Add line. |
points |
Logical. Add points. |
reverse_x |
Logical. Reverse x-axis. |
A ggplot object.
plots production functions
plot_pf(object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE)plot_pf(object, quant = c("vb", "ssb"), fmsy = NULL, rel = FALSE)
object |
An *FLBRP* |
quant |
choose between vb and ssb or both |
fmsy |
default if Fmsy |
rel |
if TRUE ratios are produced for spcurve |
ggplot
data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = brp(FLBRP(ple4,sr)) asem2spm(brp)[1:4] plot_pf(brp) plot_pf(brp,rel=TRUE)data(ple4) ple4 <- merge_catch(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = brp(FLBRP(ple4,sr)) asem2spm(brp)[1:4] plot_pf(brp) plot_pf(brp,rel=TRUE)
Plots the selectivity-at-age stored in a gear object together with the corresponding seasonally averaged curve. Individual seasonal curves can be displayed as reference lines.
plot_sel_a_seasonal( gear, lhpar, age, n_seasons, show_seasons = TRUE, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )plot_sel_a_seasonal( gear, lhpar, age, n_seasons, show_seasons = TRUE, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )
gear |
Gear object returned by [build_gear()]. |
lhpar |
Life-history parameters containing 'linf', 'k', and 't0'. |
age |
Numeric vector of ages. |
n_seasons |
Integer number of equal within-year seasons. |
show_seasons |
Logical; if 'TRUE', add the individual seasonal curves. |
model |
Growth function or model object. Defaults to 'vonbert'. |
reflen |
Optional reference length passed to [iALK()]. |
cv, lmin, lmax_mult, bin
|
Length-at-age CV and length grid; default to 'gear$grid'. The key is always built on the grid of 'gear$sel_len'. |
A 'ggplot' object.
## Not run: plot_sel_a_seasonal( om_gears$Trawl, lhpars, age = 0:5, n_seasons = 12 ) ## End(Not run)## Not run: plot_sel_a_seasonal( om_gears$Trawl, lhpars, age = 0:5, n_seasons = 12 ) ## End(Not run)
Plots one or more selectivity-at-age curves stored as 'FLQuant' objects.
plot_sel_age( object, age_by = 1, points = TRUE, title = NULL, line_width = 0.7, point_size = 1.5, colours = NULL, ylab = "Selectivity", xlab = "Age" )plot_sel_age( object, age_by = 1, points = TRUE, title = NULL, line_width = 0.7, point_size = 1.5, colours = NULL, ylab = "Selectivity", xlab = "Age" )
object |
An 'FLQuant' containing selectivity-at-age, or a list of 'FLQuant' objects. If a list is supplied, each element is plotted as a separate curve. List names are used as legend labels. |
age_by |
Numeric. Spacing of age-axis breaks. Default is '1'. |
points |
Logical. Should points be added to the curves? Default is 'TRUE'. |
title |
Optional plot title. Can be a character string or expression. |
line_width |
Numeric. Line width passed to 'ggplot2::geom_line()'. Default is '0.7'. |
point_size |
Numeric. Point size passed to 'ggplot2::geom_point()'. Default is '1.5'. |
colours |
Optional named vector of colours. Names must match curve names. If 'NULL', ggplot2 default colours are used. |
ylab |
Character. Y-axis label. Default is '"Selectivity"'. |
xlab |
Character. X-axis label. Default is '"Age"'. |
The function accepts either a single 'FLQuant' or a named list of 'FLQuant' objects. It is intended for comparing joint or gear-specific selectivity-at-age curves used in operating models.
The age dimension is extracted from the 'age' dimension of each 'FLQuant'. Plus-group labels such as '"10+"' are converted to numeric values for plotting.
If a single 'FLQuant' is provided, the legend is suppressed. If a list of 'FLQuant' objects is provided, the legend is shown using the list names.
A 'ggplot' object.
## Not run: ## Single curve plot_sel_age(sel_joint) ## Multiple species sel_joint <- list( siganus = sel_joint_siganus, lethrinus = sel_joint_lethrinus, lutjanus = sel_joint_lutjanus, shark = sel_joint_shark ) plot_sel_age(sel_joint) ## End(Not run)## Not run: ## Single curve plot_sel_age(sel_joint) ## Multiple species sel_joint <- list( siganus = sel_joint_siganus, lethrinus = sel_joint_lethrinus, lutjanus = sel_joint_lutjanus, shark = sel_joint_shark ) plot_sel_age(sel_joint) ## End(Not run)
Plots selectivity-at-length and selectivity-at-age side by side for one selectivity object or for a named list of gear-specific selectivity objects.
plot_sel_la( object, ncol = 2, points_age = TRUE, title = NULL, line_width = 0.7, point_size = 1.5, len_by = 5, age_by = 1, colours = NULL )plot_sel_la( object, ncol = 2, points_age = TRUE, title = NULL, line_width = 0.7, point_size = 1.5, len_by = 5, age_by = 1, colours = NULL )
object |
A selectivity object returned by 'sel_la()', or a named list of such objects. For a single object, the function looks for 'sel_len' or 'sel_l', and for 'sel_age' or 'sel_a'. For a list, each element is assumed to represent one gear. |
ncol |
Numeric. Number of columns in the facet layout. Default is '2'. |
points_age |
Logical. Should points be added to the age-selectivity panel? Default is 'TRUE'. |
title |
Optional plot title. Can be a character string or expression. |
line_width |
Numeric. Line width passed to 'ggplot2::geom_line()'. Default is '0.7'. |
point_size |
Numeric. Point size for the age-selectivity panel. Default is '1.5'. |
len_by |
Numeric. Spacing of x-axis breaks for the length panel. Default is '5'. |
age_by |
Numeric. Spacing of x-axis breaks for the age panel. Default is '1'. |
colours |
Optional named vector of colours for gears. Names must match gear names. If 'NULL', ggplot2 default colours are used. |
The function is intended as a diagnostic plot for operating-model selectivity assumptions. It accepts objects returned by 'sel_la()', where selectivity-at-length and selectivity-at-age are stored as 'FLQuant' objects. If a named list is supplied, each element is treated as a gear and overlaid in both panels.
Length selectivity is plotted against length-bin midpoints when these are available through 'object$len_bins' or the '"len_bins"' attribute of the length 'FLQuant'. Otherwise, midpoints are inferred from the lower length-bin labels and the median bin width.
A 'ggplot' object.
## Not run: plot_sel_la(sels$lutjanus_bohar, len_by = 10, age_by = 1) plot_sel_la( sels$carcharhinus_melanopterus, len_by = 20, age_by = 2, title = expression(italic("Carcharhinus melanopterus")) ) ## End(Not run)## Not run: plot_sel_la(sels$lutjanus_bohar, len_by = 10, age_by = 1) plot_sel_la( sels$carcharhinus_melanopterus, len_by = 20, age_by = 2, title = expression(italic("Carcharhinus melanopterus")) ) ## End(Not run)
plotAdvice Plots stochastic stock dynamics against refpts for constant Fsim()
plotAdvice( object, rpts = "missing", type = NULL, yield = c("catch", "landings")[1], plotrefs = TRUE, probs = c(0.05, 0.2, 0.5, 0.8, 0.95), colour = "dodgerblue", ncol = NULL, osa = FALSE, label.size = 2.5, ssbQ = 1, recQ = 1 )plotAdvice( object, rpts = "missing", type = NULL, yield = c("catch", "landings")[1], plotrefs = TRUE, probs = c(0.05, 0.2, 0.5, 0.8, 0.95), colour = "dodgerblue", ncol = NULL, osa = FALSE, label.size = 2.5, ssbQ = 1, recQ = 1 )
type |
age-structured "asm" or surplus production "spm" plotting style |
yield |
option to select "catch" (default) or "landings" |
plotrefs |
if TRUE reference points are plotted |
probs |
determine credibility intervals, default 80th, 90th percentiles #' @param ncol number of plot panel columns |
colour |
color of CIs |
osa |
if TRUE it shows one-step-ahead for SSB and Rec |
label.size |
size of refpts labels |
ssbQ |
spawning quarter for seasonal models |
recQ |
recruitment quarter seasonal models |
stock |
FLStock or FLStockR |
refpts |
as FLPar or Fbrp() if FLStockR is not provided or should be overwritten |
ggplot
data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1","fe40"),blim=0.1,type="b0") plotAdvice (ple4,brp)data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1","fe40"),blim=0.1,type="b0") plotAdvice (ple4,brp)
plotAR Plots the new proposed ICES advice rule
plotAR( pars, ftgt = 1, btrigger = "missing", bpa = "missing", bthresh = "missing", fpa = "missing", fthresh = "missing", bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.2, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, label.cex = 3.5, critical = TRUE )plotAR( pars, ftgt = 1, btrigger = "missing", bpa = "missing", bthresh = "missing", fpa = "missing", fthresh = "missing", bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.2, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, label.cex = 3.5, critical = TRUE )
pars |
FLPar object or computeFbrp() ouput
|
ftgt |
factor to adjust Fmsy or its proxy e.g. 0.8Fmsy |
btrigger |
biomass trigger below which F is linearly reduced, if > 10 value, else factor*Btgt |
bpa |
precautionary biomass threshold, if > 10 value, else factor*Blim |
fpa |
option to input Fpa value |
bclose |
biomass that invokes fishing closure |
fmin |
minimum allowable (bycatch) fishing mortality under closure |
obs |
obtion to show observation with input class 'FLStock' |
kobe |
add kobe colour-coding |
alpha |
transparency of shading |
xmax |
multiplier for upper default xlim |
ymax |
multiplier for upper default ylim |
ylab |
option customize ylab |
xlab |
option customize xlab |
rel |
option to denote x,y labs as relative B/Btgt and F/Ftgt |
expand |
option to expand the plot area to border - default TRUE |
labels |
annotate reference point labels |
critical |
option to highlight critical zone below blim |
labelslabel.cex=3.5 |
set size of labels |
ggplot
data(ple4) srr = srrTMB(as.FLSR(ple4,model=segreg),spr0=spr0y(ple4)) blim = params(srr)[[2]] brp = computeFbrp(stock=ple4,sr=srr,proxy="f0.1",blim=blim) rpt = Fbrp(brp) plotAR(rpt,btrigger=an(0.8*rpt["Btgt"])) # Use Bpa as trigger (ICES style) plotAR(rpt,obs=ple4,bpa=1.4) # Change kobe to greyscale plotAR(rpt,obs=ple4,bpa=1.4,kobe=FALSE) # add fishing closure with minimum unavoidable F and Btrigger plotAR(rpt,obs=ple4,bpa=1.4,btrigger=0.7,kobe=TRUE,bclose=1,fmin=0.01) # show a relative plotAR(rpt,obs=ple4,rel=TRUE,bpa=1.4,btrigger=0.7,kobe=TRUE,bclose=1,fmin=0.02)data(ple4) srr = srrTMB(as.FLSR(ple4,model=segreg),spr0=spr0y(ple4)) blim = params(srr)[[2]] brp = computeFbrp(stock=ple4,sr=srr,proxy="f0.1",blim=blim) rpt = Fbrp(brp) plotAR(rpt,btrigger=an(0.8*rpt["Btgt"])) # Use Bpa as trigger (ICES style) plotAR(rpt,obs=ple4,bpa=1.4) # Change kobe to greyscale plotAR(rpt,obs=ple4,bpa=1.4,kobe=FALSE) # add fishing closure with minimum unavoidable F and Btrigger plotAR(rpt,obs=ple4,bpa=1.4,btrigger=0.7,kobe=TRUE,bclose=1,fmin=0.01) # show a relative plotAR(rpt,obs=ple4,rel=TRUE,bpa=1.4,btrigger=0.7,kobe=TRUE,bclose=1,fmin=0.02)
plotbioage() Plots stock N_a, W_a, M_a and Mat_a by year
plotbioage( stk, metrics = c("Weight", "Maturity", "M", "Selectivity"), bysex = FALSE, ncol = 2 )plotbioage( stk, metrics = c("Weight", "Maturity", "M", "Selectivity"), bysex = FALSE, ncol = 2 )
stk |
stock object class FLStock |
metrics |
choose Weight, Maturity, M, Selectivity |
bysex |
plot by sex default FALSE |
ncol |
number of columns in multiplot |
ggplot
data(ple4) plotbioage(ple4)data(ple4) plotbioage(ple4)
plotbioyr() Plots stock N_a, W_a, M_a and Mat_a across years
plotbioyr(stk, ncol = 2)plotbioyr(stk, ncol = 2)
stk |
stock object class FLStock |
ncol |
number of columns in multiplot |
ggplot
data(ple4) plotbioyr(ple4)data(ple4) plotbioyr(ple4)
Produces candidate GFCM advice plot
plotCECAF( ftgt = 1, btgt = 1, blim = 0.3, btrigger = "missing", bthr = 0.8, fthr = 1.2, bclose = 0.3, fmin = 0.2, fadv = 0.8, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = TRUE, expand = TRUE, labels = TRUE, critical = kobe, text = TRUE )plotCECAF( ftgt = 1, btgt = 1, blim = 0.3, btrigger = "missing", bthr = 0.8, fthr = 1.2, bclose = 0.3, fmin = 0.2, fadv = 0.8, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = TRUE, expand = TRUE, labels = TRUE, critical = kobe, text = TRUE )
btgt |
Btarget corresponding Ftgt |
blim |
biomass limit point used as fraction of Btgt, default 0.25-0.3Btgt |
btrigger |
biomass trigger (can differ from Bthr) |
bthr |
biomass precautionary point as fraction of Bmsy, default 0.5Btgt |
fthr |
upper Ftgt threshold, default 1.2 Ftgt |
bclose |
fishing closure |
fmin |
minimum F at closure |
fadv |
advice F from HCR |
obs |
"missing" option to show observed ssb,fba |
kobe |
if TRUE option to add KOBE colors |
alpha |
option for transparency |
xmax |
multiplier of btgt for ylim |
ymax |
multiplier of ftgt for xlim |
ylab |
|
xlab |
|
rel |
illustrate relative to btgt and ftgt if TRUE |
expand |
= TRUE graphic param |
labels |
if true add labels |
critical |
show area below Blim as dark red |
text |
show text |
ftg |
Ftarget |
GFCM advice plot
plotGFCM(fadv=0.95,btrigger=0.5)plotGFCM(fadv=0.95,btrigger=0.5)
plotdyn() Plots stock trajectories at age
plotdyn(stk, ncol = 2)plotdyn(stk, ncol = 2)
stk |
stock object class FLStock |
ncol |
number of columns in multiplot |
ggplot
data(ple4) plotdyn(ple4)data(ple4) plotdyn(ple4)
ploteq() Modification of method plot('FLBRP') to plot equilibrium output of computeFbrp()
ploteq( brps, refpts = "missing", obs = FALSE, rel = FALSE, rpf = TRUE, dashed = rpf, colours = "missing", panels = NULL, ncol = 2 )ploteq( brps, refpts = "missing", obs = FALSE, rel = FALSE, rpf = TRUE, dashed = rpf, colours = "missing", panels = NULL, ncol = 2 )
brps |
output object from computeFbrp of class FLBRP |
refpts |
Reference points, defaults are computed refpts from computeFbrp()
|
obs |
Should observations be plotted? Defaults to 'FALSE'. |
rel |
option to denote x,y labs as relative B/Btgt and F/Ftgt |
rpf |
adds refpts in plots |
dashed |
plots vertical dashed lines to highlight refpts locations |
colours |
refpts colours, default is designed for computeFbrp() output |
panels |
plot panel option 1:4 |
ncol |
number of plot panel columns |
ggplot
data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1","msy"),blim=0.1,type="b0") ploteq(brp,obs=TRUE) ploteq(brp,obs=TRUE,refpts="msy",rel=TRUE) brp.pa = computeFbrp(stock=ple4,sr=srr,proxy=c("msy","sprx","f0.1"),blim=0.1,bpa=Fbrp(brp)["Blim"]*2,type="b0") ploteq(brp.pa,obs=TRUE,rel=TRUE)data(ple4) srr = srrTMB(as.FLSR(ple4,model=rickerSV),spr0=spr0y(ple4)) brp = computeFbrp(stock=ple4,sr=srr,proxy=c("sprx","f0.1","msy"),blim=0.1,type="b0") ploteq(brp,obs=TRUE) ploteq(brp,obs=TRUE,refpts="msy",rel=TRUE) brp.pa = computeFbrp(stock=ple4,sr=srr,proxy=c("msy","sprx","f0.1"),blim=0.1,bpa=Fbrp(brp)["Blim"]*2,type="b0") ploteq(brp.pa,obs=TRUE,rel=TRUE)
plotFsim Plots stochastic stock dynamics against refpts for constant Fsim()
plotFsim( object, worms = TRUE, thinning = 10, probs = c(0.05, 0.2, 0.5, 0.8, 0.95), plotrefs = TRUE, colour = "missing", ncol = "missing", label.size = 3, yrs.eval = NULL, panels = "missing" )plotFsim( object, worms = TRUE, thinning = 10, probs = c(0.05, 0.2, 0.5, 0.8, 0.95), plotrefs = TRUE, colour = "missing", ncol = "missing", label.size = 3, yrs.eval = NULL, panels = "missing" )
object |
output object from Fsim() |
worms |
option to show individual iterations |
thinning |
thinning rate of iterations shows, e.g. 10 shows every 10th |
probs |
determine credibility intervals, default 80th, 90th percentiles |
plotrefs |
if TRUE reference points are plotted |
colour |
color of CIs |
ncol |
number of plot panel columns |
label.size |
size of reference points |
yrs.eval |
last years to be used evaluation period, default half nyears |
ggplot
Produces candidate GFCM advice plot
plotGFCM( ftgt = 1, btgt = 1, blim = 0.25, btrigger = "missing", bthr = 0.5, fthr = 1.2, bclose = 0, fmin = 0, fadv = 0.8, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = TRUE, expand = TRUE, labels = TRUE, critical = kobe, text = TRUE )plotGFCM( ftgt = 1, btgt = 1, blim = 0.25, btrigger = "missing", bthr = 0.5, fthr = 1.2, bclose = 0, fmin = 0, fadv = 0.8, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = TRUE, expand = TRUE, labels = TRUE, critical = kobe, text = TRUE )
btgt |
Btarget corresponding Ftgt |
blim |
biomass limit point used as fraction of Btgt, default 0.25-0.3Btgt |
btrigger |
biomass trigger (can differ from Bthr) |
bthr |
biomass precautionary point as fraction of Bmsy, default 0.5Btgt |
fthr |
upper Ftgt threshold, default 1.2 Ftgt |
bclose |
fishing closure |
fmin |
minimum F at closure |
fadv |
advice F from HCR |
obs |
"missing" option to show observed ssb,fba |
kobe |
if TRUE option to add KOBE colors |
alpha |
option for transparency |
xmax |
multiplier of btgt for ylim |
ymax |
multiplier of ftgt for xlim |
ylab |
|
xlab |
|
rel |
illustrate relative to btgt and ftgt if TRUE |
expand |
= TRUE graphic param |
labels |
if true add labels |
critical |
show area below Blim as dark red |
text |
show text |
ftg |
Ftarget |
GFCM advice plot
plotGFCM(fadv=0.95,btrigger=0.5)plotGFCM(fadv=0.95,btrigger=0.5)
Plots the new proposed ICES advice rule
plotMajuro( ftgt = 1, fthresh = 1.1, btgt = 1, blim = 0.1, btrigger = 0.8 * btgt, bthresh = 0.5 * btgt, bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.5, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, critical = kobe )plotMajuro( ftgt = 1, fthresh = 1.1, btgt = 1, blim = 0.1, btrigger = 0.8 * btgt, bthresh = 0.5 * btgt, bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.5, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, critical = kobe )
ftgt |
Target F = min(Fbrp,Fp0.5) |
btgt |
Biomass target corresponding to Fbrp |
blim |
biomass limit |
btrigger |
biomass trigger below which F is linearly reduced |
bthresh |
biomass threshold beyond which biomass is classified sustainable |
bclose |
biomass that invokes fishing closure |
fmin |
minimum allowable (bycatch) fishing mortality under closure |
obs |
obtion to show observation with input class 'FLStock' |
kobe |
add kobe colour-coding |
alpha |
transparency of shading |
xmax |
multiplier for upper default xlim |
ymax |
multiplier for upper default ylim |
ylab |
option customize ylab |
xlab |
option customize xlab |
rel |
option to denote x,y labs as relative B/Btgt and F/Ftgt |
expand |
option to expand the plot area to border - default TRUE |
labels |
annotate reference point labels |
critical |
option to highlight critical zone below blim |
ggplot
plotMajuro()plotMajuro()
plotspr() Plots current vs unfished spawning biomass per recruit at age
plotspr(stk, nyears = 3)plotspr(stk, nyears = 3)
stk |
stock object class FLStock |
nyears |
number of current last years, default is 3 |
ncol |
number of columns in multiplot |
ggplot
data(ple4) plotbioage(ple4)data(ple4) plotbioage(ple4)
plotWKREF Plots the newploiomass target corresponding to Fbrp
plotWKREF( ftgt = 1, btgt = 1, blim = 0.2, btrigger = 0.9 * btgt, bthresh = 0.8 * btgt, bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, critical = kobe )plotWKREF( ftgt = 1, btgt = 1, blim = 0.2, btrigger = 0.9 * btgt, bthresh = 0.8 * btgt, bclose = 0, fmin = 0, obs = "missing", kobe = TRUE, alpha = 1, xmax = 1.3, ymax = 1.5, ylab = "missing", xlab = "missing", rel = FALSE, expand = TRUE, labels = TRUE, critical = kobe )
blim |
biomass limit |
btrigger |
biomass trigger below which F is linearly reduced |
bthresh |
biomass threshold beyond which biomass is classified sustainable |
bclose |
ratio biomass/blim that invokes fishing closure relative to blim |
fmin |
minimum allowable (bycatch) fishing mortality under closure |
obs |
obtion to show observation with input class 'FLStock' |
kobe |
add kobe colour-coding |
alpha |
transparency of shading |
xmax |
multiplier for upper default xlim |
ymax |
multiplier for upper default ylim |
ylab |
option customize ylab |
xlab |
option customize xlab |
rel |
option to denote x,y labs as relative B/Btgt and F/Ftgt |
expand |
option to expand the plot area to border - default TRUE |
labels |
annotate reference point labels |
critical |
option to highlight critical zone below blim |
ggplot
plotWKREF() # Close fishery at Blim and adjust axis labels to relative plotWKREF(blim=0.2,bclose=0.2,rel=TRUE) # Close fishery at Blim, but allow fmin (e.g. bycatch) plotWKREF(blim=0.2,bclose=0.2,fmin=0.1,rel=TRUE) # Change Btrigger above Btgt plotWKREF(blim=0.2,bclose=0.2,fmin=0.1,btrigger=0.80,rel=TRUE) # Plot stock data data(ple4) plotWKREF(ftgt=0.25,btgt=8e+05,btrigger = 0.9*8e+05, blim=2e5,bclose=3e5,fmin=0.03,obs=ple4)plotWKREF() # Close fishery at Blim and adjust axis labels to relative plotWKREF(blim=0.2,bclose=0.2,rel=TRUE) # Close fishery at Blim, but allow fmin (e.g. bycatch) plotWKREF(blim=0.2,bclose=0.2,fmin=0.1,rel=TRUE) # Change Btrigger above Btgt plotWKREF(blim=0.2,bclose=0.2,fmin=0.1,btrigger=0.80,rel=TRUE) # Plot stock data data(ple4) plotWKREF(ftgt=0.25,btgt=8e+05,btrigger = 0.9*8e+05, blim=2e5,bclose=3e5,fmin=0.03,obs=ple4)
Propagates annual beginning-of-year numbers-at-age through equal within-year seasons under constant total instantaneous mortality.
pop_n_season(stock, n_seasons)pop_n_season(stock, n_seasons)
stock |
An 'FLStock' or 'FLStockR' containing annual stock numbers, fishing mortality, and natural mortality. |
n_seasons |
Integer number of equal within-year seasons. |
An 'FLQuant' containing numbers-at-age at the start of each season.
## Not run: seasonal_numbers <- pop_n_season(om_hist, n_seasons = 4) ## End(Not run)## Not run: seasonal_numbers <- pop_n_season(om_hist, n_seasons = 4) ## End(Not run)
r4sscol
rc4(n, alpha = 1)rc4(n, alpha = 1)
n |
number of colors |
alpha |
transluscency |
vector of color codes
The plain bisection algorithm (Burden & Douglas, 1985) is employed here to find the value of a given forecast target quantity (e.g. 'fbar') for which a selected value of a performance statistic is obtained over a chosen period.
ref.bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, refpts, statistic, years, pyears = years, tune, target = 1, tol = 0.01, maxit = 15, verbose = TRUE )ref.bisect( stock, sr, deviances = rec(stock) %=% 1, metrics, refpts, statistic, years, pyears = years, tune, target = 1, tol = 0.01, maxit = 15, verbose = TRUE )
stock |
object class FLStock |
sr |
object class FLSR |
metrics |
FLQuant of FLStock to be defined |
statistic |
|
years |
years to be evaluated |
tune |
range for input x |
target |
target with default 1 for ratios |
tol |
tolerance level |
maxit |
number of optimisation steps |
log |
if TRUE, optimise on log-scale |
Credits to Iago Mosqueira
Burden, Richard L.; Faires, J. Douglas (1985), "2.1 The Bisection Algorithm", Numerical Analysis (3rd ed.), PWS Publishers, ISBN 0-87150-857-5
rffwd() Project forward an FLStock with evolutionary Fbar
rffwd(object, sr, fbar = control, control = fbar, deviances = "missing")rffwd(object, sr, fbar = control, control = fbar, deviances = "missing")
object |
An *FLStock* |
sr |
A stock-recruit relationship, *FLSR* or *predictModel*. |
fbar |
Yearly target for average fishing mortality, *FLQuant*. |
control |
Yearly target for average fishing mortality, *FLPar*. |
deviances |
Deviances for the strock-recruit relationsip, *FLQuant*. |
The projected *FLStock* object.
data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fbar(brp) = FLQuant(rep(0.01,70)) stk = as(brp,"FLStock") units(stk) = standardUnits(stk) its = 100 stk <- FLStockR(propagate(stk, its)) stk@refpts= Fbrp(brp) b0=an(Fbrp(brp)["B0"]) control = FLPar(Feq=0.15,Frate=0.1,Fsigma=0.15,SB0=b0,minyear=2,maxyear=70,its=its) run <- rffwd(stk, sr=sr,control=control,deviances=ar1rlnorm(0.3, 1:70, its, 0, 0.6)) plotAdvice(run)data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = computeFbrp(ple4,sr,proxy="msy") fbar(brp) = FLQuant(rep(0.01,70)) stk = as(brp,"FLStock") units(stk) = standardUnits(stk) its = 100 stk <- FLStockR(propagate(stk, its)) stk@refpts= Fbrp(brp) b0=an(Fbrp(brp)["B0"]) control = FLPar(Feq=0.15,Frate=0.1,Fsigma=0.15,SB0=b0,minyear=2,maxyear=70,its=its) run <- rffwd(stk, sr=sr,control=control,deviances=ar1rlnorm(0.3, 1:70, its, 0, 0.6)) plotAdvice(run)
Function to characterize Productivity and refpts based on r and Generation
rGclass(r = NULL, gt = NULL)rGclass(r = NULL, gt = NULL)
r |
value of the intrinsic rate of population increase |
gt |
generation time G |
list with Productivity category and suggest Fbrps
Draws a multinomial sample of size 'length(u)' from probability vector 'p' by inverse-transform sampling: each element of 'u' is mapped to a category by comparing it against the cumulative probability vector 'cumsum(p)'. This is the standard device for common random numbers (CRN) in simulation studies – as long as the same 'u' is reused, the sampled category for a given draw only changes when 'p' itself changes, never because of an unrelated call to the random number generator elsewhere in the program.
rmultinom_crn(u, p)rmultinom_crn(u, p)
u |
Numeric vector of independent 'Uniform(0,1)' deviates, one per individual to be classified. Typically pre-generated once for an entire MSE run and reused across scenarios. |
p |
Numeric vector of category probabilities. Need not sum to 1 (renormalised internally); values that are 'NA', non-finite, or negative are treated as 0. |
Contrast with 'stats::rmultinom(n, size=1, prob=p)', which draws against R's live RNG stream and gives no control over which "slice" of that stream is consumed by which computation – two calls with different 'p' will in general use different underlying randomness even if seeded identically, once anything else in the program has touched the RNG in between.
Integer vector of length 'length(p)', the count landing in each category. Sums to 'length(u)', or to 0 if 'p' sums to a non-positive value (all-zero true proportions, e.g. no catch that year/iter).
set.seed(1) u <- runif(1000) p <- c(0.1, 0.3, 0.6) rmultinom_crn(u, p) # ~= c(100, 300, 600) ## CRN property: same u, slightly different p -> only the boundary shifts p2 <- c(0.12, 0.28, 0.60) rbind(rmultinom_crn(u, p), rmultinom_crn(u, p2)) ## degenerate case: all-zero probability vector rmultinom_crn(u, c(0, 0, 0)) # c(0, 0, 0), no errorset.seed(1) u <- runif(1000) p <- c(0.1, 0.3, 0.6) rmultinom_crn(u, p) # ~= c(100, 300, 600) ## CRN property: same u, slightly different p -> only the boundary shifts p2 <- c(0.12, 0.28, 0.60) rbind(rmultinom_crn(u, p), rmultinom_crn(u, p2)) ## degenerate case: all-zero probability vector rmultinom_crn(u, c(0, 0, 0)) # c(0, 0, 0), no error
Generates one array of uniform deviates for each within-year timing event for use by [len.sim()].
rUnif_len(gear, timing, years, nsim, seed = NULL)rUnif_len(gear, timing, years, nsim, seed = NULL)
gear |
Gear object returned by [build_gear()]. 'gear$ess_len' defines the total length-sample size. |
timing |
Numeric vector of within-year sampling times. |
years |
Vector of years. |
nsim |
Integer number of simulation iterations. |
seed |
Optional integer random seed. |
A list with one '[draw, year, iter]' array per timing event.
## Not run: u_len <- rUnif_len(trawl, timing = seq(0, 11/12, 1/12), years = 2025:2054, nsim = 100, seed = 456) length(u_len) # one array per timing event dim(u_len[[1]]) # ess_t x years x nsim ## End(Not run)## Not run: u_len <- rUnif_len(trawl, timing = seq(0, 11/12, 1/12), years = 2025:2054, nsim = 100, seed = 456) length(u_len) # one array per timing event dim(u_len[[1]]) # ess_t x years x nsim ## End(Not run)
Generates uniform-deviate arrays for the age and length stages of [lfd.sim()] for every gear.
rUnif_lfd(om_gears, years, nsim, seed = NULL)rUnif_lfd(om_gears, years, nsim, seed = NULL)
om_gears |
Named list of gear objects returned by [build_gear()] (one area; for several areas call it once per area). |
years |
Vector of years. |
nsim |
Integer number of simulation iterations. |
seed |
Optional integer random seed. |
Gears sampled once a year get exactly the same deviates as in earlier versions for the same 'seed'.
A list with components 'age' and 'len'. Each is a named list, one element per gear: a '[draw, year, iter]' array for gears sampled once a year, or, for gears with 'n_seasons > 1' (see [build_gear()]), a list of 'n_seasons' such arrays sized by the seasonal sample sizes ([split_ess()]), as expected by [lfd.sim.season()].
## Not run: om_gears <- list(Trawl = trawl, Gillnet = gillnet) devs <- rUnif_lfd(om_gears, years = 2025:2054, nsim = 100, seed = 456) ## End(Not run)## Not run: om_gears <- list(Trawl = trawl, Gillnet = gillnet) devs <- rUnif_lfd(om_gears, years = 2025:2054, nsim = 100, seed = 456) ## End(Not run)
sam2FLQuant()
sam2FLQuant( object, metric = c("ssb", "fbar", "catch", "rec")[1], what = c("mle") )sam2FLQuant( object, metric = c("ssb", "fbar", "catch", "rec")[1], what = c("mle") )
object |
fit from FLSAM |
forecast |
TRUE/FALSE |
FLQuant
adopted from Laurie Kell (biodyn)
sam2FLStockR()
sam2FLStockR(res, itsCI = 1000)sam2FLStockR(res, itsCI = 1000)
res |
fit from FLSAM |
itsCI |
number of iterations to depict uncertainty in plots |
FLStockR with refpts
sam2stars()
sam2stars(sam, refpts = NULL, quantiles = c(0.05, 0.95))sam2stars(sam, refpts = NULL, quantiles = c(0.05, 0.95))
sam |
fit from FLSAM |
refpts |
optional FLPar object with reference points |
STARS list with $timeseris and $refpts
The sampling step of [sampling.lfd.oem()] for one 'unit', exported so that sampling designs can be built and checked outside an MSE with exactly the code the OEM runs. For each gear in 'om_gears':
gear catch-at-age by [catch_n_gear()], one two-stage sample with [lfd.sim()] using the gear's conditional ALK (built at 'gear$grid$timing').
gear catch-at-age split into
seasons by [season_fraction()]; an independent two-stage
sample per season with [lfd.sim.season()] (ALK at each season
mid-point, 'ess_age' and 'ess_len' split among seasons). This emulates
continuous sampling of the fishery.
survey numbers-at-age at the gear's timing, [survey_n_gear()], one two-stage sample with [lfd.sim()].
sample_lfd_gears( stock, om_gears, years = dimnames(stock)$year, u_lfd = NULL, f_share = NULL, season = FALSE )sample_lfd_gears( stock, om_gears, years = dimnames(stock)$year, u_lfd = NULL, f_share = NULL, season = FALSE )
stock |
'FLStock' with a single 'unit' (subset areas or sexes first). |
om_gears |
Named list of gears from [build_gear()]. |
years |
Years to sample. |
u_lfd |
Optional common random numbers for this unit, as returned by [rUnif_lfd()] (spanning at least 'years'); 'NULL' uses the live RNG. |
f_share |
Optional 'FLQuants' of time-varying F shares for this unit (see [sampling.lfd.oem()]). |
season |
Logical. For gears with 'n_seasons > 1': 'TRUE' keeps the seasonal samples in the season dimension; 'FALSE' (default) returns the annual sample, pooled with 'seasonSums()'. Gears sampled once a year always have one season. |
A list with 'lfd' ('FLQuants' of raw sampled counts by gear, 'scale = FALSE') and 'catch_n' ('FLQuants' of annual catch-at-age for the fishery gears).
## Not run: gears <- build_gear(list( Commercial = list(type = "dnormal", Lpeak = 30, sd_left = 4, sd_right = 15, f_mult = 1, ess_age = 120, ess_len = 1200, n_seasons = 12), Survey = list(type = "logistic", L50 = 15, L95 = 20, obs = "survey", ess_age = 30, ess_len = 200, timing = 1/24)), lhpar = lhpar, age = 1:10, timing = 0.5, fbar_range = c(2, 6)) s <- sample_lfd_gears(ple4, gears, years = 2008:2017, season = TRUE) plot_lfd_ridgeline(s$lfd, lhpar = lhpar) ## End(Not run)## Not run: gears <- build_gear(list( Commercial = list(type = "dnormal", Lpeak = 30, sd_left = 4, sd_right = 15, f_mult = 1, ess_age = 120, ess_len = 1200, n_seasons = 12), Survey = list(type = "logistic", L50 = 15, L95 = 20, obs = "survey", ess_age = 30, ess_len = 200, timing = 1/24)), lhpar = lhpar, age = 1:10, timing = 0.5, fbar_range = c(2, 6)) s <- sample_lfd_gears(ple4, gears, years = 2008:2017, season = TRUE) plot_lfd_ridgeline(s$lfd, lhpar = lhpar) ## End(Not run)
Calculates biomass process deviations from a projected FLStock
by comparing the realised biomass transition with the deterministic
surplus-production expectation implied by asem2spm().
sample_proc_dev(stk, brp, biomass = c("vb", "ssb"), eps = 1e-12)sample_proc_dev(stk, brp, biomass = c("vb", "ssb"), eps = 1e-12)
stk |
A projected |
brp |
An |
biomass |
Character. Biomass metric to use. Either |
eps |
Numeric. Small positive value used to avoid taking the logarithm of zero or negative predicted biomass. |
The process deviation is calculated as:
where , , , and are obtained from
asem2spm(brp, quant = biomass).
This corresponds to sampling the residual process variation around the SPM-equivalent biomass transition:
A list with elements:
A one-row data.frame with median F, process-error
standard deviation, median B/Bmsy, and median B/B0.
An FLQuant of log biomass process deviations.
The equivalent surplus-production parameters from
asem2spm().
Standard deviation of the sampled process deviations.
Biomass relative to Bmsy.
Median biomass relative to B0.
The biomass metric used.
## Not run: sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 100 ) one <- sample_proc_dev( stk = sim[[1]], brp = brp, biomass = "vb" ) one$output one$sigma ## End(Not run)## Not run: sim <- Fsim_grid( brp, sigmaR = 0.5, rho = 0.3, nyears = 100, iters = 100 ) one <- sample_proc_dev( stk = sim[[1]], brp = brp, biomass = "vb" ) one$output one$sigma ## End(Not run)
An 'FLoem' method for 'mse::mp()' that generates fishery-dependent and survey length-frequency (LFD) samples and a reported catch split by gear (and, optionally, by area), as a structural analogue of 'mse::sampling.oem()'. The abundance-index block of 'sampling.oem()' is replaced by an LFD block: for each 'unit', [sample_lfd_gears()] partitions true catch-at-age by gear with [catch_n_gear()] and passes it through the two-stage sampler [lfd.sim()], once a year or within the year ([lfd.sim.season()]), and samples survey gears from numbers-at-age at the survey timing ([survey_n_gear()]).
sampling.lfd.oem( stk, deviances, observations, args, tracking, om_gears, f_share = NULL, season = FALSE, lfd.raising = FALSE, lfd.scale = c("sample", "catch") )sampling.lfd.oem( stk, deviances, observations, args, tracking, om_gears, f_share = NULL, season = FALSE, lfd.raising = FALSE, lfd.scale = c("sample", "catch") )
stk |
'FLStock' passed by 'mp()' (the OM stock). |
deviances |
List with optional elements
|
observations |
List with elements
|
args |
'mp()' arguments; uses 'y0', 'dy', 'dys'. 'y0' must be set in ‘mp()'’s own 'args' (the first year of the LFD series), not in 'FLoem(args = )'. |
tracking |
'mp()' tracking object, returned unchanged. |
om_gears |
Gear objects from [build_gear()] (built with 'fbar_range', so each gear carries 'f_share'). Single area: the named list of gears. Multiple areas: a list named by area (matching 'dimnames(stk)$unit') of named gear lists; a gear may be absent from an area. A plain gear list with a multi-unit stock is applied to every area. Each gear's sampling design is part of the gear: 'obs' ('"fishery"' or '"survey"'), 'timing' and 'n_seasons' (see [build_gear()]). |
f_share |
Optional 'FLQuants' named by gear of time-varying shares of total F-at-age (age x year x unit x iter, covering the projection years), e.g. from [f_share_gear()]. Default ‘NULL' uses each gear’s static 'f_share', which is exact whenever gear Fbar trajectories are proportional and needs no extension into the projection period. |
season |
Logical. For gears sampled within the year ('n_seasons > 1'): 'TRUE' keeps each seasonal sample in the season dimension of 'observations$lfd' and of the samples passed to 'est' (for a seasonal assessment, e.g. FLicc with seasonal transitions); 'FALSE' (default) pools them into one annual sample with 'seasonSums()'. Surveys and gears sampled once a year always have one season. |
lfd.raising |
Logical. If 'TRUE' (intended for more than one unit), the per-unit fishery samples passed to ‘est' are raised to each unit’s reported gear catch by sum of products with the gear's weight-at-length ('gear$wt_len', from 'a' and 'b' in 'lhpar'; see [lfd_sop()]) and summed over units, so the pooled length composition is weighted by catch per unit rather than by sample size per unit. Seasonal samples are raised with one factor per year and unit. Survey samples are summed over units. The reported catch by gear is summed over units as well. 'observations$lfd' always keeps the raw samples by unit. Default 'FALSE' passes the samples by unit unchanged. |
lfd.scale |
With 'lfd.raising = TRUE': '"sample"' (default) rescales the pooled, catch-weighted LFD to the total number of fish measured across units, so the sample size seen by the likelihood is the real one; '"catch"' keeps the raised numbers caught (requires 'wt_len' and catch in the same units). |
A single-area stock (one 'unit', typically '"unique"') is the default case. Multiple areas are represented by the 'unit' dimension of the operating-model stock, each area with its own gear set.
Each call is incremental, as in 'sampling.oem()': only years 'dys' are simulated and written into 'observations', so each CRN deviate is used once and the same 'FLoem' gives identical sampling noise to every MP.
For area , gear and year 'dys':
gear catch-at-age by the partial Baranov equation,
, using the OM's realised F and the
(possibly noised) stock;
two-stage LFD sample with [lfd.sim()]: a multinomial age sample of
size ‘ess_age', projected through the gear’s and
sampled with size 'ess_len'. With 'n_seasons = S > 1', the catch is
first split into seasons,
([season_fraction()]), and each season is an independent sample at
its mid-point with 'ess_age', 'ess_len' split among seasons;
surveys: sampled with
[lfd.sim()] at the survey timing ;
reported catch weight (fishery gears)
.
Raising across units ('lfd.raising = TRUE'). For gear ,
year and unit with sampled counts and
reported catch weight :
Without raising, a unit that is heavily sampled relative to its catch would dominate the pooled composition. With one unit, raising followed by 'lfd.scale = "sample"' returns the sample unchanged.
Zero catch-at-age entries are set to 'sqrt(.Machine$double.eps)' to avoid 0/0 in [lfd.sim()]; a gear with no catch at all in an area-year leaves a zero LFD.
Run 'mp()' with 'parallel = FALSE' until the common random numbers are stored as 'FLQuant's: 'mp()' subsets only 'FLQuant' deviances by iteration when it splits the run across workers.
A list with 'stk' (the observed stock, window 'y0:dy', with attributes '"lfd"' and '"catch_gear"': 'FLQuants' by gear holding the accumulated series 'y0:dy', by unit or, with 'lfd.raising = TRUE', pooled over units), 'idx' (empty 'FLIndices'), and the updated 'observations' and 'tracking'. The attributes are how the samples reach the 'est' module (e.g. 'flicc.sa()'), because 'mp()' passes only 'stk' and 'idx' to it.
[build_gear()], [sample_lfd_gears()], [lfd_obs_init()], [catch_n_gear()], [lfd.sim()], [lfd.sim.season()], [rUnif_lfd()], 'mse::sampling.oem()'
## Not run: lfd.devs <- rUnif_lfd(om_gears, years = 2010:2034, nsim = 20, seed = 456) init <- lfd_obs_init(stock(om), om_gears, years = 2010:2034, hist_years = 2010:2024, u_lfd = lfd.devs) oem <- FLoem( method = sampling.lfd.oem, observations = list(stk = stock(om), lfd = init$lfd, catch_gear = init$catch_gear), deviances = list(stk = stk.devs, lfd = lfd.devs, catch_gear = cg.devs), args = list(om_gears = om_gears) ) run <- mp(om, oem = oem, ctrl = ctrl, parallel = FALSE, args = list(iy = 2024, fy = 2034, y0 = 2010, it = 20)) ## monthly fishery sampling kept by month for a seasonal assessment: ## build the gear with n_seasons = 12 and use season = TRUE in both ## lfd_obs_init() and the FLoem args ## two areas (units): gear sets by area, independent CRN streams by area, ## LFDs raised to catch by area and pooled for the assessment oem2 <- FLoem( method = sampling.lfd.oem, observations = list(stk = stock(om2), lfd = init2$lfd, catch_gear = init2$catch_gear), deviances = list(stk = stk.devs2, lfd = list(North = rUnif_lfd(gears_N, 2010:2034, 20, 1), South = rUnif_lfd(gears_S, 2010:2034, 20, 2)), catch_gear = cg.devs2), args = list(om_gears = list(North = gears_N, South = gears_S), lfd.raising = TRUE) ) ## End(Not run)## Not run: lfd.devs <- rUnif_lfd(om_gears, years = 2010:2034, nsim = 20, seed = 456) init <- lfd_obs_init(stock(om), om_gears, years = 2010:2034, hist_years = 2010:2024, u_lfd = lfd.devs) oem <- FLoem( method = sampling.lfd.oem, observations = list(stk = stock(om), lfd = init$lfd, catch_gear = init$catch_gear), deviances = list(stk = stk.devs, lfd = lfd.devs, catch_gear = cg.devs), args = list(om_gears = om_gears) ) run <- mp(om, oem = oem, ctrl = ctrl, parallel = FALSE, args = list(iy = 2024, fy = 2034, y0 = 2010, it = 20)) ## monthly fishery sampling kept by month for a seasonal assessment: ## build the gear with n_seasons = 12 and use season = TRUE in both ## lfd_obs_init() and the FLoem args ## two areas (units): gear sets by area, independent CRN streams by area, ## LFDs raised to catch by area and pooled for the assessment oem2 <- FLoem( method = sampling.lfd.oem, observations = list(stk = stock(om2), lfd = init2$lfd, catch_gear = init2$catch_gear), deviances = list(stk = stk.devs2, lfd = list(North = rUnif_lfd(gears_N, 2010:2034, 20, 1), South = rUnif_lfd(gears_S, 2010:2034, 20, 2)), catch_gear = cg.devs2), args = list(om_gears = list(North = gears_N, South = gears_S), lfd.raising = TRUE) ) ## End(Not run)
generates a Schafer surplus production model with process and observation error
schaefer.sim( k = 10000, r = 0.3, q = 0.5, pe = 0.1, oe = 0.2, bk = 0.9, years = 1980:2022, f0 = 0.2, fhi = 2.2, flo = 0.8, sigmaF = 0.15, iters = 1, blim = 0.3, bthr = 0.5, rel = FALSE )schaefer.sim( k = 10000, r = 0.3, q = 0.5, pe = 0.1, oe = 0.2, bk = 0.9, years = 1980:2022, f0 = 0.2, fhi = 2.2, flo = 0.8, sigmaF = 0.15, iters = 1, blim = 0.3, bthr = 0.5, rel = FALSE )
k |
carrying capacity |
r |
intrinsic rate of population increase |
q |
catchability coefficient |
pe |
process error |
oe |
process error |
bk |
initial fraction of b/k |
years |
time horizon |
f0 |
factor for initial year as f0 = f/fmsy |
fhi |
factor for high F as fhi = f/fmsy |
flo |
factor for low F as flo = fbar/fmsy |
sigmaF |
variation on f trajectory |
iters |
number of iterations |
rel |
if TRUE metrics B/Bmsy and F/Fmsy are produced |
FLQuants
stk = schaefer.sim(iters=100,q=0.5) plotAdvice(stk) plot(FLIndex(index=iter(stk@stock,1))) # indexstk = schaefer.sim(iters=100,q=0.5) plotAdvice(stk) plot(FLIndex(index=iter(stk@stock,1))) # index
Under constant instantaneous F and M within the year, the fraction of the
annual catch-at-age taken in season of equal seasons is
( where ). Multiplying annual gear catch-at-age (from
[catch_n_gear()]) by gives seasonal catch-at-age that sums
exactly to the annual catch, with older and heavily fished ages
concentrated early in the year. This is the observation-side analogue of
[seasonalize_catch_n_gear()] and needs no seasonal operating model.
season_fraction(stock, n_seasons)season_fraction(stock, n_seasons)
stock |
'FLStock' with annual 'harvest' and 'm' (one season). |
n_seasons |
Integer number of equal seasons (e.g. 4 or 12). |
'FLQuant' age x year x unit x season x area x iter of fractions.
## Not run: data(ple4) fr <- season_fraction(ple4[, ac(2015:2017)], 12) range(seasonSums(fr)) # 1 ## End(Not run)## Not run: data(ple4) fr <- season_fraction(ple4[, ac(2015:2017)], 12) range(seasonSums(fr)) # 1 ## End(Not run)
Disaggregates annual gear-specific catch-at-age into equal within-year seasons under constant instantaneous fishing and natural mortality.
seasonalize_catch_n_gear(stock, f_age_gear, n_seasons)seasonalize_catch_n_gear(stock, f_age_gear, n_seasons)
stock |
An 'FLStock' or 'FLStockR' containing annual stock numbers, fishing mortality, and natural mortality. |
f_age_gear |
Named list of gear-specific fishing-mortality-at-age 'FLQuant' objects. |
n_seasons |
Integer number of equal within-year seasons. |
Population numbers at the start of season 's' are
, where 'S' is 'n_seasons'. Gear catch in
that season is calculated with the corresponding partial fishing mortality.
A named list of gear-specific 'FLQuant' objects with a populated season dimension.
## Not run: seasonal_catch <- seasonalize_catch_n_gear(om_hist, f_age_gear, n_seasons = 4) ## End(Not run)## Not run: seasonal_catch <- seasonalize_catch_n_gear(om_hist, f_age_gear, n_seasons = 4) ## End(Not run)
Integrates selectivity-at-length over the length-at-age distribution at seasonal midpoint timings and averages the resulting selectivity-at-age curves across seasons.
sel_a_seasonal_avg( lhpar, sel_len, age, n_seasons, model = vonbert, reflen = NULL, cv = 0.1, lmin = 5, lmax_mult = 1.2, bin = 1, scale = TRUE )sel_a_seasonal_avg( lhpar, sel_len, age, n_seasons, model = vonbert, reflen = NULL, cv = 0.1, lmin = 5, lmax_mult = 1.2, bin = 1, scale = TRUE )
lhpar |
Life-history parameters containing 'linf', 'k', and 't0'. |
sel_len |
Selectivity-at-length as an 'FLQuant' or named numeric vector. |
age |
Numeric vector of ages. |
n_seasons |
Integer number of equal within-year seasons. |
model |
Growth function or model object. Defaults to 'vonbert'. |
reflen |
Optional reference length passed to [iALK()]. |
cv |
Numeric coefficient of variation in length-at-age. |
lmin, lmax_mult
|
Unused; the length grid is taken from the names of 'sel_len' (e.g. 'gear$sel_len'), so it always matches the gear. |
bin |
Numeric length-bin width. |
scale |
Logical; if 'TRUE', scale the averaged curve to a maximum of one. |
Seasonal midpoint 's' is evaluated at 't = (s - 0.5) / n_seasons'. Within-year growth is represented by replacing 't0' with 't0 - t' in the growth parameters.
A named numeric vector of seasonally averaged selectivity-at-age.
## Not run: sel_a <- sel_a_seasonal_avg( lhpars, om_gears$Trawl$sel_len, age = 0:5, n_seasons = 4 ) ## End(Not run)## Not run: sel_a <- sel_a_seasonal_avg( lhpars, om_gears$Trawl$sel_len, age = 0:5, n_seasons = 4 ) ## End(Not run)
Computes asymmetric dome-shaped selectivity as a function of length. The curve peaks at 'Lpeak', with separate standard deviations for the ascending and descending limbs.
sel_dnormal_len(L, Lpeak, sd_left, sd_right)sel_dnormal_len(L, Lpeak, sd_left, sd_right)
L |
Numeric vector of lengths. |
Lpeak |
Length at maximum selectivity. |
sd_left |
Standard deviation for lengths below or equal to 'Lpeak'. |
sd_right |
Standard deviation for lengths above 'Lpeak'. |
Numeric vector of selectivity values scaled to a maximum of 1.
Evaluates a logistic, normal, or double-normal selectivity curve on a length grid and maps the same curve to predicted length-at-age.
sel_la( lhpar, amin = 0, amax = 20, type = c("logistic", "normal", "dnormal"), lmin = 3, lmax = NULL, binwidth = 1, lmax_mult = 1.1, L50 = NULL, L95 = NULL, Lpeak = NULL, sd = NULL, sd_left = 0.3, sd_right = 0.6, scale = TRUE )sel_la( lhpar, amin = 0, amax = 20, type = c("logistic", "normal", "dnormal"), lmin = 3, lmax = NULL, binwidth = 1, lmax_mult = 1.1, L50 = NULL, L95 = NULL, Lpeak = NULL, sd = NULL, sd_left = 0.3, sd_right = 0.6, scale = TRUE )
lhpar |
Life-history parameters containing 'linf', 'k', and 't0'. |
amin, amax
|
Integer minimum and maximum ages. Defaults to '0' and '20'. |
type |
Selectivity curve: '"logistic"', '"normal"', or '"dnormal"'. |
lmin |
Numeric lower limit of the length grid. Defaults to '3'. |
lmax |
Optional numeric upper limit of the length grid. When 'NULL', it is calculated from 'linf * lmax_mult'. |
binwidth |
Numeric length-bin width. Defaults to '1'. |
lmax_mult |
Numeric multiplier applied to 'linf' when 'lmax' is 'NULL'. Defaults to '1.1'. |
L50, L95
|
Lengths at 50 and 95 percent selectivity for a logistic curve. |
Lpeak |
Length at maximum selectivity for normal and double-normal curves. |
sd |
Standard deviation of a normal curve. |
sd_left, sd_right
|
Standard deviations of the ascending and descending limbs of a double-normal curve. |
scale |
Logical; if 'TRUE', scale the length and age curves separately to a maximum of one. |
Length-dimension labels contain lower bin limits, while selectivity is evaluated at bin midpoints. The returned age curve is a point evaluation at predicted length-at-age. Use [build_gear()] when selectivity-at-age must be integrated over a length-at-age distribution.
A list with components 'sel_len', an 'FLQuant' of selectivity-at-length; 'sel_a', an 'FLQuant' of selectivity-at-age; and 'len_bins', a data frame of lower, upper, and midpoint lengths.
## Not run: linefish <- sel_la( lhpar = lhpar, amin = 0, amax = 20, type = "logistic", L50 = 35, L95 = 50 ) gillnet <- sel_la( lhpar = lhpar, type = "normal", Lpeak = 35, sd = 10 ) traps <- sel_la( lhpar = lhpar, type = "dnormal", Lpeak = 30, sd_left = 8, sd_right = 25 ) plot_sel_la(traps) ## End(Not run)## Not run: linefish <- sel_la( lhpar = lhpar, amin = 0, amax = 20, type = "logistic", L50 = 35, L95 = 50 ) gillnet <- sel_la( lhpar = lhpar, type = "normal", Lpeak = 35, sd = 10 ) traps <- sel_la( lhpar = lhpar, type = "dnormal", Lpeak = 30, sd_left = 8, sd_right = 25 ) plot_sel_la(traps) ## End(Not run)
Computes asymptotic logistic selectivity as a function of length. The curve is parameterised by the length at 50 and the length at 95
sel_logistic_len(L, L50, L95)sel_logistic_len(L, L50, L95)
L |
Numeric vector of lengths. |
L50 |
Length at 50% selectivity. |
L95 |
Length at 95% selectivity. |
Numeric vector of selectivity values between 0 and 1.
Computes symmetric dome-shaped selectivity as a function of length. The curve peaks at 'Lpeak' and declines symmetrically around the peak.
sel_normal_len(L, Lpeak, sd)sel_normal_len(L, Lpeak, sd)
L |
Numeric vector of lengths. |
Lpeak |
Length at maximum selectivity. |
sd |
Standard deviation controlling the width of the dome. |
Numeric vector of selectivity values scaled to a maximum of 1.
scales catch-at-age to total catch with error (optional)
sops(object, stock, sigma = 0.1, what = c("catch", "landings", "discards")[1])sops(object, stock, sigma = 0.1, what = c("catch", "landings", "discards")[1])
object |
FLQuant catch.n, discard.n, landings.n |
stock |
FLStock |
sigma |
observation error |
what |
type c("catch", "landings", "discards") |
FLQuant
spict2FLQuant()
spict2FLQuant( x, metric = c("ssb", "fbar", "catch", "stock", "harvest")[1], osa = FALSE, forecast = F, what = c("mle") )spict2FLQuant( x, metric = c("ssb", "fbar", "catch", "stock", "harvest")[1], osa = FALSE, forecast = F, what = c("mle") )
x |
fit from SPICT |
osa |
add one-step-ahead forecast |
forecast |
TRUE/FALSE |
what |
mle or log.sd |
FLQuant
adopted from Laurie Kell (biodyn)
spict2FLStockR()
spict2FLStockR( res, blim = 0.3, bthr = 0.5, rel = FALSE, osa = FALSE, forecast = NULL, itsCI = 1, seed = 123 )spict2FLStockR( res, blim = 0.3, bthr = 0.5, rel = FALSE, osa = FALSE, forecast = NULL, itsCI = 1, seed = 123 )
res |
fit from SPICT |
blim |
biomass limit reference point as fraction of Bmsy |
bthr |
biomass precautionary reference point as fraction of Bmsy |
rel |
if TRUE ratios BBmsy and FFmsy are stored |
osa |
add one-step-ahead forecast |
forecast |
extract forecast TRUE/FALSE |
itsCI |
number of iterations to depict uncertainty in plots |
seed |
random seed for consistent sampling across scenarios |
FLStockR with refpts
spict2stars()
spict2stars(spict, blim = 0.3, bthr = 0.5, quantiles = c(0.05, 0.95))spict2stars(spict, blim = 0.3, bthr = 0.5, quantiles = c(0.05, 0.95))
spict |
fit from fit.spict() |
blim |
biomass limit point as fraction of Bmsy, default 0.3Bmsy (ICES) |
bthr |
biomass precautionary point as fraction of Bmsy, default 0.5Bmsy (ICES) |
STARS list with $timeseris and $refpts
Largest-remainder split: the seasonal values differ by at most one and sum exactly to 'n' (unlike 'rep(round(n / S), S)', which gives 48 for 50 / 12).
split_ess(n, S)split_ess(n, S)
n |
Integer total sample size. |
S |
Integer number of seasons. |
Integer vector of length 'S' summing to 'n'.
split_ess(50, 12) sum(split_ess(50, 12))split_ess(50, 12) sum(split_ess(50, 12))
Maps a spawning potential ratio (SPR, spawning biomass per recruit
relative to unfished) to equilibrium spawning biomass relative to
unfished, , for a Beverton-Holt stock-recruit relationship with
steepness :
truncated at zero below . The mapping
is the identity at (constant recruitment).
spr2depletion(spr, s)spr2depletion(spr, s)
spr |
Numeric vector or |
s |
Beverton-Holt steepness, |
With and the equilibrium
condition , solving for and dividing by
gives the equation above. Use it to express
per-recruit status estimates (e.g. from length-based SPR methods) on the
biomass scale when recruitment depends on stock size. Relative to an SPR
target, spr2depletion(spr, s) / spr2depletion(spr_tgt, s) gives
.
Object of the same class as spr.
spr2depletion(c(0.2, 0.4, 0.6, 1), s = 0.75) ## status relative to an SPR40 target on the biomass scale spr2depletion(0.3, 0.75) / spr2depletion(0.4, 0.75)spr2depletion(c(0.2, 0.4, 0.6, 1), s = 0.75) ## status relative to an SPR40 target on the biomass scale spr2depletion(0.3, 0.75) / spr2depletion(0.4, 0.75)
ss2FLStockR()
ss2FLStockR(mvln, thin = 1, output = NULL, rel = FALSE)ss2FLStockR(mvln, thin = 1, output = NULL, rel = FALSE)
mvln |
output from ssmvln() |
thin |
thinnig rate of retained iters |
output |
expected outputs presented as "mle" or median of "iters" |
rel |
if TRUE ratios B/Btgt and F/Ftgt are shown |
FLStockR with refpts
ss2ices()
ss2ices(mvln, quantiles = c(0.05, 0.95))ss2ices(mvln, quantiles = c(0.05, 0.95))
mvln |
output of ssmvln() |
quantiles |
default is 95CIs as c(0.025,0.975) |
output |
choice c("iters","mle")[1] |
Fmsy |
if specified the ratio F/Fmsy is calculated (required for ensembles) |
Btrigger |
if specified the ratio SSB/Btrigger is calculated (required for ensembles) |
ICES list with $timeseris and $refpts
ss2stars()
ss2stars(mvln, output = c("iters", "mle")[2], quantiles = c(0.05, 0.95))ss2stars(mvln, output = c("iters", "mle")[2], quantiles = c(0.05, 0.95))
mvln |
output of ssmvln() |
output |
choice c("iters","mle")[1] |
quantiles |
default is 95CIs as c(0.025,0.975) |
STARS list with $timeseris and $refpts
ss3col
ss3col(n, alpha = 1)ss3col(n, alpha = 1)
n |
number of colors |
alpha |
transluscency |
vector of color codes
function to generate MVN assessment error deviations of F and SSB
ss3devs(om, vcv, Fphi = 0.423, bias.correct = TRUE, ...)ss3devs(om, vcv, Fphi = 0.423, bias.correct = TRUE, ...)
om |
*FLom* or *FLStock* object |
vcv |
covariance matrix from ss3vcv() |
Fphi |
autocorrelation of F error |
bias.correct |
lognormal bias correction if TRUE |
FLQuants with devs of F and SSB
Henning Winker (GFCM)
function to generate to extract variance-covariance matrix for F and SSB
ss3vcv(ss3rep)ss3vcv(ss3rep)
ss3rep |
from r4ss::SS_output |
covariance matrix for F and SSB end year
Henning Winker (GFCM)
function to generate uncertainty for Stock Synthesis
ssmvln( ss3rep, Fref = NULL, years = NULL, virgin = FALSE, mc = 1000, weight = 1, run = "MVLN", addprj = FALSE, ymax = NULL, xmax = NULL, legendcex = 1, verbose = TRUE, seed = 123, observed.catch = FALSE )ssmvln( ss3rep, Fref = NULL, years = NULL, virgin = FALSE, mc = 1000, weight = 1, run = "MVLN", addprj = FALSE, ymax = NULL, xmax = NULL, legendcex = 1, verbose = TRUE, seed = 123, observed.catch = FALSE )
ss3rep |
from r4ss::SS_output |
Fref |
Choice of Fratio c("MSY","Btgt","SPR","F01"), correponding to F_MSY and F_Btgt |
years |
single year or vector of years for mvln |
virgin |
if FALSE (default) the B0 base for Bratio is SSB_unfished |
mc |
number of monte-carlo simulations |
weight |
weighting option for model ensembles weight*mc |
run |
qualifier for model run |
addprj |
include forecast years |
ymax |
ylim maximum |
xmax |
xlim maximum |
verbose |
Report progress to R GUI? |
seed |
retains interannual correlation structure like MCMC |
observed.catch |
if FALSE expected catch is used |
out |
choice c("iters","mle") |
plot |
option to show plot |
legendcex=1 |
Allows to adjust legend cex |
output list of quant posteriors and mle's
Henning Winker (GFCM)
stock2ratios()
stock2ratios(object)stock2ratios(object)
object |
of class *FLStockR* |
FLStockR with ratios F/Ftgt and B/Btgt
stock2spm()
stock2spm(object, brps, bthr = 0.5, blim = 0.3, rel = T, relC = FALSE)stock2spm(object, brps, bthr = 0.5, blim = 0.3, rel = T, relC = FALSE)
object |
of class *FLStockR* |
FLStockR with ratios F/Ftgt and B/Btgt
stockMedians() Converts FLStock into simplified FLStock with Median FLQuants
stockMedians(object, FUN = iterMedians, ssbQ = 1, recQ = 1)stockMedians(object, FUN = iterMedians, ssbQ = 1, recQ = 1)
object |
of class *FLStock* or *FLStockR* or *FLStocks* |
FUN |
computes iterMedians, iterMeans |
ssbQ |
SSB quarter seasonal models |
recQ |
recruitment quarter seasonal models |
FLStockR with *FLQuants*
the at-age composition a survey gear samples at its 'timing' .
Passed to [lfd.sim()] with the same gear, whose conditional ALK
is built at the same timing.
survey_n_gear( stock, gear, years = dimnames(stock)$year, timing = gear$grid$timing %||% 0 )survey_n_gear( stock, gear, years = dimnames(stock)$year, timing = gear$grid$timing %||% 0 )
stock |
'FLStock'. |
gear |
Gear object from [build_gear()] (uses 'sel_a', 'grid$timing'). |
years |
Years. Default all years of 'stock'. |
timing |
Within-year timing. Default 'gear$grid$timing'. |
'FLQuant' of selected numbers-at-age.
computes catch.n for a given harvest
updCatch.n(stk)updCatch.n(stk)
object |
An *FLStock* |
FLQuant
updates sr in brp after changing biology
updsr(object, s = 0.7, v = NULL)updsr(object, s = 0.7, v = NULL)
object |
An *FLBRP* |
s |
assumed steepness s |
v |
input option new SB0 |
FLBRP
data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = FLBRP(ple4,sr) s = sr@SV[[1]] params(brp) # change m(brp) = Mlorenzen(stock.wt(brp),Mref=0.15) brpupd =updsr(brp,s) params(brp)data(ple4) sr <- srrTMB(as.FLSR(ple4,model=bevholtSV),spr0=mean(spr0y(ple4))) brp = FLBRP(ple4,sr) s = sr@SV[[1]] params(brp) # change m(brp) = Mlorenzen(stock.wt(brp),Mref=0.15) brpupd =updsr(brp,s) params(brp)
updstars()
updstars(star, newrefpts)updstars(star, newrefpts)
star |
output of star list with new refpoints |
newrefpts |
FLPar manually adjusted reference points |
STARS list with $timeseris and $refpts
Calculates vulnerable biomass as the stock numbers-at-age multiplied by stock weight-at-age and total selectivity. Total selectivity is defined as the sum of landings and discards selectivity, scaled to a maximum of one.
vbbrp(x)vbbrp(x)
x |
An object with |
Vulnerable biomass is calculated as:
where is total selectivity-at-age, calculated as
landings.sel(x) + discards.sel(x) and normalised to a maximum of one.
This helper is useful when deriving an SPM-equivalent biomass quantity based on vulnerable biomass rather than spawning biomass or total biomass.
An FLQuant containing vulnerable biomass by year and
iteration. Units are copied from stock(x).
## Not run: vb <- vbbrp(brp) plot(vb) ## End(Not run)## Not run: vb <- vbbrp(brp) plot(vb) ## End(Not run)
Calculates weight-at-age at seasonal midpoint timings and averages across seasons using seasonal numbers-at-age as weights.
wt_a_seasonal( n_season, params, gear = NULL, n_seasons, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )wt_a_seasonal( n_season, params, gear = NULL, n_seasons, model = vonbert, reflen = NULL, cv = gear$grid$cv %||% 0.1, lmin = gear$grid$lmin %||% 5, lmax_mult = gear$grid$lmax_mult %||% 1.2, bin = gear$grid$bin %||% 1 )
n_season |
An 'FLQuant' containing seasonal population or catch numbers-at-age. |
params |
Life-history parameters containing 'linf', 'k', 't0', 'a', and 'b'. |
gear |
Optional gear object returned by [build_gear()]. If supplied, the age-length key is conditioned on the gear's selectivity-at-length. |
n_seasons |
Integer number of equal within-year seasons. |
model |
Growth function or model object. Defaults to 'vonbert'. |
reflen |
Optional reference length passed to [iALK()]. |
cv, lmin, lmax_mult, bin
|
Length-at-age CV and length grid; default to 'gear$grid' when 'gear' is supplied, so the key matches the gear. |
When 'gear' is supplied, seasonal catch numbers weight a capture-conditioned age-length key. When 'gear = NULL', the biological key is weighted by seasonal population numbers.
An 'FLQuant' containing seasonally weighted weight-at-age by year and iteration.
## Not run: catch_wt <- wt_a_seasonal( seasonal_catch$Trawl, lhpars, gear = om_gears$Trawl, n_seasons = 4 ) ## End(Not run)## Not run: catch_wt <- wt_a_seasonal( seasonal_catch$Trawl, lhpars, gear = om_gears$Trawl, n_seasons = 4 ) ## End(Not run)