Title: | Management Strategy Evaluation Toolkit |
---|---|
Description: | Development, simulation testing, and implementation of management procedures for fisheries (see Carruthers & Hordyk (2018) <doi:10.1111/2041-210X.13081>). |
Authors: | Adrian Hordyk [aut, cre], Quang Huynh [aut], Tom Carruthers [aut], Chris Grandin [ctb] (iSCAM functions) |
Maintainer: | Adrian Hordyk <[email protected]> |
License: | GPL-3 |
Version: | 3.7.3 |
Built: | 2024-11-23 16:55:45 UTC |
Source: | CRAN |
Example objects of class Stock
Albacore Blue_shark Bluefin_tuna Bluefin_tuna_WAtl Butterfish Herring Mackerel Porgy Rockfish Snapper Sole Toothfish
Albacore Blue_shark Bluefin_tuna Bluefin_tuna_WAtl Butterfish Herring Mackerel Porgy Rockfish Snapper Sole Toothfish
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
An object of class Stock
of length 1.
avail("Stock")
avail("Stock")
Example objects of class MOM
Albacore_TwoFleet
Albacore_TwoFleet
An object of class MOM
of length 1.
avail("MOM")
avail("MOM")
Apply multi Management Procedures (class MMP) to a hierarchical list of Data class objects
applyMMP( DataList, MP = NA, reps = 1, nsims = NA, silent = FALSE, parallel = snowfall::sfIsRunning() )
applyMMP( DataList, MP = NA, reps = 1, nsims = NA, silent = FALSE, parallel = snowfall::sfIsRunning() )
DataList |
A hierarchical list of Data objects (Fleets nested in Stocks) |
MP |
Name of the MMP to run |
reps |
Number of samples |
nsims |
Optional. Number of simulations. |
silent |
Logical. Should messages be suppressed? |
parallel |
Logical. Whether to run MPs in parallel |
A hierarchical list of management recommendations (object class Rec), Fleets nested in Stocks
Apply Management Procedures to an object of class Data
applyMP( Data, MPs = NA, reps = 100, nsims = NA, silent = FALSE, parallel = snowfall::sfIsRunning() )
applyMP( Data, MPs = NA, reps = 100, nsims = NA, silent = FALSE, parallel = snowfall::sfIsRunning() )
Data |
An object of class Data |
MPs |
Name(s) of the MPs to run |
reps |
Number of samples |
nsims |
Optional. Number of simulations. |
silent |
Logical. Should messages be suppressed? |
parallel |
Logical. Whether to run MPs in parallel. Can be a vector of length(MPs) |
A list with the first element a list of management recommendations, and the second the updated Data object
Reads a fitted ASAP model and uses the MLE estimates with identical reconstruction among simulations. Future recruitment is
sampled from a lognormal distribution with autocorrelation. ASAP2Data
imports a Data object.
ASAP2OM( asap, nsim = 48, proyears = 50, mcmc = FALSE, Name = "ASAP Model", Source = "No source provided", nyr_par_mu = 3, Author = "No author provided", report = FALSE, silent = FALSE ) ASAP2Data(asap, Name = "ASAP assessment")
ASAP2OM( asap, nsim = 48, proyears = 50, mcmc = FALSE, Name = "ASAP Model", Source = "No source provided", nyr_par_mu = 3, Author = "No author provided", report = FALSE, silent = FALSE ) ASAP2Data(asap, Name = "ASAP assessment")
asap |
A list returned by ASAP, e.g., |
nsim |
The number of simulations in the operating model |
proyears |
The number of MSE projection years |
mcmc |
Logical, whether to use mcmc samples. Currently unsupported. |
Name |
The name of the operating model |
Source |
Reference to assessment documentation e.g. a url |
nyr_par_mu |
integer, the number of recent years to estimate vulnerability over for future projections |
Author |
Who did the assessment |
report |
Logical, should a comparison of biomass reconstruction be produced? |
silent |
Logical, should progress reporting be printed to the console? |
Length at age is not used in ASAP so arbitrary placeholder values are used for length-based parameters. Update these parameters to model length in the operating model.
An operating model OM class.
Q. Huynh
A function that develops a multiple fleet operating model (MOM) and either models a unisex or 2-sex stock from arrays of abundance, fishing mortality, and biological parameters. The user still needs to parameterize most of the observation and implementation portions of the operating model.
Assess2MOM( Name = "MOM created by Assess2MOM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, fecaa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... )
Assess2MOM( Name = "MOM created by Assess2MOM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, fecaa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... )
Name |
Character string. The name of the multi-OM. |
proyears |
Positive integer. The number of projection years for MSE. |
interval |
Positive integer. The interval at which management procedures will update the management advice in multiMSE, e.g., 1 = annual updates. |
CurrentYr |
Positive integer. The current year (e.g., final year of fitting to data) |
h |
The steepness of the stock-recruitment curve. Either a single numeric or a length nsim vector. |
Obs |
Either a single observation model to be used for all sexes and populations (class Obs), or a list where
|
Imp |
Either a single implementation model to be used for all sexes and populations (class Imp), or a list where
|
naa |
Numbers-at-age by sex |
faa |
Fishing mortality rate-at-age by sex and fleet |
waa |
Weight-at-age |
Mataa |
Maturity (spawning fraction)-at-age |
Maa |
Natural mortality rate-at-age |
laa |
Length-at-age |
fecaa |
Fecundity at age |
nyr_par_mu |
Positive integer. The number of recent years that natural mortality, age vulnerability, weight, length and maturity parameters are averaged over for defining future projection conditions. |
LowerTri |
Integer. The number of recent years for which model estimates of recruitment are ignored (not reliably estimated by the assessment) |
recind |
Positive integer. The first age class that fish 'recruit to the fishery'. The default is 0 - ie the first position in the age dimension of naa is age zero |
plusgroup |
Logical. Does the assessment assume that the oldest age class is a plusgroup? |
altinit |
Integer. Various assumptions for how to set up the initial numbers. 0: standard, 1: no plus group, 2: temporary fix for MSEtool plus group initialization |
fixq1 |
Logical. Should q be fixed (ie assume the F-at-age array faa is accurate? |
report |
Logical, if TRUE, a diagnostic will be reported showing the matching of the OM reconstructed numbers at age vs the assessment. |
silent |
Whether to silence messages to the console. |
... |
Additional arguments (for all, either a numeric or a length nsim vector):
|
Use a seed for the random number generator to sample future recruitment.
An object of class MOM.
Q. Huynh
Assess2OM
is identical to VPA2OM
.A function that uses a set of bootstrap estimates of numbers-at-age, fishing mortality rate-at-age, M-at-age, weight-at-age, length-at-age and Maturity-at-age to define a fully described MSEtool operating model. The user still needs to parameterize most of the observation and implementation portions of the operating model.
Assess2OM( Name = "A fishery made by VPA2OM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... ) VPA2OM( Name = "A fishery made by VPA2OM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... )
Assess2OM( Name = "A fishery made by VPA2OM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... ) VPA2OM( Name = "A fishery made by VPA2OM", proyears = 50, interval = 2, CurrentYr = as.numeric(format(Sys.Date(), "%Y")), h = 0.999, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, naa, faa, waa, Mataa, Maa, laa, nyr_par_mu = 3, LowerTri = 1, recind = 0, plusgroup = TRUE, altinit = 0, fixq1 = TRUE, report = FALSE, silent = FALSE, ... )
Name |
Character string. The name of the operating model. |
proyears |
Positive integer. The number of projection years for MSE. |
interval |
Positive integer. The interval at which management procedures will update the management advice in runMSE, e.g., 1 = annual updates. |
CurrentYr |
Positive integer. The current year (final year of fitting to data) |
h |
The steepness of the stock-recruitment curve (greater than 0.2 and less than 1, assumed to be close to 1 to match VPA assumption). Either a single numeric or a length nsim vector. |
Obs |
The observation model (class Obs). This function only updates the catch and index observation error. |
Imp |
The implementation model (class Imp). This function does not update implementation parameters. |
naa |
Numeric array |
faa |
Numeric array |
waa |
Numeric array |
Mataa |
Numeric array |
Maa |
Numeric array |
laa |
Numeric array |
nyr_par_mu |
Positive integer. The number of recent years that natural mortality, age vulnerability, weight, length and maturity parameters are averaged over for defining future projection conditions. |
LowerTri |
Integer. The number of recent years for which model estimates of recruitment are ignored (not reliably estimated by the assessment) |
recind |
Positive integer. The first age class that fish 'recruit to the fishery'. The default is 0 - ie the first position in the age dimension of naa is age zero |
plusgroup |
Logical. Does the assessment assume that the oldest age class is a plusgroup? |
altinit |
Integer. Various assumptions for how to set up the initial numbers. 0: standard, 1: no plus group, 2: temporary fix for MSEtool plus group initialization |
fixq1 |
Logical. Should q be fixed (ie assume the F-at-age array faa is accurate? |
report |
Logical, if TRUE, a diagnostic will be reported showing the matching of the OM reconstructed numbers at age vs the assessment. |
silent |
Whether to silence messages to the console. |
... |
Additional arguments (for all, either a numeric or a length nsim vector):
|
Use a seed for the random number generator to sample future recruitment.
An object of class OM.
T. Carruthers
SS2OM iSCAM2OM WHAM2OM ASAP2OM
Example objects of class Data
Atlantic_mackerel China_rockfish Cobia Example_datafile Gulf_blue_tilefish ourReefFish Red_snapper Simulation_1
Atlantic_mackerel China_rockfish Cobia Example_datafile Gulf_blue_tilefish ourReefFish Red_snapper Simulation_1
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
An object of class Data
of length 1.
avail("Data")
avail("Data")
Generic class finder
avail(classy, package = NULL, msg = TRUE)
avail(classy, package = NULL, msg = TRUE)
classy |
A class of object (character string, e.g. 'Fleet') |
package |
Optional. Names(s) of the package to search for object of class |
msg |
Print messages? |
Finds objects of the specified class in the global environment or the openMSE packages.
T. Carruthers
avail("OM", msg=FALSE) Stocks <- avail("Stock") Fleets <- avail("Fleet") MPs <- avail("MP")
avail("OM", msg=FALSE) Stocks <- avail("Stock") Fleets <- avail("Fleet") MPs <- avail("MP")
A function that generates an operating model from the MCMC samples of an Awatea model. Code optimized for the BC Pacific ocean perch assessment (Haigh et al. 2018).
Awatea2OM( AwateaDir, nsim = 48, proyears = 50, Name = "OM made by Awatea2OM", Source = "No source provided", Author = "No author provided", verbose = TRUE )
Awatea2OM( AwateaDir, nsim = 48, proyears = 50, Name = "OM made by Awatea2OM", Source = "No source provided", Author = "No author provided", verbose = TRUE )
AwateaDir |
A folder with Awatea files |
nsim |
The number of simulations |
proyears |
The number of projection years for the MSE |
Name |
The name of the operating model |
Source |
Reference to assessment documentation e.g. a url |
Author |
Who did the assessment |
verbose |
Return detailed messages? |
This function averages biological parameters across sex and then sends arrays to VPA2OM, assumes unfished status (B/B0 = 1) in the first year, and assumes a single fishing fleet.
Q. Huynh and T. Carruthers
Haigh, R., et al. 2018. Stock assessment for Pacific Ocean Perch (Sebastes alutus) in Queen Charlotte Sound, British Columbia in 2017. Canadian Science Advisory Secretariat (CSAS) Research Document 2018/038. 232 pp. https://www.dfo-mpo.gc.ca/csas-sccs/Publications/ResDocs-DocRech/2018/2018_038-eng.html
Import a multi-stock, multi-fleet OM from a BAM object
BAM2MOM( rdat, nsim = 48, proyears = 50, interval = 1, stock_name = NULL, fleet_name = NULL, LowerTri = 0, report = FALSE, ... ) BAM2OM(rdat, nsim = 48, proyears = 50, interval = 2, report = FALSE, ...)
BAM2MOM( rdat, nsim = 48, proyears = 50, interval = 1, stock_name = NULL, fleet_name = NULL, LowerTri = 0, report = FALSE, ... ) BAM2OM(rdat, nsim = 48, proyears = 50, interval = 2, report = FALSE, ...)
rdat |
A list object from the |
nsim |
the number of simulations |
proyears |
the number of projection years |
interval |
the management interval |
stock_name |
Name of the stock(s) |
fleet_name |
Name of the fleet(s) |
LowerTri |
Integer. The number of recent years for which model estimates of recruitment are ignored (not reliably estimated by the assessment) |
report |
Logical, if TRUE, a diagnostic will be reported showing the matching of the OM reconstructed numbers at age vs the assessment. |
... |
Additional arguments passed to |
An object of class MOM
BAM2OM()
: Create a single stock/fleet OM from a BAM object
Boxplot of TAC recommendations
## S3 method for class 'Data' boxplot(x, upq = 0.9, lwq = 0.1, ylim = NULL, outline = FALSE, col = NULL, ...)
## S3 method for class 'Data' boxplot(x, upq = 0.9, lwq = 0.1, ylim = NULL, outline = FALSE, col = NULL, ...)
x |
An object of class MSE |
upq |
Upper quantile of TACs for max ylim |
lwq |
Lower quantile of TACs for min ylim |
ylim |
Optional numeric vector of length 2 to specify limits of y-axis. |
outline |
Logical. Include outliers in plot? |
col |
Optional colours to pass to |
... |
Optional additional arguments passed to |
Returns a data frame containing the information shown in the plot
A. Hordyk
Calculate Reference Yield
calcRefYield(x, StockPars, FleetPars, pyears, Ncurr, nyears, proyears)
calcRefYield(x, StockPars, FleetPars, pyears, Ncurr, nyears, proyears)
x |
Integer, the simulation number |
StockPars |
List of Stock Parameters |
FleetPars |
List of Fleet Parameters |
pyears |
The number of years to project forward. Equal to 'nyears' for optimizing for q. |
Ncurr |
Array with current numbers-at-age (dim=c(nsim, maxage+1, nareas)) |
nyears |
Number of historical years |
proyears |
Number of projection years |
A. Hordyk
A function that condenses the number of catch-at-length bins in a data object
CALsimp(Data, nbins = 10, simno = 1)
CALsimp(Data, nbins = 10, simno = 1)
Data |
An object of class 'Data'. |
nbins |
Integer. The target number of catch at length bins |
simno |
Integer. An optional argument to specify the simulation number if writing simulated data |
T. Carruthers
Diagnostic tools that look up the slot requirements of each MP and compares to the data available in the Data object.
Can(Data, timelimit = 1, MPs = NA, dev = FALSE, silent = FALSE) Cant(Data, timelimit = 1, silent = FALSE) DLMdiag( Data, command = c("available", "not available", "needed"), reps = 5, timelimit = 1, funcs1 = NA, dev = FALSE, silent = FALSE ) Needed(Data, timelimit = 1, silent = FALSE)
Can(Data, timelimit = 1, MPs = NA, dev = FALSE, silent = FALSE) Cant(Data, timelimit = 1, silent = FALSE) DLMdiag( Data, command = c("available", "not available", "needed"), reps = 5, timelimit = 1, funcs1 = NA, dev = FALSE, silent = FALSE ) Needed(Data, timelimit = 1, silent = FALSE)
Data |
A data-limited methods data object (class Data) |
timelimit |
The maximum time (seconds) taken for an MP to undertake 5 reps (this filters out methods that are too slow) |
MPs |
Optional list of MP names |
dev |
Logical. Run in development mode? |
silent |
Logical Display messages? |
command |
What to calculate? Character. Options = c("available", "not available", "needed") |
reps |
The number of replicates for the MP |
funcs1 |
A character vector of the MP names (optional) |
Can()
: Identifies MPs that have the correct data, do not produce errors,
and run within the time limit.
Cant()
: Identifies MPs that don't have sufficient data, lead to errors, or don't run in
time along with a list of their data requirements.
DLMdiag()
: Internal function called by Can
and Cant
Needed()
: Identifies what data are needed to run
the MPs that are currently not able to run given a Data
object
CanMPs <- Can(MSEtool::Cobia) CantMPs <- Cant(MSEtool::Cobia) Needs <- Needed(MSEtool::Cobia)
CanMPs <- Can(MSEtool::Cobia) CantMPs <- Cant(MSEtool::Cobia) Needs <- Needed(MSEtool::Cobia)
Custom MPs cannot have the same names of MPs in MSEtool and related packages
CheckDuplicate(MPs)
CheckDuplicate(MPs)
MPs |
Character vector of MP names |
An error if duplicated MP names, otherwise nothing
Check that specified MPs are valid and will run on MSEtool::SimulatedData
CheckMPs(MPs = NA, silent = FALSE)
CheckMPs(MPs = NA, silent = FALSE)
MPs |
Character vector of MP names |
silent |
Logical. Report messages? |
MP names
Utility functions for MSE objects
checkMSE(MSEobj) addMPs(MSEobjs) joinMSE(MSEobjs = NULL) joinHist(Hist_List) updateMSE(MSEobj, save.name = NULL)
checkMSE(MSEobj) addMPs(MSEobjs) joinMSE(MSEobjs = NULL) joinHist(Hist_List) updateMSE(MSEobj, save.name = NULL)
MSEobj |
A |
MSEobjs |
A list of MSE objects |
Hist_List |
A list of objects of class |
save.name |
Character string. Optional file name to save the updated MSE object to disk. |
An object of class MSE
A new object of class Hist
checkMSE()
: Check that an MSE object includes all slots in the latest version of DLMtool
addMPs()
: Adds additional MPs to an MSE object by combining
multiple MSE objects that have identical historical OM values but different
MPs.
joinMSE()
: Joins two or more MSE objects together across simulations. MSE objects must have identical
number of historical years, and projection years.
joinHist()
: Join objects of class Hist
. Does not join slot OM
updateMSE()
: Updates an existing MSE object (class MSE) from a previous version of the
MSEtool to include slots new to the latest version. Also works with Stock,
Fleet, Obs, Imp, and Data objects. The new slots will be empty,
but avoids the 'slot doesn't exist' error that sometimes occurs.
Returns an object of class matching class(MSEobj)
A. Hordyk
Check OM object is complete
CheckOM(OM, msg = TRUE, stop_if_missing = TRUE)
CheckOM(OM, msg = TRUE, stop_if_missing = TRUE)
OM |
An object of class |
msg |
Logical. Display messages? |
stop_if_missing |
Logical. Stop with error is values are missing and there is no default? |
The OM object with default values (if needed)
testOM <- CheckOM(testOM)
testOM <- CheckOM(testOM)
Interactive plots to specify trends and variability in fishing effort, fleet selectivity, and natural mortality for the operating model.
ChooseEffort(Fleet, Years = NULL) ChooseM(OM, type = c("age", "length"), x = NULL, y = NULL) ChooseSelect(Fleet, Stock, FstYr = NULL, SelYears = NULL)
ChooseEffort(Fleet, Years = NULL) ChooseM(OM, type = c("age", "length"), x = NULL, y = NULL) ChooseSelect(Fleet, Stock, FstYr = NULL, SelYears = NULL)
Fleet |
A fleet object. |
Years |
An optional vector of years. Should be nyears long. |
OM |
An object of class 'OM' |
type |
A character string - is M to be mapped by 'age' or 'length'? |
x |
Optional vector for x-axis |
y |
Optional vector for y-axis |
Stock |
Optional Stock object. If provided, average length-at-maturity is included on plot for reference. |
FstYr |
Optional value for first historical year. If empty, user must specify the year in console. |
SelYears |
Optional vector of values for each year where selectivity pattern changed. If empty, user must specify the years in console (comma separated). |
ChooseEffort |
Interactive plot which allows users to specify the relative trajectory and variability in the historical fishing effort and populates Fleet object. |
ChooseM |
Interactive plot which allows users to specify M by age or size class |
ChooseSelect |
Input the first historical year, and all years where selectivity pattern changed (separated by comma). Interactive plot which allows users to specify a range for the length at 5\ selectivity at maximum length for each year. Produces a simple plot which shows the range in selectivity pattern for each break-point year. Selectivity-at-length is fixed in between break-point years. Note that this function replaces 'nyears' in the Fleet object with the value defined here (FstYr:current year). |
ChooseEffort
and ChooseSelect
return a Fleet object while
ChooseM
returns an OM object.
A. Hordyk
Create a blank MP recommendations object (class Rec) of the right dimensions
CombineMMP(temp, nareas)
CombineMMP(temp, nareas)
temp |
A list of nsim simulations. |
nareas |
The number of areas. |
T. Carruthers
Have I undertaken enough simulations (nsim)? Has my MSE converged on stable (reliable) performance metrics?
Converge( MSEobj, PMs = c("Yield", "P10", "AAVY"), maxMP = 15, thresh = 0.5, ref.it = 20, inc.leg = FALSE, all.its = FALSE, nrow = NULL, ncol = NULL, silent = FALSE )
Converge( MSEobj, PMs = c("Yield", "P10", "AAVY"), maxMP = 15, thresh = 0.5, ref.it = 20, inc.leg = FALSE, all.its = FALSE, nrow = NULL, ncol = NULL, silent = FALSE )
MSEobj |
An MSE object of class |
PMs |
A character vector of names of the PM methods or a list of the PM methods |
maxMP |
Maximum number of MPs to include in a single plot |
thresh |
The convergence threshold. Maximum root mean square deviation over the last |
ref.it |
The number of iterations to calculate the convergence statistics. For example, a value of 20 means convergence diagnostics are calculated over last 20 simulations |
inc.leg |
Logical. Should the legend be displayed? |
all.its |
Logical. Plot all iterations? Otherwise only (nsim-ref.it):nsim |
nrow |
Numeric. Optional. Number of rows |
ncol |
Numeric. Optional. Number of columns |
silent |
Hide the messages printed in console? |
Performance metrics are plotted against the number of simulations. Convergence diagnostics
are calculated over the last ref.it
(default = 20) iterations. The convergence diagnostics are:
Is the order of the MPs stable over the last ref.it
iterations?
Is the average difference in performance statistic over the last ref.it
iterations < thresh
?
By default three commonly used performance metrics are used:
Average Yield Relative to Reference Yield
Probability Spawning Biomass is above 0.1BMSY
Probability Average Annual Variability in Yield is < 20 per cent
Additional or alternative performance metrics objects can be supplied. Advanced users can develop their own performance metrics.
A table of convergence results for each MP
A. Hordyk
## Not run: MSE <- runMSE() Converge(MSE) ## End(Not run)
## Not run: MSE <- runMSE() Converge(MSE) ## End(Not run)
Current default thresholds for COSEWIC satisficing
Cos_thresh_tab(Ptab1)
Cos_thresh_tab(Ptab1)
Ptab1 |
A COSEWIC performance table made by COSEWIC_tab() |
T. Carruthers
OM@cpars
is formatted correctlyInternal function for checking that the OM@cpars
is formatted correctly
cparscheck(cpars)
cparscheck(cpars)
cpars |
a list of model parameters to be sampled (single parameters are
a vector |
either an error and the length of the first dimension of the various
cpars list items or passes and returns the number of simulations in cpars
T. Carruthers
Compare median biomass and yield in first year and last 5 years of projection
Cplot( MSEobj, MPs = NA, lastYrs = 5, point.size = 2, lab.size = 4, axis.title.size = 12, axis.text.size = 10, legend.title.size = 12 )
Cplot( MSEobj, MPs = NA, lastYrs = 5, point.size = 2, lab.size = 4, axis.title.size = 12, axis.text.size = 10, legend.title.size = 12 )
MSEobj |
An object of class MSE |
MPs |
Optional vector of MPs to plot |
lastYrs |
Numeric. Last number of years to summarize results. |
point.size |
Size of the points |
lab.size |
Size of labels |
axis.title.size |
Axis title size |
axis.text.size |
Axis text size |
legend.title.size |
Legend title size |
## Not run: MSE <- runMSE() Cplot(MSE) ## End(Not run)
## Not run: MSE <- runMSE() Cplot(MSE) ## End(Not run)
A function to read in Data object from an Excel spreadsheet with tabs named following specific convention.
Data_xl(fname, stkname, fpath = "", saveCSV = FALSE)
Data_xl(fname, stkname, fpath = "", saveCSV = FALSE)
fname |
Name of the Excel spreadsheet file. Must include file extension. |
stkname |
Name of the Stock. |
fpath |
Full file path, if file is not in current working directory |
saveCSV |
Do you also want to the Data parameters to a CSV file? |
The Excel spreadsheet must have tabs named with the following convention.
For example if stkname
is 'myFish', the Data parameters are in a tab
named 'myFishData'.
A object of class Data
A. Hordyk
## Not run: OM <- OM_xl(fname='OMTables.xlsx', stkname='myFish') ## End(Not run)
## Not run: OM <- OM_xl(fname='OMTables.xlsx', stkname='myFish') ## End(Not run)
'Data'
An object for storing fishery data for analysis
Name
The name of the Data object. Single value. Character string
Common_Name
Common name of the species. Character string
Species
Scientific name of the species. Genus and species name. Character string
Region
Name of the general geographic region of the fishery. Character string
LHYear
The last historical year of the simulation (before projection). Single value. Positive integer
MPrec
The previous recommendation of a management procedure. Vector of length nsim. Positive real numbers
Units
Units of the catch/absolute abundance estimates. Single value. Character string
MPeff
The current level of effort. Vector of length nsim. Positive real numbers
nareas
Number of fishing areas. Vector of length nsim. Non-negative integer
MaxAge
Maximum age. Vector nsim long. Positive integer
Mort
Natural mortality rate. Vector nsim long. Positive real numbers
CV_Mort
Coefficient of variation in natural mortality rate. Vector nsim long. Positive real numbers
vbLinf
Maximum length. Vector nsim long. Positive real numbers
CV_vbLinf
Coefficient of variation in maximum length. Vector nsim long. Positive real numbers
vbK
The von Bertalanffy growth coefficient K. Vector nsim long. Positive real numbers
CV_vbK
Coefficient of variation in the von Bertalanffy K parameter. Vector nsim long. Positive real numbers
vbt0
Theoretical age at length zero. Vector nsim long. Non-positive real numbers
CV_vbt0
Coefficient of variation in age at length zero. Vector nsim long. Positive real numbers
wla
Weight-Length parameter alpha. Vector nsim long. Positive real numbers
CV_wla
Coefficient of variation in weight-length parameter a. Vector nsim long. Positive real numbers
wlb
Weight-Length parameter beta. Vector nsim long. Positive real numbers
CV_wlb
Coefficient of variation in weight-length parameter b. Vector nsim long. Positive real numbers
steep
Steepness of stock-recruitment relationship. Vector nsim long. Value in the range of one-fifth to 1
CV_steep
Coefficient of variation in steepness. Vector nsim long. Positive real numbers
sigmaR
Recruitment variability. Vector nsim long. Positive real numbers
CV_sigmaR
Coefficient of variation in recruitment variability. Vector nsim long. Positive real numbers
L50
Length at 50 percent maturity. Vector nsim long. Positive real numbers
CV_L50
Coefficient of variation in length at 50 per cent maturity. Vector nsim long. Positive real numbers
L95
Length at 95 percent maturity. Vector nsim long. Positive real numbers
LenCV
Coefficient of variation of length-at-age (assumed constant for all age classes). Vector nsim long. Positive real numbers
LFC
Length at first capture. Vector nsim long. Positive real numbers
CV_LFC
Coefficient of variation in length at first capture. Vector nsim long. Positive real numbers
LFS
Shortest length at full selection. Vector nsim long. Positive real numbers
CV_LFS
Coefficient of variation in length at full selection. Vector nsim long. Positive real numbers
Vmaxlen
Vulnerability of individuals at asymptotic length. Vector nsim long. Real number between 0 and 1.
Year
Years that corresponding to catch and relative abundance data. Vector nyears long. Positive integer
Cat
Total annual catches. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_Cat
Coefficient of variation in annual catches. Matrix nsim rows and either 1 or nyear columns.
Positive real numbers. Note: built-in MPs use only the first value of CV_Cat
for all years.
Effort
Annual fishing effort. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_Effort
Coefficient of variation in annual effort. Matrix nsim rows and either 1 or nyear columns.
Positive real numbers. Note: built-in MPs use only the first value of CV_Effort
for all years.
Ind
Relative total abundance index. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_Ind
Coefficient of variation in the relative total abundance index. Matrix nsim rows and either 1 or nyear columns.
Positive real numbers. Note: built-in MPs use only the first value of CV_Ind
for all years
SpInd
Relative spawning abundance index. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_SpInd
Coefficient of variation in the relative spawning abundance index. Matrix nsim rows and either 1 or nyear columns. Positive real numbers.
VInd
Relative vulnerable abundance index. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_VInd
Coefficient of variation in the relative vulnerable abundance index. Matrix nsim rows and either 1 or nyear columns. Positive real numbers.
AddInd
Optional additional indices. Array of dimensions nsim
, n additional indices, and nyears
(length Year
).
CV_AddInd
Coefficient of variation for additional indices. Array of same dimensions as AddInd
AddIndV
Vulnerability-at-age schedules for the additional indices. Array with dimensions: nsim
, n additional indices, MaxAge+1
.
AddIunits
Units for the additional indices - biomass (1; default) or numbers (0). Numeric vector length n.ind.
AddIndType
Index calculated from total stock (1, default), spawning stock (2), or vulnerable stock (3). Numeric vector of length n.ind
Rec
Recent recruitment strength. Matrix of nsim rows and nyears columns. Non-negative real numbers
CV_Rec
Log-normal CV for recent recruitment strength. Matrix nsim rows and either 1 or nyear columns.
Positive real numbers. Note: built-in MPs use only the first value of CV_Rec
for all years.
ML
Mean length time series. Matrix of nsim rows and nyears columns. Non-negative real numbers
Lc
Modal length of catches. Matrix of nsim rows and nyears columns. Positive real numbers
Lbar
Mean length of catches over Lc. Matrix of nsim rows and nyears columns. Positive real numbers
Vuln_CAA
Optional vulnerability-at-age schedule for catch-at-age samples. Used to condition OM for closed-loop
simulation testing. Replaces the fleet selectivity schedule in the OM used to generate CAA samples. Matrix
with dimensions nsim
x MaxAge+1
.
CAA
Catch at Age data (numbers). Array of dimensions nsim x nyears x MaxAge+1. Non-negative integers
Vuln_CAL
Optional vulnerability-at-length schedule for catch-at-length samples. Used to condition OM for closed-loop
simulation testing. Replaces the fleet selectivity schedule in the OM used to generate CAL samples. Matrix
with dimensions nsim
x length(CAL_mids)
.
CAL_bins
The values delimiting the length bins for the catch-at-length data. Vector. Non-negative real numbers
CAL_mids
The values of the mid-points of the length bins. Optional, calculated from CAL_bins
if not entered. Vector. Non-negative real numbers.
CAL
Catch-at-length data. An array with dimensions nsim x nyears x length(CAL_mids). Non-negative integers. By default the CAL data will be the retained lengths (i.e, not including discards). If OM@control$CAL =="removals"
then the CAL data will include all removals (retained + discards).
Dep
Stock depletion SSB(current)/SSB(unfished). Vector nsim long. Fraction.
CV_Dep
Coefficient of variation in current stock depletion. Vector nsim long. Positive real numbers
Abun
An estimate of absolute current vulnerable abundance. Vector nsim long. Positive real numbers
CV_Abun
Coefficient of variation in estimate of absolute current stock size. Vector nsim long. Positive real numbers
SpAbun
An estimate of absolute current spawning stock abundance. Vector nsim long. Positive real numbers
CV_SpAbun
Coefficient of variation in estimate of absolute spawning current stock size. Vector nsim long. Positive real numbers
FMSY_M
An assumed ratio of FMSY to M. Vector nsim long. Positive real numbers
CV_FMSY_M
Coefficient of variation in the ratio in FMSY/M. Vector nsim long. Positive real numbers
BMSY_B0
The most productive stock size relative to unfished. Vector nsim long. Fraction
CV_BMSY_B0
Coefficient of variation in the position of the most productive stock size relative to unfished. Vector nsim long. Positive real numbers
Cref
Reference or target catch level (eg MSY). Vector of length nsim. Positive real numbers
CV_Cref
Log-normal CV for reference or target catch level. Vector of length nsim. Positive real numbers
Bref
Reference or target biomass level (eg BMSY). Vector of length nsim. Positive real numbers
CV_Bref
Log-normal CV for reference or target biomass level. Vector of length nsim. Positive real numbers
Iref
Reference or target relative abundance index level (eg BMSY / B0). Vector of length nsim. Positive real numbers
CV_Iref
Log-normalCV for reference or target relative abundance index level. Vector of length nsim. Positive real numbers
t
The number of years corresponding to AvC and Dt. Single value. Positive integer
AvC
Average catch over time t. Vector nsim long. Positive real numbers
CV_AvC
Coefficient of variation in average catches over time t. Vector nsim long. Positive real numbers
Dt
Depletion over time t SSB(now)/SSB(now-t+1). Vector nsim long. Fraction
CV_Dt
Coefficient of variation in depletion over time t. Vector nsim long. Positive real numbers
Ref
A reference management level (eg a catch limit). Single value. Positive real number
Ref_type
Type of reference management level (eg 2009 catch limit). Single value. Character string
Log
A record of events. Single value. Character string
params
A place to store estimated parameters. An object. R list
PosMPs
The methods that can be applied to these data. Vector. Character strings
TAC
The calculated catch limits (function TAC). An array with dimensions PosMPs x replicate TAC samples x nsim. Positive real numbers
Sense
The results of the sensitivity analysis (function Sense). An array with dimensions PosMPs x sensitivity increments. Positive real numbers
MPs
The methods that were applied to these data. Vector. Character strings
OM
A table of operating model conditions. R table object of nsim rows. Real numbers
Obs
A table of observation model conditions. R table object of nsim rows. Real numbers
Misc
Other information for MPs. An object. R list
Objects can be created by calls of the form
new('Data', stock)
T. Carruthers and A. Hordyk
newdata<-new('Data')
newdata<-new('Data')
A function that writes a correctly formatted .csv file from a MSEtool Data object
Data2csv(Data, file = NULL, simno = 1, overwrite = F, keepNAs = T)
Data2csv(Data, file = NULL, simno = 1, overwrite = F, keepNAs = T)
Data |
An object of class 'Data'. |
file |
Character string. The name of the location and file you wish to create (e.g. "C:/temp/mydata.csv") |
simno |
Integer. An optional argument to specify the simulation number if writing simulated data |
overwrite |
Boolean. Should existing data files be automatically overwritten. |
keepNAs |
Boolean. Should slots with NAs still be written to the data file. |
T. Carruthers
A data.frame with description of slots for class Data
DataDescription
DataDescription
An object of class data.frame
with 94 rows and 2 columns.
A way of locating where the package was installed so you can find example data files and code etc.
DataDir(stock = NA)
DataDir(stock = NA)
stock |
Character string representing the name of a .csv file e.g. 'Snapper', 'Rockfish' |
The file path to the object
T. Carruthers
## Not run: tilefish_location <- DataDir("Gulf_blue_tilefish") tilefish_Data <- new("Data", tilefish_location) ## End(Not run)
## Not run: tilefish_location <- DataDir("Gulf_blue_tilefish") tilefish_Data <- new("Data", tilefish_location) ## End(Not run)
Creates template for the Data input file (Excel or CSV) and Data documentation file (Markdown)
in the working directory or the directory specified by the dir
argument
DataInit(name = "Data", ext = c("xlsx", "csv"), overwrite = FALSE, dir = NULL)
DataInit(name = "Data", ext = c("xlsx", "csv"), overwrite = FALSE, dir = NULL)
name |
Name of the data input files. Default is 'Data'. Use 'Example' to create populated example Data Input and Data Documentation files. |
ext |
Optional file extension for input file. 'xlsx' (default) or 'csv' |
overwrite |
Logical. Overwrite existing files? |
dir |
Optional directory path to create the Data files. Default is 'getwd()“ |
Nothing. Creates template data files in the working directory.
A. Hordyk
## Not run: DataInit("Example") # populated example DataInit("myData") # empty template ## End(Not run)
## Not run: DataInit("Example") # populated example DataInit("myData") # empty template ## End(Not run)
Dataframe with details of slots in Dat object
DataSlots
DataSlots
An object of class tbl_df
(inherits from tbl
, data.frame
) with 101 rows and 4 columns.
Example objects of class Fleet
DecE_Dom DecE_HDom DecE_NDom FlatE_Dom FlatE_HDom FlatE_NDom Generic_DecE Generic_FlatE Generic_Fleet Generic_IncE IncE_HDom IncE_NDom Low_Effort_Non_Target Target_All_Fish Targeting_Small_Fish
DecE_Dom DecE_HDom DecE_NDom FlatE_Dom FlatE_HDom FlatE_NDom Generic_DecE Generic_FlatE Generic_Fleet Generic_IncE IncE_HDom IncE_NDom Low_Effort_Non_Target Target_All_Fish Targeting_Small_Fish
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
An object of class Fleet
of length 1.
avail("Fleet")
avail("Fleet")
A plot of biomass relative to BMSY over projected years
DFO_bar(MSEobj, yres = 10)
DFO_bar(MSEobj, yres = 10)
MSEobj |
An MSE object of class MSE produced by DLMtool function runMSE |
yres |
Integer: the year interval over which to calculate B/BMSY in future years |
T. Carruthers
A plot of current and historical stock status by simulation according to the stock status zones and reference points of DFO. http://www.dfo-mpo.gc.ca/reports-rapports/regs/sff-cpd/precaution-eng.htm
DFO_hist(OM, panel = T, nsim = 48)
DFO_hist(OM, panel = T, nsim = 48)
OM |
An operating model object of class OM |
panel |
should the plots be separate or in two panels? |
nsim |
how many simulations should be plotted (over-ridden by OM@nsim where cpars is specified) |
T. Carruthers
A plot of mean biomass relative to BMSY and fishing mortality rate relative to FMSY over the final 5 years of the projection http://www.dfo-mpo.gc.ca/reports-rapports/regs/sff-cpd/precaution-eng.htm
DFO_plot(MSEobj, zero_origin = T)
DFO_plot(MSEobj, zero_origin = T)
MSEobj |
An MSE object of class MSE produced by MSEtool function runMSE |
zero_origin |
Logical: should plots have a zero-zero origin? |
T. Carruthers
A preliminary plot for returning trade-offs plots and performance table for probability of obtaining half reference (FMSY) yield and probability of biomass dropping below 50 per cent BMSY
DFO_plot2(MSEobj, nam = NA, panel = T, Bcut = 50, Ycut = 50)
DFO_plot2(MSEobj, nam = NA, panel = T, Bcut = 50, Ycut = 50)
MSEobj |
An object of class MSE |
nam |
Title of plot |
panel |
Should the plots be organized in many panels in a single figure |
Bcut |
The cutoff biomass for satisficing (relative to BMSY) |
Ycut |
the cutoff yield for satisficing (relative to reference yield) |
A table of performance metrics.
T. Carruthers
A projection plot of MP performance by simulation according to the stock status zones and reference points of DFO. http://www.dfo-mpo.gc.ca/reports-rapports/regs/sff-cpd/precaution-eng.htm
DFO_proj(MSEobj, maxplot = 6)
DFO_proj(MSEobj, maxplot = 6)
MSEobj |
An operating model object of class MSE |
maxplot |
The maximum number of MPs to be plotted per figure |
T. Carruthers
A plot of biomass relative to BMSY quantiles over projected years
DFO_quant( MSEobj, maxcol = 6, qcol = rgb(0.4, 0.8, 0.95), lcol = "dodgerblue4", curyr = 2018, quants = c(0.05, 0.25, 0.75, 0.95), addline = T, forreport = T )
DFO_quant( MSEobj, maxcol = 6, qcol = rgb(0.4, 0.8, 0.95), lcol = "dodgerblue4", curyr = 2018, quants = c(0.05, 0.25, 0.75, 0.95), addline = T, forreport = T )
MSEobj |
An MSE object of class MSE produced by DLMtool function runMSE |
maxcol |
Integer how many columns for panel plots? |
qcol |
A color, the quantile coloration |
lcol |
A color, the mean B/BMSY line |
curyr |
The current calendar year |
quants |
A vector 2 long for the quantiles e.g. 0.1 and 0.9 for the 10th and 90th quantiles |
addline |
Should two individual example simulations be added to the plot? |
forreport |
Logical. Is it for a report? If true, one plot of six MPs in a row will be provided one after another. |
T. Carruthers
Provides performance plots typical in the assessment of Canadian fish stocks.
DFO_report( MSEobj, output_file = NA, author = "Author not specified", title = NA, maxMPs = 15 )
DFO_report( MSEobj, output_file = NA, author = "Author not specified", title = NA, maxMPs = 15 )
MSEobj |
An object of class MSE |
output_file |
The directory and filename you wish to use for the report e.g. "C:/temp/myMSEreport.html" |
author |
The person who made this report |
title |
The title of the report |
maxMPs |
Maximum number of MPs to plot |
T. Carruthers
DFO performance spider plot (top three MPs)
DFO_spider(MSEobj)
DFO_spider(MSEobj)
MSEobj |
An object of class MSE produced by MSEtool::runMSE() |
T. Carruthers
P_Cr_S is the probability of being in the critical zone in the first 10 projected years P_Ct_S is the probability of being in the cautious zone in the first 10 projected years P_H_S is the probability of being in the healthy zone in the first 10 projected years POF_S is the probability of overfishing in the first 10 projected years STY is the mean yield relative to FMSY management over the first 10 projected years P_Cr_L is the probability of being in the critical zone in the last 10 projected years P_Ct_L is the probability of being in the cautious zone in the last 10 projected years P_H_L is the probability of being in the healthy zone in the last 10 projected years POF_L is the probability of overfishing in the last 10 projected years LTY is the mean yield relative to FMSY management over the last 10 projected years AAVY is the average annual variability in yield over the whole projection phrased as a CV percentage P_Reb is the probability the stock has rebuilt to over BMSY in 2 mean generation times
DFO_tab(MSEobj, maxMPs = 15, rnd = 0)
DFO_tab(MSEobj, maxMPs = 15, rnd = 0)
MSEobj |
An object of class MSE |
maxMPs |
Integer: the maximum number of top ranking MPs to include in the table (ranked by long term yield) |
rnd |
The number of significant figures for rounding. |
T. Carruthers
Crit_S is the probability of being in the critical zone in the first 10 projected years Caut_S is the probability of being in the cautious zone in the first 10 projected years Health_S is the probability of being in the healthy zone in the first 10 projected years OvFish_S is the probability of overfishing in the first 10 projected years Yield_S is the mean yield relative to FMSY management over the first 10 projected years Crit is the probability of being in the critical zone in the last 10 projected years Caut is the probability of being in the cautious zone in the last 10 projected years Health is the probability of being in the healthy zone in the last 10 projected years OvFish is the probability of overfishing in the last 10 projected years Yield is the mean yield relative to FMSY management over the last 10 projected years AAVY is the average annual variability in yield over the whole projection phrased as a CV percentage Reb is the probability the stock has rebuilt to over BMSY in 2 mean generation times
DFO_tab_formatted( Ptab1, thresh = c(30, 50, 40, 60, 50, 20, 40, 50, 60, 50, 30, 50), ret_thresh = F )
DFO_tab_formatted( Ptab1, thresh = c(30, 50, 40, 60, 50, 20, 40, 50, 60, 50, 30, 50), ret_thresh = F )
Ptab1 |
A DFO performance table made by DFO_tab() |
thresh |
A vector of thresholds for each column Health, Yield and Reb are 'greater than threshold' conditions |
ret_thresh |
Logical: if true just the threshold levels are returned |
T. Carruthers
Directory of the installed package on your computer
DLMDataDir(stock = NA)
DLMDataDir(stock = NA)
stock |
Character string representing the name of a .csv file e.g. 'Snapper', 'Rockfish' |
The file path to the object
Double-normal selectivity curve
dnormal(lens, lfs, sl, sr)
dnormal(lens, lfs, sl, sr)
lens |
Vector of lengths |
lfs |
Length at full selection |
sl |
Sigma of ascending limb |
sr |
Sigma of descending limb |
A hockey stick (2 inflection points) HCR that accepts estimated level relative to reference level and modifies a proposed TAC based on control points for the x axis (est/ref) and y axis (fraction of TAC)
doHCR(trial_TAC, est, ref, CP = c(0, 1), CPy = c(0, 1))
doHCR(trial_TAC, est, ref, CP = c(0, 1), CPy = c(0, 1))
trial_TAC |
Postitive real number, the proposed total allowable catch before HCR modification. |
est |
Positive real number on same scale as ref, the estimated stock level (e.g. mean current index level) |
ref |
Positive real number on same scale as est, a reference level of stock level (e.g. index level at BMSY) |
CP |
Vector of real numbers, 2 positions long (c(Lx, Ux)), the lower and upper control points of a hockey stick HCR on the xaxis (est/ref). Below Lx (est/ref < Lx) the TAC is trial_TAC x Ly. Above Ux (est/ref > Ux) the TAC is trial_TAC x Uy. Between the TAC is linearly ramped between these levels. |
CPy |
Vector of real numbers, 2 positions long (c(Ly, Uy)), the lower and upper control points of a hockey stick HCR on the yaxis (fraction of trial_TAC). |
A real number (TAC advice but theoretically could be used for effort, size limits etc).
T. Carruthers
Given an index (historical period and projected period) this function creates sparsity in the projected index to simulate varying frequency (intensity) of data collection.
doIfreq(I_hist, I_freq, LHYr, CurYr, Year)
doIfreq(I_hist, I_freq, LHYr, CurYr, Year)
I_hist |
Vector of real numbers, concatinated observed (historical) and simulated (projected) indices. |
I_freq |
Positive integer. The frequency of index sampling (e.g. 1 is every year, 2 is every 2 years - a gap every 2 years in the projected, simulated data). |
LHYr |
Positive integer, a year (e.g. 2023), the last historical year, demarks the historical period where observations have been collected from the projected period where sparsity is to be simulated. |
CurYr |
Positive integer, a year (e.g. 2043), the most recent year of the simulation. |
Year |
Vector of positive integers (as long as I_hist), the years corresponding with I_hist. |
A thinned ector I_hist long of index observations.
T. Carruthers
MPs that perform worse than comparable MPs across all performance metrics are considered 'dominated' as other options are always preferable.
Dom(MSEobj, ..., PMlist = NULL, Refs = NULL, Yrs = NULL)
Dom(MSEobj, ..., PMlist = NULL, Refs = NULL, Yrs = NULL)
MSEobj |
An object of class |
... |
Names of Performance Metrics (PMs), or other arguments to |
PMlist |
Optional list of PM names. Overrides any supplied in ... above |
Refs |
An optional named list (matching the PM names) with numeric values to override the default |
Yrs |
An optional named list (matching the PM names) with numeric values to override the default |
The Dom
function compares the probabilities calculated in the performance metric
(PM
) functions and determines the MPs that have a lower probability across all PMs compared
to other MPs of the same management type (e.g., size limit, TAC, etc).
Consequently, it is important that all PM
functions are constructed so that higher probabilities = better performance
(e.g, PNOF
is the probability of NOT overfishing)
A named list of length 2 with a character vector of non-dominated MPs in MPs
and
a data.frame of dominated MPs and the names of the relevant dominated MPs in DomMPs
A. Hordyk
## Not run: MSE <- runMSE(MPs=NA) # run all MPs Nondom <- Dom(MSE, "P10", "LTY", "PNOF") # Non-dominated MPs Nondom$MPs # Dominated MPs Nondom$DomMPs ## End(Not run)
## Not run: MSE <- runMSE(MPs=NA) # run all MPs Nondom <- Dom(MSE, "P10", "LTY", "PNOF") # Non-dominated MPs Nondom$MPs # Dominated MPs Nondom$DomMPs ## End(Not run)
Creates a TAC management recommendation given constraints on how much that can change from previous TAC and contraints on minimum and maximum TAC
doRec(MPrec, mod, delta_down, delta_up, TACrng)
doRec(MPrec, mod, delta_down, delta_up, TACrng)
MPrec |
Positive real number, the previous management recommendation (e.g. 100 tonnes). |
mod |
Imperfect fraction, the proposed modification (change to MPrec) (e.g. 1.2 is a 20% increase) |
delta_down |
A vector 2 positions long, the minimum and maximum levels of downward change (e.g. when mod < 1) in the recommendation. |
delta_up |
A vector 2 positions long, the minimum and maximum levels of upward change (e.g. when mod > 1) in the recommendation. |
TACrng |
A vector 2 positions long, the minimum and maximum TAC (same units as MPrec). |
n object of class Rec.
T. Carruthers
An all-purpose empirical MP that runs of Indices of relative abundance
Emp( x, Data, reps = 1, Inds = NA, I_freq = NA, I_wt = NA, calib_yrs = 2, enp_mult = 0.3, Ind_fac = NA, TACrng = NA, delta_down = c(0.01, 0.5), delta_up = c(0.01, 0.5), resp = 1, curI_2_target = NA, HCR_CP_B = c(0, 0), HCR_CP_TAC = c(0, 1), Mode = 1 )
Emp( x, Data, reps = 1, Inds = NA, I_freq = NA, I_wt = NA, calib_yrs = 2, enp_mult = 0.3, Ind_fac = NA, TACrng = NA, delta_down = c(0.01, 0.5), delta_up = c(0.01, 0.5), resp = 1, curI_2_target = NA, HCR_CP_B = c(0, 0), HCR_CP_TAC = c(0, 1), Mode = 1 )
x |
Positive integer, the simulation number (a position in data object Data) |
Data |
An object of class 'Data' containing all fishery data (simulated or real - real has only one 'simulation') |
reps |
Positive integer, the number of stochastic samples of management advice (not applicable here) |
Inds |
Vector of positive integers. The indices (dimension 2) of the Additional Indices Data@AddInd to be used in calculation. When this is NA, the single index Data@Ind is used |
I_freq |
Vector of positive integers. Same length as Inds - how frequently will each index be available. 1 is every year, 2 is every 2 years, etc. |
I_wt |
Vector of positive real numbers. Same lengtt as Inds - the weighting of each index in the calculation of mean index level. |
calib_yrs |
Positive integer. The number of recent historical years used to calculate the 'current' Catch per Index value (more or less a nuisance parameter) |
enp_mult |
Fraction. The degree of smoothing for the polynomial function of indices. Larger numbers mean more smoothing. This is effective number of parameters. 0.3 means that the number of parameters in the polynomial smoother is 30% the length of the index. |
Ind_fac |
Positive real number. The factor (multiplier) of current catch(calib_yrs) / index(calib_yrs) to fish at in the future. A value of 2 means that per index the catches will be twice as high as today. If NA, the fraction of defaults to perfectly known mean((0.75 * FMSY)/last_historical_F) - mean over simulations. |
TACrng |
Vector 2 positions long, the minimum and maximum allowable catches. If NA this defaults to c(0, max_historical_catch*100) - essentially no TAC limit. |
delta_down |
Vector 2 positions long, the minimum and maximum allowable fractional downward change in TAC among management cycles. |
delta_up |
Vector 2 positions long, the minimum and maximum allowable fractional upward change in TAC among management cycles. |
resp |
Positive real number, the responsiveness of the TAC change algorithm. TAC_change = exp(log(new_TAC/old_TAC)*resp). Lower values linearly reduce the logspace TAC response and make smaller adjustements as proposed TAC changes are larger). |
curI_2_target |
Positive real number, the current (most recent historical year) index relative that at the target biomass level. If NA this defaults to perfectly known mean(last_historical_biomass / (1.25 * BMSY)), mean over all simulations. |
HCR_CP_B |
Vector of positive real numbers. Biomass control points of an HCR. These are the x-axis locations of the hockey stick inflection points. c(0,1) means a linear ramp from I/I_target. c(0.5,1) means no fishing til half I_target then a linear ramp in fishing to I_target. c(0,0) means no HCR. |
HCR_CP_TAC |
Vector of positive real numbers. Response control points of an HCR. These are the y-levels corresponding with the hockey stick. These are the minimum and maximum modifiers applied to the TAC recommendation. |
Mode |
Integer. What type of index-based MP is used? 1 = Index rate, aims to fish at a rate of index (ie TAC = f(I, current_C / current_I, Ind_fac, HCR_CP_B, HCR_CP_TAC)), 2 = Index target, makes incremental TAC adjustments based on I/I_target (i.e. TAC = f(I, curI_2_target, )) |
An object of class MP
.
T. Carruthers
What MPs may be run (best case scenario) for various data-availability scenarios and management constraints?
Fease( Data = NULL, TAC = TRUE, TAE = TRUE, SL = TRUE, Spatial = TRUE, names.only = TRUE, msg = TRUE, include.ref = FALSE )
Fease( Data = NULL, TAC = TRUE, TAE = TRUE, SL = TRUE, Spatial = TRUE, names.only = TRUE, msg = TRUE, include.ref = FALSE )
Data |
An object of class 'Data'. Optional. If Data object is included, the returned MPs are both feasible (in terms of management) and possible (sufficient data to run MP) |
TAC |
Logical. Are catch limits feasible for this fishery? |
TAE |
Logical. Are effort controls feasible for this fishery? |
SL |
Logical. Are size-selectivity regulations (either gear changes or size-retention regulations) feasible for this fishery? |
Spatial |
Logical. Are spatial closures feasible for this fishery? |
names.only |
Logical. Should only the names of the feasible MPs be returned (default)? If FALSE, a data frame with MP name, and two columns of logical values: Can (possible given data) and Fease (feasible given management constraints) is returned |
msg |
Logical. Should messages be printed to the console? |
include.ref |
Logical. Should reference MPs (e.g. FMSYref) be included as feasible methods? Default is FALSE |
Either a vector of MP names that are feasible for the fishery (default) or a 3 column data frame (names.only=FALSE
).
T. Carruthers & A. Hordyk
## Not run: Fease(TAC=FALSE) Fease(SL=FALSE, Spatial=FALSE) Fease(Atlantic_mackerel, TAE=FALSE, names.only=FALSE) ## End(Not run)
## Not run: Fease(TAC=FALSE) Fease(SL=FALSE, Spatial=FALSE) Fease(Atlantic_mackerel, TAE=FALSE, names.only=FALSE) ## End(Not run)
'Fleet'
The component of the operating model that controls fishing dynamics
Name
Identifying name for the fleet. Usually includes location and gear type.
nyears
The number of years for the historical simulation. Single value. For example, if the simulated population is assumed to be unfished in 1975 and this is the year you want to start your historical simulations, and the most recent year for which there is data available is 2019, then nyears equals 45.
CurrentYr
The last historical year simulated before projections begin.
Single value. Note that this should match the last historical year specified in
the Data
object, which is usually the last historical year for which data is
available.
EffYears
Vector indicating the historical years where there is information available to infer the relative fishing effort expended.This vector is specified in terms of the position of the year in the vector rather than the calendar year. For example, say our simulation starts with an unfished stock in 1975,and the current year (the last year for which there is data available) is 2019. Then there are 45 historical years simulated, and EffYears should include numbers between 1 and 45. Note that there may not be information available for every historical year, especially for data poor fisheries. In these situations, the EffYears vector should include only the positions of the years for which there is information, and the vector may be shorter than the total number of simulated historical years (nyears).
EffLower
Lower bound on relative fishing effort corresponding to EffYears. EffLower must be a vector that is the same length as EffYears describing how fishing effort has changed over time. Information on relative fishing effort can be entered in any units provided they are consistent across the entire vector because the data provided will be scaled to 1 (divided by the maximum number provided).
EffUpper
Upper bound on relative fishing effort corresponding to EffYears. EffUpper must be a vector that is the same length as EffYears describing how fishing effort has changed over time. Information on relative fishing effort can be entered in any units provided they are consistent across the entire vector because the data provided will be scaled to 1 (divided by the maximum number provided).
Esd
Additional inter-annual variability in fishing mortality rate. For
each historical simulation a single value is drawn from a uniform distribution
specified by the upper and lower bounds provided. If this parameter has a
positive (non-zero) value, the yearly fishing mortality rate is drawn from a
log-normal distribution with a standard deviation (in log space) specified by
the value of Esd
drawn for that simulation. This parameter applies only to
historical projections.
qinc
Mean temporal trend in catchability (also though of as the efficiency of fishing gear) parameter, expressed as a percentage change in catchability (q) per year. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Positive numbers indicate an increase and negative numbers indicate a decrease. q then changes by this amount for in each year of the simulation This parameter applies only to forward projections.
qcv
Inter-annual variability in catchability expressed as a coefficient of variation. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This parameter applies only to forward projections.
L5
Shortest length at which 5% of the population is vulnerable to selection by the gear used in this fleet. Values can either be specified as lengths (in the same units used for the maturity and growth parameters in the stock object) or as a percentage of the size of maturity (see the parameter isRel for more information). For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This value is the same in all years unless cpars is used to provide time-varying selection.
LFS
Shortest length at which 100% of the population is vulnerable to selection by the gear used by this fleet. Values can either be specified as lengths (in the same units used for the maturity and growth parameters in the stock object) or as a percentage of the size of maturity (see the parameter isRel for more information). For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This value is the same in all years unless cpars is used to provide time-varying selection.
Vmaxlen
Proportion of fish selected by the gear at the asymptotic
length (Stock@Linf
). Upper and Lower bounds between 0 and 1. A value of
1 indicates that 100% of fish are selected at the asymptotic length, and the
selection curve is logistic. If Vmaxlen
is less than 1 the selection curve is
dome shaped. For example, if Vmaxlen
is 0.4, then only 40% of fish are
vulnerable to the fishing gear at the asymptotic length.
isRel
Specify whether selection and retention parameters use absolute lengths or relative to the size of maturity. Single logical value (TRUE or FALSE).
LR5
Shortest length at which 5% of the population is vulnerable to retention by the fleet. Values can either be specified as lengths (in the same units used for the maturity and growth parameters in the stock object) or as a percentage of the size of maturity (see the parameter isRel for more information). For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This value is the same in all years unless cpars is used to provide time-varying selection.
LFR
Shortest length where 100% of the population is vulnerable to
retention by the fleet. Values can either be specified as lengths (in the same
units used for the maturity and growth parameters in the stock object) or as a
percentage of the size of maturity (see the parameter isRel
for more
information). For each simulation a single value is drawn from a uniform
distribution specified by the upper and lower bounds provided. This value is
the same in all years unless cpars is used to provide time-varying selection.
Rmaxlen
Proportion of fish retained at the asymptotic length
(Stock@Linf
). Upper and Lower bounds between 0 and 1. A value of 1
indicates that 100% of fish are retained at the asymptotic length, and the
selection curve is logistic. If Rmaxlen
is less than 1 the retention curve is
dome shaped. For example, if Rmaxlen
is 0.4, then only 40% of fish at the
asymptotic length are retained.
DR
Discard rate, defined as the proportion of fully selected fish that are discarded by the fleet. Upper and Lower bounds between 0 and 1, with a value of 1 indicates that 100% of selected fish are discarded. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided.
Spat_targ
Distribution of fishing in relation to vulnerable biomass (VB) across areas. The distribution of fishing effort is proportional to VB^Spat_targ. Upper and lower bounds of a uniform distribution. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This parameter allows the user to model either avoidance or spatial targeting behavior by the fleet. If the parameter value is 1, fishing effort is allocated across areas in proportion to the population density of that area. Values below 1 simulate an avoidance behavior and values above 1 simulate a targeting behavior.
MPA
Logical argument (TRUE or FALSE). Creates an MPA in Area 1 for all years if true is selected. Defaults to FALSE.
Misc
Miscellaneous list for bio-economic parameters
Objects can be created by calls of the form new('Fleet')
T. Carruthers and A. Hordyk
showClass('Fleet')
showClass('Fleet')
A data.frame with description of slots for class Fleet
FleetDescription
FleetDescription
An object of class data.frame
with 20 rows and 2 columns.
Several reference MPs for your operating model to use in the management strategy
evaluation. FMSYref (and related) assume perfect information about FMSY (FMSY
is taken from the operating model stored at Data@Misc$ReferencePoints$ByYear$FMSY
),
and set an effort limit (TAE) so that F=FMSY (or some fraction of FMSY) in
each year the MP is applied. NFref sets annual catch to zero and is used
for looking at variability in stock with no fishing.
FMSYref(x, Data, reps = 100, plot = FALSE) FMSYref50(x, Data, reps = 100, plot = FALSE) FMSYref75(x, Data, reps = 100, plot = FALSE) NFref(x, Data, reps = 100, plot = FALSE) curEref(x, Data, reps = 100, plot = FALSE)
FMSYref(x, Data, reps = 100, plot = FALSE) FMSYref50(x, Data, reps = 100, plot = FALSE) FMSYref75(x, Data, reps = 100, plot = FALSE) NFref(x, Data, reps = 100, plot = FALSE) curEref(x, Data, reps = 100, plot = FALSE)
x |
A position in the data object |
Data |
A data object |
reps |
The number of stochastic samples of the MP recommendation(s) |
plot |
Logical. Show the plot? |
Note that you can out-perform FMSYref
easily. The requirement for fixed
F is actually quite strict and is by no means the upper limit in terms of
yield. Don't panic if your method beats this one for yield, especially for
short-lived species of high temporal variability in productivity!
An object of class Rec
with the TAC
slot populated with a numeric vector of length reps
FMSYref()
: A reference FMSY method that fishes at FMSY
FMSYref50()
: A reference FMSY method that fishes at 50% of FMSY
FMSYref75()
: A reference FMSY method that fishes at 75% of FMSY
NFref()
: A reference MP that sets annual catch to almost zero (1e-15)
curEref()
: A reference MP that keeps fishing effort at the level of the last
historical year
See Data for information on the Data
object
T. Carruthers, A. Hordyk
FMSYref(1, MSEtool::SimulatedData, plot=TRUE) FMSYref50(1, MSEtool::SimulatedData, plot=TRUE) FMSYref75(1, MSEtool::SimulatedData, plot=TRUE) NFref(1, MSEtool::SimulatedData, plot=TRUE) curEref(1, MSEtool::SimulatedData)
FMSYref(1, MSEtool::SimulatedData, plot=TRUE) FMSYref50(1, MSEtool::SimulatedData, plot=TRUE) FMSYref75(1, MSEtool::SimulatedData, plot=TRUE) NFref(1, MSEtool::SimulatedData, plot=TRUE) curEref(1, MSEtool::SimulatedData)
Example objects of class Obs
Generic_Obs Imprecise_Biased Imprecise_Unbiased Perfect_Info Precise_Biased Precise_Unbiased
Generic_Obs Imprecise_Biased Imprecise_Unbiased Perfect_Info Precise_Biased Precise_Unbiased
An object of class Obs
of length 1.
An object of class Obs
of length 1.
An object of class Obs
of length 1.
An object of class Obs
of length 1.
An object of class Obs
of length 1.
An object of class Obs
of length 1.
avail("Obs")
avail("Obs")
Internal function for determining if object is of classy
getclass(x, classy)
getclass(x, classy)
x |
Character string object name |
classy |
A class of object (character string, e.g. 'Fleet') |
TRUE or FALSE
T. Carruthers with nasty hacks from A. Hordyk
Get part of an MP specific data-list
getDataList(MSElist, mm)
getDataList(MSElist, mm)
MSElist |
A hierarchical list [Stock][Fleet][MP] |
mm |
integer the MP number |
a sublist of MSElist for a specific MP
Extract the first dimension of a hierarchical list of recommendation objects
getfirstlev(x, name, pp, ff)
getfirstlev(x, name, pp, ff)
x |
Simulation number |
name |
Character. The slot name to extract. |
pp |
Integer. The stock number (second level list) |
ff |
Integer. The fleet number (third level list) |
T. Carruthers
The user specifies the probability of staying in the same area and spatial heterogeneity (both in the unfished state).
getmov2(x, Prob_staying, Frac_area_1)
getmov2(x, Prob_staying, Frac_area_1)
x |
A position in vectors Prob_staying and Frac_area_1 |
Prob_staying |
User specified probability that individuals in area 1 remain in that area (unfished conditions) |
Frac_area_1 |
User specified fraction of individuals found in area 1 (unfished conditions) |
This is paired with movfit to find the correct movement model.
A markov movement matrix
T. Carruthers
Prob_staying<-0.8 # probability that individuals remain in area 1 between time-steps Frac_area_1<-0.35 # the fraction of the stock found in area 1 under equilibrium conditions markovmat<-getmov2(1,Prob_staying, Frac_area_1) vec<-c(0.5,0.5) # initial guess at equilibrium distribution (2 areas) for(i in 1:300)vec<-apply(vec*markovmat,2,sum) # numerical approximation to stable distribution c(markovmat[1,1],vec[1]) # pretty close right?
Prob_staying<-0.8 # probability that individuals remain in area 1 between time-steps Frac_area_1<-0.35 # the fraction of the stock found in area 1 under equilibrium conditions markovmat<-getmov2(1,Prob_staying, Frac_area_1) vec<-c(0.5,0.5) # initial guess at equilibrium distribution (2 areas) for(i in 1:300)vec<-apply(vec*markovmat,2,sum) # numerical approximation to stable distribution c(markovmat[1,1],vec[1]) # pretty close right?
Calls dynGet()
, then get()
in order to find the MP definition in the R session.
getMP(MP)
getMP(MP)
MP |
Character of MP name |
The function definition or an error message from try()
if unsuccessful
Q. Huynh
Count independent variables for a MICE relationship at position x in a Rel list
getnIVs(x, Rel)
getnIVs(x, Rel)
x |
Position of a MICE relationship in the list Rel (MOM@Rel) |
Rel |
The list of MICE relationships (MOM@Rel) |
T.Carruthers
Calculate selectivity curve
getsel(x, lens, lfs, sls, srs)
getsel(x, lens, lfs, sls, srs)
x |
Simulation number |
lens |
Matrix of lengths (nsim by nlengths) |
lfs |
Vector of length at full selection (nsim long) |
sls |
Vector of sigmas of ascending limb (nsim long) |
srs |
Vector of sigmas of descending limb (nsim long) |
Convert stock recruit parameters from steepness parameterization to alpha/beta (and vice versa)
hconv(alpha, phi0, SR = 1, type = 1) R0conv(alpha, beta, phi0, SR = 1, type = 1) SRalphaconv(h, phi0, SR = 1, type = 1) SRbetaconv(h, R0, phi0, SR = 1, type = 1)
hconv(alpha, phi0, SR = 1, type = 1) R0conv(alpha, beta, phi0, SR = 1, type = 1) SRalphaconv(h, phi0, SR = 1, type = 1) SRbetaconv(h, R0, phi0, SR = 1, type = 1)
alpha |
Alpha parameter |
phi0 |
Unfished spawners per recruit |
SR |
Stock-recruit function: (1) Beverton-Holt, or (2) Ricker |
type |
The parameterization of the Beverton-Holt function with respect to |
beta |
Beta parameter |
h |
Steepness parameter |
R0 |
Unfished recruitment parameter |
The Type 1 Beverton-Holt equation is
The Type 2 Beverton-Holt equation is
The Ricker equation is
A numeric.
hconv()
: Returns steepness (h) from alpha
and phi0
R0conv()
: Returns unfished recruitment (R0) from alpha
, beta
, and phi0
SRalphaconv()
: Returns alpha
from h
and phi0
SRbetaconv()
: Returns beta
from h
, R0
, and phi0
Q. Huynh
expandHerm
expands the Herm list in SexPars to a matrix of fractions at age
checkHerm
checks that each array in the list has dimension nsim x maxage+1 x nyears + proyears.
For backwards compatibility, also converts matrices to arrays by adding the year dimension.
subsetHerm
returns year-specific Herm values.
expandHerm(Herm, maxage, np, nsim) checkHerm(Herm, maxage, nsim, nyears, proyears) subsetHerm(Herm, y)
expandHerm(Herm, maxage, np, nsim) checkHerm(Herm, maxage, nsim, nyears, proyears) subsetHerm(Herm, y)
Herm |
A list of Hermaphroditic fractions at age |
maxage |
The maximum age of stocks being simulated |
np |
The total number of stocks being simulated |
nsim |
The number of simulations |
nyears |
The number of historical years |
proyears |
The number of projection years |
y |
The year to subset |
T. Carruthers
Q. Huynh
'Hist'
An object for storing information generated by the end of the historical simulations
Data
The Data object at the end of the historical period
OMPars
A numeric data.frame with nsim rows with sampled Stock, Fleet, Obs, and Imp parameters.
AtAge
A named list with arrays of dimensions: c(nsim, maxage+1, nyears+proyears)
or
c(nsim, maxage+1, nyears, nareas)
Length: Length-at-age for each simulation, age, and year
Weight: Weight-at-age for each simulation, age, and year
Select: Selectivity-at-age for each simulation, age, and year
Retention: Retention-at-age for each simulation, age, and year
Maturity: Maturity-at-age for each simulation, age, and year
N.Mortality: Natural mortality-at-age for each simulation, age, and year
Z.Mortality: Total mortality-at-age for each simulation, age, year and area
F.Mortality: Fishing mortality-at-age for each simulation, age, year and area
Fret.Mortality: Fishing mortality-at-age for retained fish for each simulation, age, year and area
Number: Total numbers by simulation, age, year and area
Biomass: Total biomass by simulation, age, year and area
VBiomass: Vulnerable biomass by simulation, age, year and area
SBiomass: Spawning biomass by simulation, age, year and area
Removals: Removals (biomass) by simulation, age, year and area
Landings: Landings (biomass) by simulation, age, year and area
Discards: Discards (biomass) by simulation, age, year and area
TSdata
A named list with population and fleet dynamics:
Number: Total numbers; array dimensions c(nsim, nyears, nareas)
Biomass: Total biomass; array dimensions c(nsim, nyears, nareas)
VBiomass: Vulnerable biomass; array dimensions c(nsim, nyears, nareas)
SBiomass: Spawning Biomass; array dimensions c(nsim, nyears, nareas)
Removals: Removals (biomass); array dimensions c(nsim, nyears, nareas)
Landings: Landings (biomass); array dimensions c(nsim, nyears, nareas)
Discards: Discards (biomass); array dimensions c(nsim, nyears, nareas)
Find: Historical fishing mortality (scale-free); matrix dimensions c(nsim, nyears)
RecDev: Recruitment deviations (historical and projection); matrix dimensions c(nsim, nyears+proyears+maxage)
SPR: Named list with Equilibrium and Dynamic SPR (both matrices iwth dimensions c(nsim, nyears)
)
Unfished_Equilibrium: A named list with unfished equilibrium numbers and biomass-at-age
Ref
A named list with biological reference points:
ByYear: A named list with asymptotic reference points (i.e., calculated annually without recruitment deviations) all matrices with dimensions nsim
by nyears+proyears
:
N0: Asymptotic unfished total number
SN0: Asymptotic unfished spawning number
B0: Asymptotic unfished total biomass
SSB0: Asymptotic unfished spawning biomass
VB0: Asymptotic unfished vulnerable biomass
MSY: Asymptotic MSY
FMSY: Fishing mortality corresponding with asymptotic MSY
SSBMSY: Spawning stock biomass corresponding with asymptotic MSY
BMSY: total biomass corresponding with asymptotic MSY
VBMSY: Vulnerable biomass corresponding with asymptotic MSY
F01: Fishing mortality where the change in yield per recruit is 10% of that at F = 0
Fmax: Fishing mortality that maximizes yield per recruit
F_SPR: Fishing mortality corresponding to spawning potential ratio of 20 - 60% in increments of 5%; array dimensions c(nsim, 9, nyears+proyears)
Fcrash: Fishing mortality corresponding to the recruits-per-spawner at the origin of the stock-recruit relationship
Fmed: Fishing mortality corresponding to the median recruits-per-spawner in the historical period
SPRcrash: SPR corresponding to the recruits-per-spawner at the origin of the stock-recruit relationship
Dynamic_Unfished: A named list with dynamic unfished reference points for each simulation and year:
N0: Unfished total numbers
B0: Unfished total biomass
SN0: Unfished spawning numbers
SSB0: Unfished spawning biomass
VB0: Unfished vulnerable biomass
Rec: Unfished recruitment
ReferencePoints: A data.frame with nsim
rows with with biological reference points
calculated as an average over age-of-maturity ageM
years around the
current year (i.e. nyears
):
N0: Average unfished numbers
B0: Average unfished biomass
SSB0: Average unfished spawning biomass (used to calculate depletion)
SSN0: Average unfished spawning numbers
VB0: Average unfished vulnerable biomass (used to calculate depletion if cpar$control$D='VB'
)
MSY: Average maximum sustainable yield (equilibrium)
FMSY: Average fishing mortality corresponding with MSY
SSBMSY: Average spawning stock biomass corresponding with MSY
BMSY: Average total biomass corresponding with MSY
VBMSY: Average vulnerable biomass corresponding with MSY
UMSY: Average exploitation rate corresponding with MSY
FMSY_M: Average FMSY/M ratio
SSBMSY_SSB0: Average ratio of SSBMSY to SSB0
BMSY_B0: Average ratio of BMSY to B0
VBMSY_VB0: Average ratio of VBMSY to VB0
RefY: Maximum yield obtained in forward projections with a fixed F
SampPars
A named list with all sampled Stock, Fleet, Obs, and Imp parameters
OM
The OM
object (without cpars)
Misc
A list for additional information
A. Hordyk
Produces a blank plot if all values in x are equal
hist2(x, col, axes = FALSE, main = "", breaks = 10, cex.main = 1)
hist2(x, col, axes = FALSE, main = "", breaks = 10, cex.main = 1)
x |
A vector of values |
col |
Colour of the histogram |
axes |
Logical - should axes be included? |
main |
Character - main title |
breaks |
Number of breaks. See ?hist for more details |
cex.main |
Text size of the main title |
A data.frame with description of slots for class Hist
HistDescription
HistDescription
An object of class data.frame
with 76 rows and 2 columns.
'Imp'
An operating model component that specifies the degree of adherence to management recommendations (Implementation error)
Name
The name of the Implementation error object. Single value. Character string.
Name
The name of the Implementation error object. Single value. Character string.
TACFrac
Mean fraction of recommended TAC that is actually taken. For
each historical simulation a single value is drawn from a uniform distribution
specified by the upper and lower bounds provided. This value is the mean TAC
fraction obtained across all years of that simulation, and a yearly TAC frac is
drawn from a log-normal distribution with the simulation mean and a coefficient
of variation specified by the value of TACSD
drawn for that simulation. If
the value drawn is greater than 1 the amount of catch taken is greater than
that recommended by the TAC, and if it is less than 1 the amount of catch taken
is less than that recommended by the TAC. Positive real numbers.
TACSD
Log-normal coefficient of variation in the fraction of
recommended TAC that is actually taken. For each historical simulation a single
value is drawn from a uniform distribution specified by the upper and lower
bounds provided. This value is used, along with the TACFrac
drawn for that
simulation, to create a log-normal distribution that yearly values specifying
the actual amount of catch taken are drawn from. Positive real numbers.
TAEFrac
Mean fraction of recommended TAE that is actually taken. For
each historical simulation a single value is drawn from a uniform distribution
specified by the upper and lower bounds provided. This value is the mean TAE
fraction obtained across all years of that simulation, and a yearly TAE frac is
drawn from a log-normal distribution with the simulation mean and a coefficient
of variation specified by the value of TAESD
drawn for that simulation. If
the value drawn is greater than 1 the amount of effort employed is greater than
that recommended by the TAE, and if it is less than 1 the amount of effort
employed is less than that recommended by the TAE. Positive real numbers.
TAESD
Log-normal coefficient of variation in the fraction of
recommended TAE that is actually taken. For each historical simulation a single
value is drawn from a uniform distribution specified by the upper and lower
bounds provided. This value is used, along with the TAEFrac
drawn for that
simulation, to create a log-normal distribution that yearly values speciying
the actual amount of efort employed are drawn from. Positive real numbers.
SizeLimFrac
Mean fraction of recommended size limit that is actually
retained. For each historical simulation a single value is drawn from a uniform
distribution specified by the upper and lower bounds provided. This value is
the mean size limit fraction obtained across all years of that simulation, and
a yearly size limit fraction is drawn from a log-normal distribution with the
simulation mean and a coefficient of variation specified by the value of
SizeLimSD
drawn for that simulation. If the value drawn is greater than 1 the
size of fish retained is greater than that recommended by the size limit, and
if it is less than 1 the amount of size of fish retained is less than that
recommended by the size limit. Positive real numbers.
SizeLimSD
Log-normal coefficient of variation in the fraction of
recommended size limit that is actually retained. For each historical
simulation a single value is drawn from a uniform distribution specified by the
upper and lower bounds provided. This value is used, along with the
SizeLimFrac
drawn for that simulation, to create a log-normal distribution
that yearly values speciying the actual fraction of the size limit retained are
drawn from. Positive real numbers.
Objects can be created by calls of the form
new('Imp')
#'
T. Carruthers and A. Hordyk
showClass('Imp')
showClass('Imp')
A data.frame with description of slots for class Imp
ImpDescription
ImpDescription
An object of class data.frame
with 7 rows and 2 columns.
initialize
~~~~ Methods for Function initialize
~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
%% ~~describe this method here~~
Runs a set of input control methods are returns the output in a single table
Input(Data, MPs = NA, reps = 100, timelimit = 10, CheckMPs = TRUE, msg = TRUE)
Input(Data, MPs = NA, reps = 100, timelimit = 10, CheckMPs = TRUE, msg = TRUE)
Data |
A Data object |
MPs |
A list of input MPs, if NA all available input MPs are run |
reps |
Number of repetitions (for those methods that use them) |
timelimit |
Maximum timelimit to run MP (in seconds) |
CheckMPs |
Logical, the Can function is run if this is TRUE |
msg |
Logical. Should messages be printed? |
A. Hordyk
## Not run: library(MSEtool) Input(MSEtool::Cobia) ## End(Not run)
## Not run: library(MSEtool) Input(MSEtool::Cobia) ## End(Not run)
Internal functions for reading iSCAM input and output files into R
load.iscam.files(model.dir, burnin = 1000, thin = 1, verbose = FALSE) fetch.file.names(path, filename) read.report.file(fn) read.data.file(file = NULL, verbose = FALSE) read.control.file( file = NULL, num.gears = NULL, num.age.gears = NULL, verbose = FALSE ) read.projection.file(file = NULL, verbose = FALSE) read.par.file(file = NULL, verbose = FALSE) read.mcmc(model.dir = NULL, verbose = TRUE)
load.iscam.files(model.dir, burnin = 1000, thin = 1, verbose = FALSE) fetch.file.names(path, filename) read.report.file(fn) read.data.file(file = NULL, verbose = FALSE) read.control.file( file = NULL, num.gears = NULL, num.age.gears = NULL, verbose = FALSE ) read.projection.file(file = NULL, verbose = FALSE) read.par.file(file = NULL, verbose = FALSE) read.mcmc(model.dir = NULL, verbose = TRUE)
model.dir |
Folder name |
burnin |
The initial mcmc samples to be discarded |
thin |
The degree of chain thinning 1 in every thin iterations is kept |
verbose |
should detailed results be printed to console |
path |
File path |
filename |
The filename |
fn |
File location |
file |
File location |
num.gears |
The number of gears |
num.age.gears |
The number age-gears |
load.iscam.files()
: Wrapper function to generate R list
fetch.file.names()
: A function for returning the three types of iSCAM input and output files
read.report.file()
: A function for returning the results of the .rep iscam file
read.data.file()
: A function for returning the results of the .dat iscam file
read.control.file()
: A function for returning the results of the iscam control file
read.projection.file()
: A function for returning the results of the iscam projection file
read.par.file()
: A function for returning the results of the iscam .par file
read.mcmc()
: A function for returning the results of the iscam mcmc files
Chris Grandin (DFO PBS)
Functions for importing an iSCAM assessment. From a fitted model, iSCAM2OM
populates the various slots of an operating model and iSCAM2Data
generates a Data object.
These functions rely on several functions written by Chris Grandin (DFO PBS).
iSCAM2OM( iSCAMdir, nsim = 48, proyears = 50, mcmc = FALSE, spawn_time_frac = 0, Name = "iSCAM model", Source = "No source provided", length_timestep = 1, nyr_par_mu = 2, Author = "No author provided", report = FALSE, silent = FALSE ) iSCAM2Data( iSCAMdir, Name = "iSCAM assessment", Source = "No source provided", length_timestep = 1, Author = "No author provided" )
iSCAM2OM( iSCAMdir, nsim = 48, proyears = 50, mcmc = FALSE, spawn_time_frac = 0, Name = "iSCAM model", Source = "No source provided", length_timestep = 1, nyr_par_mu = 2, Author = "No author provided", report = FALSE, silent = FALSE ) iSCAM2Data( iSCAMdir, Name = "iSCAM assessment", Source = "No source provided", length_timestep = 1, Author = "No author provided" )
iSCAMdir |
A folder with iSCAM input and output files in it. Alternatively, a list returned by load.iscam.files. |
nsim |
The number of simulations to take for parameters with uncertainty (for OM@cpars custom parameters) |
proyears |
The number of MSE projection years |
mcmc |
Logical, whether to use mcmc samples to create custom parameters cpars. Alternatively, a list returned by read.mcmc. Set the seed for the function to sub-sample the mcmc samples. |
spawn_time_frac |
Numeric between 0-1 indicating when spawning occurs within the time step |
Name |
The name of the operating model |
Source |
Reference to assessment documentation e.g. a url |
length_timestep |
How long is a model time step in years (e.g. a quarterly model is 0.25, a monthly model 1/12) (currently only uses annual time step) |
nyr_par_mu |
integer, the number of recent years to estimate vulnerability over for future projections |
Author |
Who did the assessment |
report |
logical should a numbers at age reconstruction plot be produced? |
silent |
logical should progress reporting be printed to the console? |
The function calls model <- load.iscam.files(iSCAMdir)
and grabs the following matrices:
model$mpd$d3_weight_mat
- fecundity (product of weight and maturity at age)
model$mpd$ma
- maturity at age
The function calls model <- load.iscam.files(iSCAMdir)
and then grabs the following matrices:
model$mpd$N
- abundance at age
model$mpd$F
- fishing mortality at age
model$mpd$M
- natural mortality at age
If a delay-difference model is recognized, then the following is used instead:
model$mpd$F_dd
- fishing mortality at age
model$mpd$M_dd
- natural mortality at age
Abundance at age is reconstructed using model$mpd$rt
(recruitment) and projected with F_dd
and
M_dd
to match model$mpd$numbers
.
If mcmc = TRUE
the function calls mcmc_model <- read.mcmc(iSCAMdir)
, and grabs nsim
sub-samples of the MCMC output
through the following arrays:
mcmc_model$params
and mcmc_model$ft
- fishing mortality at age from the fleet selectivity parameters and apical F's
mcmc_model$m
- year-specific natural mortality at age
mcmc_model$params$rinit
and mcmc_model$rt
- recruitment and abundance
While the iSCAM start age can be greater than zero, abundance at age is back-calculated to age zero with M, maturity, growth = 0. In this way, the stock-recruit dynamics from iSCAM are preserved.
These arrays are then passed to Assess2OM to generate the operating model.
iSCAM calculates the stock-recruit relationship and subsequently a single set of MSY and unfished reference points using R0, steepness, and unfished spawners per recruit from the mean M, fecundity, and growth (mean with respect to time).
R0 and h are recalculated for the operating model by obtaining the stock-recruit alpha and beta from the
iSCAM parameters and the mean unfished spawners per recruit in the first ageM
(age of 50% maturity) years.
T. Carruthers, Q. Huynh
iSCAM assessments are often fitted to numerous fleets that have differing age selectivities. iSCAMcomps is a simple way of providing the aggregate catch at age data. It should be noted that this process is important and in a real application would require due diligence (ie peer reviewed data workshop).
iSCAMcomps(replist, Year)
iSCAMcomps(replist, Year)
replist |
S3 class object: the output from a read from an iSCAM data folder |
Year |
Integer vector: the years of the data object ie Data@Year |
T. Carruthers
iSCAM assessments often make use of multiple indices of abundance. The data object and MPs currently only make use of a single index. combiSCAMinds is a function that creates a single index from many using linear modelling. It is a simple way of providing initial calculations of management recommendations and it should be noted that this process is important and in a real application would require due diligence (ie peer reviewed data workshop).
iSCAMinds(idata, Year, fleeteffect = T)
iSCAMinds(idata, Year, fleeteffect = T)
idata |
List: the indices recorded in a read from an iSCAM data folder, e.g. replist$data$indices |
Year |
Integer vector: the years of the data object ie Data@Year |
fleeteffect |
Logical: should a fleet effect be added to the linear model? |
T. Carruthers
Plot several plots with a shared legend
join_plots( plots, ncol = length(plots), nrow = 1, position = c("right", "bottom"), legend = TRUE )
join_plots( plots, ncol = length(plots), nrow = 1, position = c("right", "bottom"), legend = TRUE )
plots |
list of plot objects of class |
ncol |
Optional number of columns |
nrow |
Optional number of rows |
position |
position of the legend ("bottom" or "right") |
legend |
Logical. Use a legend? |
modified from https://github.com/tidyverse/ggplot2/wiki/share-a-legend-between-two-ggplot2-graphs
A function that combined a list of data objects into a single data object (same dimensions but can have different numbers of simulations)
joinData(DataList)
joinData(DataList)
DataList |
A list of data objects of identical dimension (except for simulation) |
T. Carruthers
A standard KOBE plot by each method that also shows the percentage of methods that ended up in each quadrant.
Kplot( MSEobj, maxsim = 60, MPs = NA, sims = NULL, maxMP = 9, nam = NA, cex.leg = 1.5 )
Kplot( MSEobj, maxsim = 60, MPs = NA, sims = NULL, maxMP = 9, nam = NA, cex.leg = 1.5 )
MSEobj |
An object of class MSE |
maxsim |
Maximum number of simulations (lines) to plot on each panel. |
MPs |
Optional subset MSE object by MP |
sims |
Optional subset MSE object by simulation |
maxMP |
Maximum number of MPs to include in plot |
nam |
The name of the plot |
cex.leg |
Size of legend |
Apologies for the nauseating shading.
T. Carruthers with some additions from A. Hordyk
Data
object by a specified number of time-stepsLag the time-series slots in a Data
object by a specified number of time-steps
Lag_Data(Data, Data_Lag = 0, msg = FALSE)
Lag_Data(Data, Data_Lag = 0, msg = FALSE)
Data |
An object of class |
Data_Lag |
Either a numeric vector of length 1 with a positive number specifying the number of time-steps to lag all time-series data, or a named list with numeric values (length 1). See details for more information. |
msg |
Logical. Display the messages? |
By default, all simulated data in the forward projections are provided up to the
previous time-step. That is, in projection year t
, the simulated data are up to
and including t-1
.
This function will lag the time-series values by the specified value. For example,
Data_Lag=5
will mean in projection time-step t
the data will be up to and
including t-6
.
Note: The Data@Year
slot is not lagged by this function.
Many built-in MPs use the length of Data@Year
to determine the number of
years of data for smoothing over recent years etc. This may not be appropriate
so check the MP is behaving as you expect if you use Lag_Data
.
An object of class Data
with time-series slots lagged.
# Lag all time-series slots by 2 time-steps (usually years) Data <- Example_datafile Lagged_1 <- Lag_Data(Data, 2) length(Data@Year) length(Lagged_1@Year) length(Data@Cat[1,]) length(Lagged_1@Cat[1,]) length(Data@Ind[1,]) length(Lagged_1@Ind[1,]) # Lag CAA by 5 and Ind by 3 time-steps Lagged_2 <- Lag_Data(Data, Data_Lag=list(CAA=5, Ind=3)) length(Lagged_2@Year) length(Lagged_2@Cat[1,]) dim(Data@CAA[1,,]) dim(Lagged_2@CAA[1,,]) length(Data@Ind[1,]) length(Lagged_2@Ind[1,])
# Lag all time-series slots by 2 time-steps (usually years) Data <- Example_datafile Lagged_1 <- Lag_Data(Data, 2) length(Data@Year) length(Lagged_1@Year) length(Data@Cat[1,]) length(Lagged_1@Cat[1,]) length(Data@Ind[1,]) length(Lagged_1@Ind[1,]) # Lag CAA by 5 and Ind by 3 time-steps Lagged_2 <- Lag_Data(Data, Data_Lag=list(CAA=5, Ind=3)) length(Lagged_2@Year) length(Lagged_2@Cat[1,]) dim(Data@CAA[1,,]) dim(Lagged_2@CAA[1,,]) length(Data@Ind[1,]) length(Lagged_2@Ind[1,])
Dimensions of a hierarchical list object
ldim(x)
ldim(x)
x |
A list |
T. Carruthers
Predict missing life-history based on taxonomic information and hierarchical model fitted to FishBase life-history parameters
LH2OM( OM, dist = c("unif", "norm"), filterMK = FALSE, plot = TRUE, Class = "predictive", Order = "predictive", Family = "predictive", msg = TRUE, db = MSEtool::LHdatabase ) predictLH( inpars = list(), Genus = "predictive", Species = "predictive", nsamp = 100, db = MSEtool::LHdatabase, dist = c("unif", "norm"), filterMK = TRUE, plot = TRUE, Class = "predictive", Order = "predictive", Family = "predictive", msg = TRUE )
LH2OM( OM, dist = c("unif", "norm"), filterMK = FALSE, plot = TRUE, Class = "predictive", Order = "predictive", Family = "predictive", msg = TRUE, db = MSEtool::LHdatabase ) predictLH( inpars = list(), Genus = "predictive", Species = "predictive", nsamp = 100, db = MSEtool::LHdatabase, dist = c("unif", "norm"), filterMK = TRUE, plot = TRUE, Class = "predictive", Order = "predictive", Family = "predictive", msg = TRUE )
OM |
An object of class 'OM' |
dist |
Character. Should parameters be sampled from a uniform ( |
filterMK |
Logical or numeric specifying percentiles. See Details.
e.g. |
plot |
Logical. Should the plot be produced? |
Class |
Optional higher order taxonomic information |
Order |
Optional higher order taxonomic information |
Family |
Optional higher order taxonomic information |
msg |
Logical. Should messages be printed? |
db |
Database from FishLife model with fitted model results |
inpars |
A named list with lower and upper bounds of provided parameters: Linf, L50, K and M (must be length 2). Unknown or missing parameters should not be included. For example, an empty list assumes that all four life history parameters are unknown and need to be estimated. See Details below for more information. |
Genus |
Character string specifying the Genus name. Optional. Default is 'predictive' |
Species |
Character string specifying the Species name. Optional. Default is 'predictive'. If full species name (Genus + Species) is not found if FishLife database (based on FishBase) higher order taxonomy will be used (e.g., Family) for the predictions. |
nsamp |
The number of samples to return |
If filterMK is logical: Should the predicted M and K parameters be filtered within the range specified in inpars
or OM
?
Otherwise, filterMK must be numeric vector of length(2) specifying lower and upper percentiles that will be applied to the predicted M or K values
The model predicts missing life-history parameters based on provided parameters and taxonomic information.
If both M and K are provided in inpars
or OM
, K values are predicted and predictions filtered
so that resulting K values are within bounds specified in inpars$K
or OM@K
(see filterMK
).
If both Linf and L50 are provided in inpars
or OM
, L50 values are predicted and values in inpars$L50
or OM@L50
are ignored.
LH2OM: An OM with OM@cpars
populated with OM@nsim
samples of M, K, Linf and L50
predictLH: A data.frame with nsamp
rows with Linf
, L50
, K
, and M
values.
LH2OM()
: Predict missing life-history and populate OM@cpars
predictLH()
: Predict missing life-history based on taxonomic information and
hierarchical model fitted to FishBase life-history parameters
A. Hordyk
https://github.com/James-Thorson-NOAA/FishLife
Thorson, J. T., S. B. Munch, J. M. Cope, and J. Gao. 2017. Predicting life history parameters for all fishes worldwide. Ecological Applications. 27(8): 2262–2276
Database from the FishLife package with predicted life-history parameters for all species on FishBase
LHdatabase
LHdatabase
An object of class list
of length 3.
https://github.com/James-Thorson-NOAA/FishLife/
Thorson, J. T., S. B. Munch, J. M. Cope, and J. Gao. 2017. Predicting life history parameters for all fishes worldwide. Ecological Applications. 27(8): 2262–2276
Converts an OM to a single stock, single fleet MOM.
makeMOM(..., silent = FALSE)
makeMOM(..., silent = FALSE)
... |
An OM. |
silent |
Should messages be printed out to the console? |
A class MOM object.
Q. Huynh
MOM <- makeMOM(testOM)
MOM <- makeMOM(testOM)
A function for calculating a movement matrix from user specified unfished stock biomass fraction in each area. Used by simmov to generate movement matrices for an operating model.
makemov(fracs = c(0.1, 0.2, 0.3, 0.4), prob = c(0.5, 0.8, 0.9, 0.95))
makemov(fracs = c(0.1, 0.2, 0.3, 0.4), prob = c(0.5, 0.8, 0.9, 0.95))
fracs |
A vector nareas long of fractions of unfished stock biomass in each area |
prob |
A vector of the probability of individuals staying in each area or a single value for the mean probability of staying among all areas |
T. Carruthers
A function for calculating a movement matrix from user specified distribution among areas (v) and relative movement to other areas (solves for positive diagonal - vector of prob staying). Used by simmov2 to generate movement matrices for an operating model. There must be a prior on the positive diagonal of the movement matrix or these will tend to 1 and hence perfectly satisfy the requirement V = MV.
makemov2( dist = c(0.05, 0.6, 0.35), prob = 0.5, probE = 1, frac_other = matrix(c(NA, 2, 1, 2, NA, 1, 1, 2, NA), nrow = 3, byrow = T), plot = F )
makemov2( dist = c(0.05, 0.6, 0.35), prob = 0.5, probE = 1, frac_other = matrix(c(NA, 2, 1, 2, NA, 1, 1, 2, NA), nrow = 3, byrow = T), plot = F )
dist |
A vector nareas long of fractions of unfished stock biomass in each area |
prob |
A vector of the probability of individuals staying in each area or a single value for the mean probability of staying among all areas |
probE |
The logit CV associated with prob (used as a penalty when optimizing for diagonal) |
frac_other |
A matrix nareas x nareas that specifies the relative fraction moving from one area to the others. The positive diagonal is unspecified. |
plot |
Should the convergence to a stable distribution be plotted? |
T. Carruthers
Generate a MICE Rel
object, with predict
and simulate
methods, for multiMSE.
Currently implements intra-stock dynamics via density-dependent processes.
makeRel(type = "DDM", stock = 1, CV = 0, ...) ## S3 method for class 'Rel' print(x, ...) ## S3 method for class 'Rel' predict(object, newdata, ...) ## S3 method for class 'Rel' simulate(object, nsim = 1, seed = 1, ...)
makeRel(type = "DDM", stock = 1, CV = 0, ...) ## S3 method for class 'Rel' print(x, ...) ## S3 method for class 'Rel' predict(object, newdata, ...) ## S3 method for class 'Rel' simulate(object, nsim = 1, seed = 1, ...)
type |
String to indicate the type of stock interaction. |
stock |
The index position of the stock in the MOM. |
CV |
Coefficient of variation of the predicted value for |
... |
Additional arguments depending on |
x |
For |
object |
A |
newdata |
A data frame to provide values of predictor variables with which to calculate the response variable. |
nsim |
The number of simulations. |
seed |
Integer to specify the seed for the random number generator. |
A class "Rel" object to pass to MOM@Rel
.
Natural mortality (M) is a linear function of stock depletion in terms to total biomass (B) in year y (Forrest et al. 2018):
with a constraint that if
Provide the following arguments:
M0
: Natural mortality as B approaches B0. Vector [nsim]
M1
: Natural mortality as B approaches zero. Vector [nsim]
Optional B0
: Unfished biomass. Calculated from stock-recruit alpha
and beta
and unfished
biomass per recruit at M = M0. Vector [nsim]
Q. Huynh
Forrest, R., Holt, K., and Kronlund, A. 2018. Performance of alternative harvest control rules for two Pacific groundfish stocks with uncertain natural mortality: Bias, robustness and trade-offs. Fisheries Research 206: 259–286. doi:10.1016/j.fishres.2018.04.007
# Depensatory natural mortality Rel <- makeRel(type = "DDM", M0 = 0.8, M1 = 0.2, CV = 0.1) # Predict M when B/B0 = 0.1 pred <- predict(Rel, newdata = data.frame(B_1 = 0.1, B0_1 = 1)) # Simulate values of M with CV = 0.1 Rel$fitted.values <- pred simulate(Rel, nsim = 10, seed = 1) # Add Rel to MOM MOM <- makeMOM(testOM) MOM@Rel <- list(Rel)
# Depensatory natural mortality Rel <- makeRel(type = "DDM", M0 = 0.8, M1 = 0.2, CV = 0.1) # Predict M when B/B0 = 0.1 pred <- predict(Rel, newdata = data.frame(B_1 = 0.1, B0_1 = 1)) # Simulate values of M with CV = 0.1 Rel$fitted.values <- pred simulate(Rel, nsim = 10, seed = 1) # Add Rel to MOM MOM <- makeMOM(testOM) MOM@Rel <- list(Rel)
Make colors transparent
makeTransparent(someColor, alpha = 100)
makeTransparent(someColor, alpha = 100)
someColor |
Character string describing color |
alpha |
transparency |
T. Carruthers
A highly dubious means of getting very uncertain estimates of current stock biomass and (equilibrium) fishing mortality rate from growth, natural mortality rate, recruitment and fishing selectivity.
ML2D(OM, ML, nsim = 100, ploty = T, Dlim = c(0.05, 0.6))
ML2D(OM, ML, nsim = 100, ploty = T, Dlim = c(0.05, 0.6))
OM |
An object of class 'OM' |
ML |
A estimate of current mean length of catches |
nsim |
Number of simulations |
ploty |
Produce a plot of depletion and F |
Dlim |
Limits on the depletion that is returned as a fraction of unfished biomass. |
An object of class 'OM' with 'D' slot populated
T. Carruthers
'MMSE'
A Multi Management Strategy Evaluation object that contains information about simulation conditions and performance of MPs for a multi-stock, multi-fleet operating model.
Name
Name of the MMSE object. Single value. Character string
nyears
The number of years for the historical simulation. Single value. Positive integer
proyears
The number of years for the projections - closed loop simulations. Single value. Positive integer
nMPs
Number of management procedures simulation tested. Single value. Positive integer.
MPs
The names of the MPs that were tested. Vector of length nMPs. Character strings.
MPcond
The MP condition. Character ('bystock': an MP per stock, 'byfleet' and MP per stock and fleet, 'MMP' an MP for all stocks and fleets)
MPrefs
The names of the MPs applied for each stock (row) and fleet (column). An array.
nsim
Number of simulations. Single value. Positive integer
nstocks
Number of stocks. Single value. Positive integer
nfleets
Number of fleets. Single value. Positive integer
Snames
Names of the stocks
Fnames
Names of the fleets (matrix nstocks x nfleets)
Stocks
The stock operating model objects. List of Stocks
Fleets
The fleet operating model objects. Hierarchical list, fleets nested in stocks.
Obss
The fleet specific observation error operating model objects. Hierarchical list, fleets nested in stocks.
Imps
The fleet specific implementation error operating model objects. Hierarchical list, fleets nested in stocks.
OM
A table of sampled parameters of the operating model. Data frame of nsim rows.
Obs
A table of sampled parameters of the observation model. Data frame of nsim rows.
SB_SBMSY
Simulated spawning biomass relative to SBMSY over the projection. An array with dimensions: nsim, nStocks, nMPs, proyears. Non-negative real numbers
F_FMSY
Simulated fishing mortality rate relative to FMSY over the projection. An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
N
Simulated stock numbers over the projection. An array with dimensions: nsim, nStocks, maxage
+1, nMPs, proyears, nareas. Non-negative real numbers
B
Simulated stock biomass over the projection. An array with dimensions: nsim, nStocks, nMPs, proyears. Non-negative real numbers
SSB
Simulated spawning stock biomass over the projection. An array with dimensions: nsim, nStocks, nMPs, proyears. Non-negative real numbers
VB
Simulated vulnerable biomass over the projection. An array with dimensions: nsim, nStocks, nMPs, proyears. Non-negative real numbers
FM
Simulated fishing mortality rate over the projection. An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
SPR
A list of SPR values. Currently not used.
Catch
Simulated catches (landings) over the projection. An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
Removals
Simulated removals (landings+discards) over the projection. An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
Effort
Simulated relative fishing effort in the projection years. An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
TAC
Simulated Total Allowable Catch (prescribed) over the projection (this is NA for input controls). An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
TAE
Simulated Total Allowable Effort (prescribed) over the projection (this is NA for output controls). An array with dimensions: nsim, nStocks, nFleets, nMPs, proyears. Non-negative real numbers
BioEco
A named list of bio-economic output. Not currently used.
RefPoint
Named list of annual MSY reference points MSY, FMSY, and SBMSY.
Array with dimensions: nsim, nstocks, nMPs, nyears+proyears. Will be the same as multiHist@Ref$ByYear
unless selectivity is changed by MP
multiHist
The object of class multiHist
containing information from the spool-up period.
PPD
Posterior predictive data. List of Data
objects at the end of
the projection period (length nMPs
)
Misc
Miscellaneous output such as posterior predictive data
Objects can be created by calls of the form
new('MMSE', Name, nyears, proyears, nMPs, MPs, nsim, OMtable, Obs,
B_BMSYa, F_FMSYa, Ba, FMa, Ca, OFLa, Effort, PAA, CAA, CAL, CALbins)
T. Carruthers
'MOM'
An object containing all the parameters needed to control a multi-stock, multi-fleet MSE which can be build from component Stock, Fleet, Obs, and Imp objects.
Almost all of these inputs are a vector of length 2 which describes the upper and lower bounds of a uniform distribution from which to sample the parameter.
Name
Name of the operating model
Agency
Name of the agency responsible for the management of the fishery. Character string
Region
Name of the general geographic region of the fishery. Character string
Sponsor
Name of the organization who sponsored the OM. Character string
Latitude
Latitude (decimal degrees). Negative values represent the South of the Equator. Numeric. Single value
Longitude
Longitude (decimal degrees). Negative values represent the West of the Prime Meridian. Numeric. Single value
nsim
The number of simulations
proyears
The number of projected years
interval
The assessment interval - how often would you like to update the management system?
pstar
The percentile of the sample of the management recommendation for each method
maxF
Maximum instantaneous fishing mortality rate that may be simulated for any given age class
reps
Number of samples of the management recommendation for each method. Note that when this is set to 1, the mean value of the data inputs is used.
cpars
A hierarchical list nstock then nfleet long of custom parameters. Time series are a matrix nsim rows by nyears columns. Single parameters are a vector nsim long. See validcpars()
seed
A random seed to ensure users can reproduce results exactly
Source
A reference to a website or article from which parameters were taken to define the operating model
Stocks
List of stock objects
Fleets
List of Fleet objects
Obs
Hierarchical List of Observation model objects Level 1 is stock, level 2 is fleet
Imps
Hierarchical List of Implementation model objects Level 1 is stock, level 2 is fleet
CatchFrac
A list nstock long, of matrices nsim x nfleet representing the fraction of current catches of the various fleets to each stock (each matrix is nsim by nfleet long and rows sum to 1 for each stock)
Allocation
A list nstock long, of matrices nsim x nfleet representing the fraction of future TACs of the various fleets to each stock (each matrix is nsim by nfleet long and rows sum to 1 for each stock).
Efactor
A list nstock long, of current effort factors by fleet (default is 1 - same as current effort)
Complexes
A list of stock complexes. Each position is a vector of stock numbers (as they appear in StockPars) for which data should be aggregated and TAC recommendations split among stocks according to vulnerable biomass
SexPars
A list of slots that control sex-specific dynamics, i.e., sex-specific spawning and hermaphroditism. More generally, controls spawning and moving abundance between stocks. See details.
Rel
A list of biological / ecological relationships among stocks over-ridden if an MP of class 'MP_F" is supplied that is a multi-fleet MP.
Objects can be created by calls of the form
new('MOM', Stock_list, Fleet_list, Obs_list, Imp_list)
.
SSBfrom
A nstock x nstock matrix that specifies the proportion of the spawning output of the row p stock for the column p' stock. A diagonal matrix means each stock is
responsible for its own recruitment.
Herm
A list with each entry containing a matrix (nsim x maxage + 1) that specifies the proportion at age that moves from stock p to p' (sequential hermaphroditism).
The names of the list should be of the form "H_p'_p" where p and p' are integers that identify the stock. Arrays can also be used (nsim x maxage + 1 x nyears + proyears) for time-varying values.
share_par
Optional. Logical to indicate whether stock-recruit, depletion, and observation/implementation parameters are mirrored between stocks. By default, TRUE.
T. Carruthers and A. Hordyk
Article on MOM
and multiMSE
: https://openmse.com/features-multimse/
Apply the movement model to the stock for one time-step
movestockCPP(nareas, maxage, mov, Number)
movestockCPP(nareas, maxage, mov, Number)
nareas |
The number of spatial areas |
maxage |
The maximum age |
mov |
Numeric matrix (nareas by nareas) with the movement matrix |
Number |
A numeric matrix (maxage+1, nareas) with current numbers-at-age in each area |
A. Hordyk
The user specifies the probability of staying in the same area and spatial heterogeneity (both in the unfished state). This function returns the squared difference between these values and those produced by the three logit movement model.
movfit_Rcpp(par, prb, frac)
movfit_Rcpp(par, prb, frac)
par |
Three parameters in the logit space that control the four probabilities of moving between 2 areas |
prb |
User specified probability that individuals in area 1 remain in that area (unfished conditions) |
frac |
User specified fraction of individuals found in area 1 (unfished conditions) |
This is paired with getmov to find the correct movement model.
T. Carruthers with an amateur attempt at converting to Rcpp by A. Hordyk (but it works!)
Fill any NAs arising from MPCalcs (hermaphroditism mode)
MPCalcsNAs(MPCalcs)
MPCalcsNAs(MPCalcs)
MPCalcs |
A list of arrays arising fromt the DLMtool function CalcMPDynamics() |
T. Carruthers
Management Procedure Type
MPtype(MPs = NA)
MPtype(MPs = NA)
MPs |
A vector of MP names. If none are provided function is run on all available MPs |
A data.frame with MP names, management type (e.g "Input", "Output") and management recommendations returned by the MP (e.g, TAC (total allowable catch), TAE (total allowable effort), SL (size-selectivity), and/or or Spatial)
MPtype(c("AvC", "curE", "matlenlim", "MRreal", "FMSYref"))
MPtype(c("AvC", "curE", "matlenlim", "MRreal", "FMSYref"))
'MSE'
A Management Strategy Evaluation object that contains information about simulation conditions and performance of data-limited methods
Name
Name of the MSE object. Single value. Character string
nyears
The number of years for the historical simulation. Single value. Positive integer
proyears
The number of years for the projections - closed loop simulations. Single value. Positive integer
nMPs
Number of management procedures simulation tested. Single value. Positive integer.
MPs
The names of the MPs that were tested. Vector of length nMPs. Character strings.
nsim
Number of simulations. Single value. Positive integer
OM
Operating model parameters (last historical year used for
time-varying parameters). Data.frame with nsim
rows
Obs
Observation parameters (last historical year used for time-varying
parameters). Data.frame with nsim
rows
SB_SBMSY
Simulated spawning biomass relative to spawning BMSY over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
F_FMSY
Simulated fishing mortality rate relative to FMSY over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
N
Simulated total numbers over the projection. An array with dimensions: nsim, maxage+1, nMPs, proyears, nareas. Non-negative real numbers.
B
Simulated stock biomass over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
SSB
Simulated spawning stock biomass over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
VB
Simulated vulnerable biomass over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
FM
Simulated fishing mortality rate over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
SPR
Named list with equilibrium and dynamic SPR. Each element is an array with dimensions: nsim, nMPs, proyears. Non-negative real numbers.
Catch
Simulated catches (landings) over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
Removals
Simulated removals (catch + discards) over the projection. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
Effort
Simulated relative fishing effort in the projection years. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
TAC
Simulated Total Allowable Catch prescribed by MPs. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
TAE
Simulated Total Allowable Effort prescribed by MPs. An array with dimensions: nsim, nMPs, proyears. Non-negative real numbers
BioEco
Named list with bio-economic output Only used if bio-economic parameters are included in OM
RefPoint
Named list of annual MSY reference points MSY, FMSY, and
SBMSY. Array with dimensions: nsim, nMPs, nyears+proyears. Will be the same as
Hist@Ref$ByYear
unless selectivity is changed by MP
CB_hist
Simulated catches (landings) from the spool-up period. An array with dimensions: nsim, nyears. Non-negative real numbers
FM_hist
Simulated fishing mortality rate from the spool-up period. An array with dimensions: nsim, nyears Non-negative real numbers
SSB_hist
Simulated spawning stock biomass from the spool-up period. An array with dimensions: nsim, nyears. Non-negative real numbers
Hist
Information from the historical spool-up period. Object of class
Hist
. Only contains slots AtAge
and TSdata
unless extended=TRUE
in runMSE
PPD
Posterior predictive data. List of Data
objects at the end of
the projection period (length nMPs
)
Misc
Miscellaneous output
T. Carruthers and A. Hordyk
A data.frame with description of slots for class MSE
MSEDescription
MSEDescription
An object of class data.frame
with 29 rows and 2 columns.
Downloads the MSEextra package from GitHub
MSEextra(silent = FALSE, force = FALSE)
MSEextra(silent = FALSE, force = FALSE)
silent |
Logical. Should messages to printed? |
force |
Logical. For install from github if package is up-to-date? |
Internal function to calculate MSY Reference Points
MSYCalcs( logF, M_at_Age, Wt_at_Age, Mat_at_Age, Fec_at_Age, V_at_Age, maxage, relRfun, SRRpars, R0x = 1, SRrelx = 3L, hx = 1, SSBpR = 0, opt = 1L, plusgroup = 1L, spawn_time_frac = 0 )
MSYCalcs( logF, M_at_Age, Wt_at_Age, Mat_at_Age, Fec_at_Age, V_at_Age, maxage, relRfun, SRRpars, R0x = 1, SRrelx = 3L, hx = 1, SSBpR = 0, opt = 1L, plusgroup = 1L, spawn_time_frac = 0 )
logF |
log fishing mortality |
M_at_Age |
Vector of M-at-age |
Wt_at_Age |
Vector of weight-at-age |
Mat_at_Age |
Vector of maturity-at-age |
Fec_at_Age |
Vector of mature weight-at-age |
V_at_Age |
Vector of selectivity-at-age |
maxage |
Maximum age |
relRfun |
Optional. A function used to calculate reference points if |
SRRpars |
Optional. A named list of arguments for |
R0x |
R0 for this simulation. Set = 1 if SRrelx = 4 for per-recruit calculations |
SRrelx |
SRR type for this simulation. Use 4 for per-recruit calculations, i.e. constant recruitment. |
hx |
numeric. Steepness value for this simulation. Not used if SRrelx = 4. |
SSBpR |
numeric. Unfished spawners per recruit for this simulation. Not used if SRrelx = 4. |
opt |
Option. 1 = return -Yield, 2= return all MSY calcs |
plusgroup |
Integer. Default = 0 = no plus-group. Use 1 to include a plus-group |
spawn_time_frac |
Numeric. Fraction of the year when spawning occurs. Default = 0. |
See opt
Catches, CAA, CAL are summed. LFC and LFS are weighted averages. ML, Lc and Lbar are recalculated from summed CAL. All other observations are for fleet 1 (indicative)
multiData(MSElist, StockPars, p, mm, nf)
multiData(MSElist, StockPars, p, mm, nf)
MSElist |
A hierarchical list of data objects stock then fleet then MP |
StockPars |
A list of stock parameters |
p |
Integer the Stock number |
mm |
Integer the MP number |
nf |
The number of fleets |
T. Carruthers
Catches, CAA, CAL are summed. Indices, LFC and LFS are weighted averages. ML, Lc and Lbar are recalculated from summed CAL. All other observations are for fleet 1 and weighted average across stocks
multiDataS(MSElist, Real.Data.Map, np, mm, nf, realVB)
multiDataS(MSElist, Real.Data.Map, np, mm, nf, realVB)
MSElist |
A hierarchical list of data objects stock then fleet then MP |
Real.Data.Map |
Matrix describing which data are mapped across stocks |
np |
The number of stocks |
mm |
Integer the MP number |
nf |
The number of fleets |
realVB |
A matrix of real vulnerable biomass |
T. Carruthers
A basic comparison of runMSE output (MSE) and multiMSE (MMSE)
multidebug(MSEsingle, MSEmulti, p = 1, f = 1, MPno = 1, maxsims = 4)
multidebug(MSEsingle, MSEmulti, p = 1, f = 1, MPno = 1, maxsims = 4)
MSEsingle |
An object of class MSE arising from a run of runMSE(OM, ...) |
MSEmulti |
An object of class MMSE arising from a run of multiMSE(MOM, ...) |
p |
Integer. The stock number from the MSEmulti object (to be plotted) |
f |
Integer. The fleet number from the MSEmulti object (to be plotted) |
MPno |
Integer. The MP number from the MSEmulti and MSEsingle object (to be plotted) |
maxsims |
Integer. The maximum number of simulations to plot. |
T.Carruthers
Create of vector of values that correspond with a slot in a list of objects
NIL(listy, namey, lev1 = T)
NIL(listy, namey, lev1 = T)
listy |
A list of objects |
namey |
A character vector representing the list item's name |
lev1 |
Logical, should NIL default to the first level of the list? |
T. Carruthers
A preliminary plot for returning trade-offs plots and performance table for total yield, variability in yield, probability of overfishing and likelihood of biomass dropping below 50 per cent BMSY
NOAA_plot(MSEobj, nam = NA, type = NA, panel = T)
NOAA_plot(MSEobj, nam = NA, type = NA, panel = T)
MSEobj |
An object of class MSE |
nam |
Title of plot |
type |
Plots full range of data if NA. Plots a subset that meet thresholds if not NA. |
panel |
Should a two panel plot be made or should plots be made in sequence. |
A table of performance metrics.
T. Carruthers
'Obs'
An operating model component that controls the observation model
Name
The name of the observation model object. Single value. Character string.
Name
The name of the Observation error object. Single value. Character string.
Cobs
Observation error around the total catch. Observation error in the total catch is expressed as a coefficient of variation (CV). Cobs requires upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly observation error values for the catch data are then drawn from this distribution. For each time step the simulation model records the true catch, but the observed catch is generated by applying this yearly error term (plus any bias, if specified) to the true catch.
Cbiascv
Log-normally distributed coefficient of variation controlling the sampling bias in observed catch for each simulation. Bias occurs when catches are systematically skewed away from the true catch level (for example, due to underreporting of catch or undetected illegal catches). Cbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years.
CAA_nsamp
Number of catch-at-age observations collected per time step. For each time step a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Positive integers.
CAA_ESS
Effective sample size of catch-at-age observations collected per time step. For each time step a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. CAA_ESS should not exceed CAA_nsamp. If greater than 1, then this is the multinomial distribution sample size. If less than 1, this is the coefficient of variation for the logistic normal distribution (see help doucmentation for simCAA for details).
CAL_nsamp
Number of catch-at-length observations collected per time step. For each time step a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Positive integers.
CAL_ESS
Effective sample size. For each time step a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. CAL_ESS should not exceed CAL_nsamp. Positive integers.
Iobs
Observation error in the relative abundance index expressed as a coefficient of variation (CV). Iobs requires upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly observation error values for the index of abundance data are then drawn from this distribution. For each time step the simulation model records the true change in abundance, but the observed index is generated by applying this yearly error term (plus any bias, if specified) to the true relative change in abundance. Positive real numbers.
Btobs
Observation error in the absolute abundance expressed as a coefficient of variation (CV). Btobs requires upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly observation error values for the absolute abundance data are then drawn from this distribution. For each time step the simulation model records the true abundance, but the observed abundance is generated by applying this yearly error term (plus any bias, if specified) to the true abundance. Positive real numbers.
Btbiascv
Log-normally distributed coefficient (CV) controlling error in observations of the current stock biomass. Bias occurs when the observed index of abundance is is systematically higher or lower than the true relative abundance. Btbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
beta
A parameter controlling hyperstability/hyperdepletion in the measurement of abundance. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Values below 1 lead to hyperstability (the observed index decreases more slowly than the true abundance) and values above 1 lead to hyperdepletion (the observed index decreases more rapidly than true abundance). Positive real numbers.
LenMbiascv
Log-normal coefficient of variation for sampling bias in observed length at 50 percent maturity. LenMbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Mbiascv
Log-normal coefficient of variation for sampling bias in observed natural mortality rate. Mbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Kbiascv
Log-normal coefficient of variation for sampling bias in observed growth parameter K. Kbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
t0biascv
Log-normal coefficient of variation for sampling bias in observed t0. t0biascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Linfbiascv
Log-normal coefficient of variation for sampling bias in observed maximum length. Linfbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
LFCbiascv
Log-normal coefficient of variation for sampling bias in observed length at first capture. LFCbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
LFSbiascv
Log-normal coefficient of variation for sampling bias in length-at-full selection. LFSbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
FMSY_Mbiascv
Log-normal coefficient of variation for sampling bias in estimates of the ratio of the fishing mortality rate that gives the maximum sustainable yield relative to the assumed instantaneous natural mortality rate. FMSY/M. FMSY_Mbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
BMSY_B0biascv
Log-normal coefficient of variation for sampling bias in estimates of the BMSY relative to unfished biomass (BMSY/B0). BMSY_B0biascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Irefbiascv
Log-normal coefficient of variation for sampling bias in the observed relative index of abundance (Iref). Irefbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Brefbiascv
Log-normal coefficient of variation for sampling bias in the observed reference biomass (Bref). Brefbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Crefbiascv
Log-normal coefficient of variation for sampling bias in the observed reference catch (Cref). Crefbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Dbiascv
Log-normal coefficient of variation for sampling bias in the observed depletion level. Dbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Dobs
Log-normal coefficient of variation controlling error in observations of stock depletion among years. Observation error in the depletion expressed as a coefficient of variation (CV). Dobs requires the upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly observation error values for the depletion data are then drawn from this distribution. For each time step the simulation model records the true depletion, but the observed depletion is generated by applying this yearly error term (plus any bias, if specified) to the true depletion.
hbiascv
Log-normal coefficient of variation for sampling persistent bias in steepness. hbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Recbiascv
Log-normal coefficient of variation for sampling persistent bias in recent recruitment strength. Recbiascv requires the upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly bias values for the depletion data are then drawn from this distribution. Positive real numbers.
sigmaRbiascv
Log-normal coefficient of variation for sampling persistent bias in recruitment variability. sigmaRbiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years. Positive real numbers.
Eobs
Observation error around the total effort. Observation error in the total effort is expressed as a coefficient of variation (CV). Eobs requires upper and lower bounds of a uniform distribution, and for each simulation a CV is sampled from this distribution. Each CV is used to specify a log-normal error distribution with a mean of 1 and a standard deviation equal to the sampled CV. The yearly observation error values for the effort data are then drawn from this distribution. For each time step the simulation model records the true effort, but the observed effort is generated by applying this yearly error term (plus any bias, if specified) to the true effort.
Ebiascv
Log-normally distributed coefficient of variation controlling the sampling bias in observed effort for each simulation. Bias occurs when effort is systematically skewed away from the true effort level. Ebiascv is a single value specifying the standard deviation of a log-normal distribution with a mean of 1 and a standard deviation equal to the sampled CV. For each simulation a bias value is drawn from this distribution, and that bias is applied across all years.
Objects can be created by calls of the form
new('Obs')
Its questionable whether the hyperstability/hyperdepletion should be categorised as an observation model characteristic as it is most often driven by fleet dynamics (and therefore should be in the fleet object). Oh well its here and you might want to make it hyperstable beta < 1 or hyperdeplete beta > 1, only.
T. Carruthers and A. Hordyk
showClass('Obs')
showClass('Obs')
A data.frame with description of slots for class Obs
ObsDescription
ObsDescription
An object of class data.frame
with 30 rows and 2 columns.
'OM'
An object containing all the parameters needed to control the MSE which can be build from component Stock, Fleet, Obs, and Imp objects.
Almost all of these inputs are a vector of length 2 which describes the upper and lower bounds of a uniform distribution from which to sample the parameter.
Name
Name of the operating model
Agency
Name of the agency responsible for the management of the fishery. Character string
Region
Name of the general geographic region of the fishery. Character string
Sponsor
Name of the organization who sponsored the OM. Character string
Latitude
Latitude (decimal degrees). Negative values represent the South of the Equator. Numeric. Single value
Longitude
Longitude (decimal degrees). Negative values represent the West of the Prime Meridian. Numeric. Single value
nsim
The number of simulations
proyears
The number of projected years
interval
The assessment interval - how often would you like to update the management system?
pstar
The percentile of the sample of the management recommendation for each method
maxF
Maximum instantaneous fishing mortality rate that may be simulated for any given age class
reps
Number of samples of the management recommendation for each method. Note that when this is set to 1, the mean value of the data inputs is used.
cpars
A list of custom parameters. Time series are a matrix nsim rows by nyears columns. Single parameters are a vector nsim long. See validcpars()
seed
A random seed to ensure users can reproduce results exactly
Source
A reference to a website or article from which parameters were taken to define the operating model
Objects can be created by calls of the form
new('OM', Stock, Fleet, Obs, Imp)
.
T. Carruthers and A. Hordyk
A data.frame with description of slots for class OM
OMDescription
OMDescription
An object of class data.frame
with 15 rows and 2 columns.
Generate OM Documentation Report
OMdoc( OM = NULL, rmd.source = NULL, overwrite = FALSE, out.file = NULL, inc.plot = TRUE, render = TRUE, output = "html_document", openFile = TRUE, quiet = FALSE, dir = NULL, ... )
OMdoc( OM = NULL, rmd.source = NULL, overwrite = FALSE, out.file = NULL, inc.plot = TRUE, render = TRUE, output = "html_document", openFile = TRUE, quiet = FALSE, dir = NULL, ... )
OM |
An object of class 'OM' or the name of an OM xlsx file |
rmd.source |
Optional. Name of the source.rmd file corresponding to the 'OM'. Default assumption is that the file is '[email protected]' |
overwrite |
Logical. Should existing files be overwritten? |
out.file |
Optional. Character. Name of the output file. Default is the same as the text file. |
inc.plot |
Logical. Should the plots be included? |
render |
Logical. Should the document be compiled? May be useful to turn off if there are problems with compiling the Rmd file. |
output |
Character. Output file type. Default is 'html_document'. 'pdf_document' is available but may require additional software and have some formatting issues. |
openFile |
Logical. Should the compiled file be opened in web browser? |
quiet |
TRUE to suppress printing of the pandoc command line. |
dir |
Optional file path to read the xlsx and rmd files. Default is |
... |
Optional additional named arguments provided to |
Creates a Rmarkdown file and compiles a HTML report file in the working directory.
A. Hordyk
## Not run: OMinit('myOM', Stock='Herring', Fleet='Generic_Fleet', Obs='Generic_Obs', Imp='Perfect_Imp', overwrite=TRUE) myOM <- XL2OM('myOM.xlsx') OMdoc(myOM) ## End(Not run)
## Not run: OMinit('myOM', Stock='Herring', Fleet='Generic_Fleet', Obs='Generic_Obs', Imp='Perfect_Imp', overwrite=TRUE) myOM <- XL2OM('myOM.xlsx') OMdoc(myOM) ## End(Not run)
Copy example OM XL and OM Documentation
OMexample(dir = getwd())
OMexample(dir = getwd())
dir |
the file path to copy the files to. |
## Not run: OMexample() ## End(Not run)
## Not run: OMexample() ## End(Not run)
Generates an Excel spreadsheet and a source.rmd file in the current working directory for specifying and documenting a MSEtool Operating Model.
OMinit( name = NULL, ..., files = c("xlsx", "rmd"), dir = NULL, overwrite = FALSE )
OMinit( name = NULL, ..., files = c("xlsx", "rmd"), dir = NULL, overwrite = FALSE )
name |
The name of the Excel and source.rmd file to be created in the working directory (character). Use 'example' for a populated example OM XL and documentation file. |
... |
Optional MSEtool objects to use as templates: OM, Stock, Fleet, Obs, or Imp objects |
files |
What files should be created: 'xlsx', 'rmd', or c('xlsx', 'rmd') (default: both) to use as templates for the Operating Model. |
dir |
Optional file path to create the xlsx and rmd files. Default is |
overwrite |
Logical. Should files be overwritten if they already exist? |
name.xlsx and name.rmd files are created in the working directory.
A. Hordyk
## Not run: # Create an Excel OM template and rmd file called 'myOM.xlsx' and 'myOM.rmd': OMinit('myOM') # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # another OM as a template: OMinit('myOM', myOM) # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # the Stock object 'Herring' as a template: OMinit('myOM', Herring) # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # the Stock object 'Herring', and Obs object 'Generic_obs' as templates: OMinit('myOM', Herring, Generic_obs) ## End(Not run)
## Not run: # Create an Excel OM template and rmd file called 'myOM.xlsx' and 'myOM.rmd': OMinit('myOM') # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # another OM as a template: OMinit('myOM', myOM) # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # the Stock object 'Herring' as a template: OMinit('myOM', Herring) # Create an Excel OM template and text file called 'myOM.rmd' and 'myOM.rmd', using # the Stock object 'Herring', and Obs object 'Generic_obs' as templates: OMinit('myOM', Herring, Generic_obs) ## End(Not run)
Determine optimal number of cpus
optCPU(nsim = 96, thresh = 5, plot = TRUE, msg = TRUE, maxn = NULL)
optCPU(nsim = 96, thresh = 5, plot = TRUE, msg = TRUE, maxn = NULL)
nsim |
Numeric. Number of simulations. |
thresh |
Recommended n cpus is what percent of the fastest time? |
plot |
Logical. Show the plot? |
msg |
Logical. Should messages be printed to console? |
maxn |
Optional. Maximum number of cpus. Used for demo purposes |
A. Hordyk
## Not run: optCPU() ## End(Not run)
## Not run: optCPU() ## End(Not run)
Example objects of class Imp
Overages Perfect_Imp
Overages Perfect_Imp
An object of class Imp
of length 1.
An object of class Imp
of length 1.
avail("Imp")
avail("Imp")
Performance metric (PMs) methods for your management strategy evaluation.
P10(MSEobj = NULL, Ref = 0.1, Yrs = NULL) P50(MSEobj = NULL, Ref = 0.5, Yrs = NULL) P100(MSEobj = NULL, Ref = 1, Yrs = NULL) PNOF(MSEobj = NULL, Ref = 1, Yrs = NULL) LTY(MSEobj = NULL, Ref = 0.5, Yrs = -10) STY(MSEobj = NULL, Ref = 0.5, Yrs = 10) Yield(MSEobj = NULL, Ref = 1, Yrs = NULL) PGK(MSEobj = NULL, Ref = 1, Yrs = NULL) AAVY(MSEobj = NULL, Ref = 0.2, Yrs = NULL) AAVE(MSEobj = NULL, Ref = 0.2, Yrs = NULL)
P10(MSEobj = NULL, Ref = 0.1, Yrs = NULL) P50(MSEobj = NULL, Ref = 0.5, Yrs = NULL) P100(MSEobj = NULL, Ref = 1, Yrs = NULL) PNOF(MSEobj = NULL, Ref = 1, Yrs = NULL) LTY(MSEobj = NULL, Ref = 0.5, Yrs = -10) STY(MSEobj = NULL, Ref = 0.5, Yrs = 10) Yield(MSEobj = NULL, Ref = 1, Yrs = NULL) PGK(MSEobj = NULL, Ref = 1, Yrs = NULL) AAVY(MSEobj = NULL, Ref = 0.2, Yrs = NULL) AAVE(MSEobj = NULL, Ref = 0.2, Yrs = NULL)
MSEobj |
An object of class MSE |
Ref |
Reference point for calculating the performance metric. See details. |
Yrs |
Numeric vector of length 2 with year indices to summarize performance. If NULL, the performance is summarized over all projection years. |
Performance Metric definitions:
P10 |
Probability B > 0.1 BMSY |
P50 |
Probability B > 0.5 BMSY |
P100 |
Probability B > BMSY |
PNOF |
Probability F < FMSY |
LTY |
Probability Long-Term Yield > 0.5 Relative Yield |
STY |
Probability Short-Term Yield > 0.5 Relative Yield |
AAVY |
Probability AAVY < 0.2 (Average Annual Variability in Yield) |
AAVE |
Probability AAVE < 0.2 (Average Annual Variability in Effort) |
Yield |
Average Yield (relative to Reference Yield) |
Argument Ref
provides the ratio relative to the reference point for calculating
the performance metric. For biomass-based PMs (P10
, P50
, P100
), this is the fraction of
BMSY. For PNOF
, the fraction of FMSY. For Yield
(and LTY
/STY
), the fraction of the
Reference Yield. For AAVY
is it the maximum acceptable variability in yield (i.e, default
for AAVY
is Ref=0.2
)
The Yrs
argument defines the number of years to calculate the performance statistic over.
A value of NULL
, the default for AAVY
, AAVE
, P10
, P50
, P100
, and PNOF
, means that the
performance metric is calculated over all projection years. A numeric vector of length two is used
to specify the first and last year, e.g, if Yrs=c(1,10)
the performance statistic is calculated
over the first 10 projection years. A numeric vector of length one with positive or negative value
respectively can be used to specify the first x or last x years, e.g, Yrs=10
is first 10 years,
and Yrs=-10
is the last 10 years. See ChkYrs
for more details.
By default Long-Term Yield (LTY
) is the Yield in the last ten years of the projection period in the MSE,
and Short-Term Yield (STY
) is that in the first 10 years of the projection period.
An object of class PMobj
## Not run: myMSE <- runMSE() P10(myMSE) P50(myMSE) P100(myMSE) PNOF(myMSE) LTY(myMSE) STY(myMSE) AAVY(myMSE) AAVE(myMSE) Yield(myMSE) ## End(Not run)
## Not run: myMSE <- runMSE() P10(myMSE) P50(myMSE) P100(myMSE) PNOF(myMSE) LTY(myMSE) STY(myMSE) AAVY(myMSE) AAVE(myMSE) Yield(myMSE) ## End(Not run)
Creates plots of the Data object in the R console. Wrapper for summary(Data)
## S3 method for class 'Data' plot( x, wait = TRUE, i = 1, plots = "all", rmd = FALSE, head = "##", tplot = 25, ... )
## S3 method for class 'Data' plot( x, wait = TRUE, i = 1, plots = "all", rmd = FALSE, head = "##", tplot = 25, ... )
x |
An object of class Data |
wait |
Logical. Wait for key press before next plot? |
i |
iteration number for the Data object. |
plots |
Character. What plots to show? |
rmd |
Logical. Used in a rmd file? |
head |
Character. Heading for rmd file. Default is '##' (second level heading) |
tplot |
Integer. Number of plots per page. Default 25 |
... |
Not used |
Plot the projected biomass, fishing, mortality rate and yield for all stocks and MPs
## S3 method for class 'MMSE' plot( x = NULL, maxcol = 6, qcol = rgb(0.4, 0.8, 0.95), lcol = "dodgerblue4", quants = c(0.05, 0.25, 0.75, 0.95), curyr = 2018, addline = FALSE, ... )
## S3 method for class 'MMSE' plot( x = NULL, maxcol = 6, qcol = rgb(0.4, 0.8, 0.95), lcol = "dodgerblue4", quants = c(0.05, 0.25, 0.75, 0.95), curyr = 2018, addline = FALSE, ... )
x |
Object of class MMSE. A Multi-OM object created by |
maxcol |
Integer. The maximum number of columns (MPs) to be plotted in each plot |
qcol |
Character, color. The color of the inner percentile range |
lcol |
Character, color. The color of the outer percentile range. |
quants |
Numeric vector. The percentiles that are plotted (LB2,LB1,UB1,UB2). LB2 and UB2 are the outer percentiles, LB1 and UB1 are the inner percentiles. |
curyr |
Integer. The current year from which projections start. |
addline |
Logical. Should two individual simulations be added to the percentile plots? |
... |
Not used |
T.Carruthers
Plot the stocks, fleets, catch fractions and relationships in multi operating model object
## S4 method for signature 'MOM,missing' plot(x, silent = TRUE, maxsims = 6)
## S4 method for signature 'MOM,missing' plot(x, silent = TRUE, maxsims = 6)
x |
Object of class MOM. A Multi-OM object created by |
silent |
Logical. Do you wish to see print outs / warnings? |
maxsims |
Integer. What are the maximum number of individual simulations you wish to plot? |
T.Carruthers
Plot MSE object
## S3 method for class 'MSE' plot(x, ...)
## S3 method for class 'MSE' plot(x, ...)
x |
object of class MSE |
... |
other parameters passed to plot (currently ignored) |
Generate HTML reports with plots of operating model components ("Stock", "Fleet", "Obs", and "Imp"), the historical simulations ("Hist"), or the complete OM ("OM").
The individual component plots of objects of class Stock
and Fleet
can also be generated by
using the generic plot.pars
function. See Examples below.
## S3 method for class 'pars' plot( x, Object, Stock = NULL, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, html = FALSE, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Stock' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Fleet' plot( x, Stock = NULL, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Obs' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Imp' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Hist' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'OM' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... )
## S3 method for class 'pars' plot( x, Object, Stock = NULL, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, html = FALSE, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Stock' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Fleet' plot( x, Stock = NULL, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Obs' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Imp' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'Hist' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... ) ## S3 method for class 'OM' plot( x, nsamp = 3, nsim = 200, nyears = 50, proyears = 28, output_file = NULL, output_dir = getwd(), quiet = TRUE, tabs = TRUE, title = NULL, date = NULL, plotPars = NULL, open = TRUE, dev = FALSE, ... )
x |
An object of class |
Object |
An object of class |
Stock |
An object of class |
nsamp |
The number of random samples to show in the plot |
nsim |
The number of simulations (only used for objects not of class |
nyears |
The number of historical years (only used for objects not of class |
proyears |
The number of projection years (only used for objects not of class |
output_file |
Name of the output html file (without file extension) |
output_dir |
Output directory. Defaults to |
quiet |
An option to suppress printing of the pandoc command line |
tabs |
Include tabs in the HTML file? |
title |
Optional title for the markdown report |
date |
Optional date for the markdown report |
plotPars |
A named list with options for plots:
|
html |
Logical. Compile to a HTML report (TRUE) or print plots in R console (FALSE) |
open |
Logical. Open the html file? |
dev |
Logical. For development use only. |
... |
Not used |
## Not run: # Plot Stock Object: Stock <- MSEtool::Albacore plot(Stock) # Individual plots: plot("M", Stock) plot("Growth", Stock) plot("Maturity", Stock) plot("Recruitment", Stock) plot("Spatial", Stock) plot("Depletion", Stock) # Plot Fleet Object Fleet <- MSEtool::Generic_DecE plot(Fleet, Stock) # Individual plots: plot("Effort", Fleet, Stock) plot("Catchability", Fleet, Stock) plot("MPA", Fleet, Stock) plot("Selectivity", Fleet, Stock) # Plot Obs Object Obs <- MSEtool::Imprecise_Unbiased plot(Obs) # Plot Imp Object Imp <- MSEtool::Overages plot(Imp) # Plot Hist Object OM <- MSEtool::testOM Hist <- Simulate(OM) plot(Hist) # Plot OM Object plot(OM) ## End(Not run)
## Not run: # Plot Stock Object: Stock <- MSEtool::Albacore plot(Stock) # Individual plots: plot("M", Stock) plot("Growth", Stock) plot("Maturity", Stock) plot("Recruitment", Stock) plot("Spatial", Stock) plot("Depletion", Stock) # Plot Fleet Object Fleet <- MSEtool::Generic_DecE plot(Fleet, Stock) # Individual plots: plot("Effort", Fleet, Stock) plot("Catchability", Fleet, Stock) plot("MPA", Fleet, Stock) plot("Selectivity", Fleet, Stock) # Plot Obs Object Obs <- MSEtool::Imprecise_Unbiased plot(Obs) # Plot Imp Object Imp <- MSEtool::Overages plot(Imp) # Plot Hist Object OM <- MSEtool::testOM Hist <- Simulate(OM) plot(Hist) # Plot OM Object plot(OM) ## End(Not run)
This function prints out the available plotting functions for objects of class MSE or Data
plotFun(class = c("MSE", "Data"), msg = TRUE)
plotFun(class = c("MSE", "Data"), msg = TRUE)
class |
Character string. Prints out the plotting functions for objects of this class. |
msg |
Logical. Should the functions be printed to screen? |
Basically the function looks for any functions in the MSEtool that
have the word plot
in them. There is a chance that some plotting
functions are missed. Let us know if you find any and we will add them.
A. Hordyk
A basic SSB plot for debugging runMSE output
plotmulti(MSEmulti, maxsim = 8)
plotmulti(MSEmulti, maxsim = 8)
MSEmulti |
An object of class MMSE arising from a run of multiMSE(MOM, ...) |
maxsim |
Integer. The number of simulations to plot |
T.Carruthers
As title.
plotOFL(Data, xlims = NA, perc = 0.5)
plotOFL(Data, xlims = NA, perc = 0.5)
Data |
An object of class Data that has been run though TAC() |
xlims |
x axis limits |
perc |
The percentile of the OFL distribution to be plotted |
A table of performance metrics.
T. Carruthers
A fairly tidy time-series quantile plot
plotquant( x, p = c(0.05, 0.25, 0.75, 0.95), yrs, qcol, lcol, addline = T, ablines = NA )
plotquant( x, p = c(0.05, 0.25, 0.75, 0.95), yrs, qcol, lcol, addline = T, ablines = NA )
x |
Matrix. A time series quantity |
p |
Numeric vector. The percentiles that are plotted (LB2,LB1,UB1,UB2). LB2 and UB2 are the outer percentiles, LB1 and UB1 are the inner percentiles. |
yrs |
Numeric vector. The years corresponding to the indexing of x |
qcol |
Character, color. The color of the inner percentile range |
lcol |
Character, color. The color of the outer percentile range. |
addline |
Logical. Should two individual simulations be added to the percentile plots? |
ablines |
Numeric vector. Horizontal lines to be added to the plot. |
T.Carruthers
Plot a relationship between stocks
plotRel(Stocks, Rel, Relno, Snams, leg = F, extras = 0)
plotRel(Stocks, Rel, Relno, Snams, leg = F, extras = 0)
Stocks |
A list of stock objects (MOM@Stocks) |
Rel |
A list of inter-stock MICE relationships (MOM@Rel) |
Relno |
Integer. The relationship you wish to plot |
Snams |
A vector of stock names |
leg |
Logical. Do you want to plot a legend? |
extras |
Integer. The number of blank plots to create at the end. |
T.Carruthers
Create a table of Performance Limits and Performance Objectives
PMLimit( MSE, ..., Prob = NULL, Labels = NULL, FeaseMPs = NULL, out.file = NULL, output_format = "html_document", openFile = TRUE, quiet = TRUE, dir = NULL, RMDfile = NULL, font_size = 14, auto_width = FALSE, enableSearch = TRUE, PMlist = NULL, build = TRUE ) PMObj( MSE, ..., Labels = NULL, out.file = NULL, output_format = "html_document", openFile = TRUE, quiet = TRUE, dir = NULL, RMDfile = NULL, font_size = 14, use.colors = TRUE, cols = NULL, show.legend = TRUE, auto_width = FALSE, enableSearch = TRUE, PMlist = NULL, build = TRUE, cex.tex = 0.75, inc.title = TRUE, title = "Legend" )
PMLimit( MSE, ..., Prob = NULL, Labels = NULL, FeaseMPs = NULL, out.file = NULL, output_format = "html_document", openFile = TRUE, quiet = TRUE, dir = NULL, RMDfile = NULL, font_size = 14, auto_width = FALSE, enableSearch = TRUE, PMlist = NULL, build = TRUE ) PMObj( MSE, ..., Labels = NULL, out.file = NULL, output_format = "html_document", openFile = TRUE, quiet = TRUE, dir = NULL, RMDfile = NULL, font_size = 14, use.colors = TRUE, cols = NULL, show.legend = TRUE, auto_width = FALSE, enableSearch = TRUE, PMlist = NULL, build = TRUE, cex.tex = 0.75, inc.title = TRUE, title = "Legend" )
MSE |
An object of class 'MSE' |
... |
PM objects to be used as performance limits. Characters (i.e names of PM objects) |
Prob |
Minimum probability threshold |
Labels |
Optional named list specifying new labels for MPs. For example: |
FeaseMPs |
Optional. Character vector of MP names that are considered feasible. e.g. the output from |
out.file |
Name of the output file. If none provided, output file will be named 'PerfLimTable' |
output_format |
Output file format. Currently only 'html_document' is supported |
openFile |
Logical. Should the file be opened in browser? |
quiet |
Logical. An option to suppress printing of the pandoc command line. |
dir |
Optional. Directory for output file. Default is working directory. |
RMDfile |
Optional. RMD template file |
font_size |
Numeric. Font size for text in the table |
auto_width |
Logical. Should table be width be automatic? |
enableSearch |
Currently disabled. Logical. Should search be enabled in the html table? |
PMlist |
Optional. List of PM names. |
build |
Logical. Build the html table? |
use.colors |
Logical. Color scale the probability text? |
cols |
Optional character vector of colors for probability text |
show.legend |
Logical. Show the legend?? |
cex.tex |
Size of legend text |
inc.title |
Logical. Include title for legend? |
title |
Title for the legend |
PMLimit
invisibly returns names of MPs that pass all performance limits
PMLimit()
: Create a table of Performance Limits
PMObj()
: Create a table of Performance Objectives.
A. Hordyk
## Not run: MSE <- runMSE() PMLimit(MSE, "P50", "PNOF", Prob=0.9) PMObj(MSE, "P100", "LTY") ## End(Not run)
## Not run: MSE <- runMSE() PMLimit(MSE, "P50", "PNOF", Prob=0.9) PMObj(MSE, "P100", "LTY") ## End(Not run)
Used internally
Name
Name of the Performance Metric. Character
Caption
A caption to be used in plots. Character, call, or function.
Stat
Statistic of interest for the PM. Dimensions: nsim, nMP, yrs. Array
Ref
Reference value to calculate probability for statistic. Numeric.
Prob
Probability (mean over years) Dimensions: nsim by MP. Matrix, numeric or data.frame
Mean
Mean probability (mean over years and simulations). Numeric. Length nMPs
MPs
Name of MPs. Single value. Character string
Objects can be created by calls of the form
new('PMobj')
A. Hordyk
A shorter version of the plot method for MSEs that just shows the projected trends in stock status and over exploitation
Pplot(MSEobj, nam = NA, maxMP = 10, MPs = NA, maxsims = 20)
Pplot(MSEobj, nam = NA, maxMP = 10, MPs = NA, maxsims = 20)
MSEobj |
An object of class MSE |
nam |
Title of plot |
maxMP |
The maximum number of MPs to plot (defaults to the first 10) |
MPs |
A character vector of MPs to plot |
maxsims |
Integer, the maximum number of simulations to plot |
T. Carruthers
A projection by projection plot of F/FMSY, B/BMSY, B/B0, and yield
Pplot2( MSEobj, YVar = c("F_FMSY", "SSB_SSBMSY"), MPs = NA, sims = NULL, traj = c("all", "quant", "both"), quants = c(0.1, 0.9), incquant = TRUE, quantcol = "lightgray", RefYield = c("lto", "curr"), LastYr = TRUE, ref.lines = c(0.5, 1, 1.5), maxMP = 6, alpha = 60, cex.axis = 1, cex.lab = 1, YLab = NULL, incMP = TRUE, MPcex = 1, MPcol = "black", incLeg = TRUE, cex.leg = 1.5, legPos = "topleft", yline = NULL, xline = NULL, parOR = FALSE, xaxis = TRUE, yaxis = TRUE, oneIt = TRUE, ... )
Pplot2( MSEobj, YVar = c("F_FMSY", "SSB_SSBMSY"), MPs = NA, sims = NULL, traj = c("all", "quant", "both"), quants = c(0.1, 0.9), incquant = TRUE, quantcol = "lightgray", RefYield = c("lto", "curr"), LastYr = TRUE, ref.lines = c(0.5, 1, 1.5), maxMP = 6, alpha = 60, cex.axis = 1, cex.lab = 1, YLab = NULL, incMP = TRUE, MPcex = 1, MPcol = "black", incLeg = TRUE, cex.leg = 1.5, legPos = "topleft", yline = NULL, xline = NULL, parOR = FALSE, xaxis = TRUE, yaxis = TRUE, oneIt = TRUE, ... )
MSEobj |
An object of class MSE |
YVar |
What to plot on the y-axis? Options are: |
MPs |
Optional subset by MP |
sims |
Optional subset by simulation |
traj |
Plot all projections ( |
quants |
Numeric vector of length 2 specifying the quantiles (e.g., 10th and 90th. Median is always included) |
incquant |
Logical. Include the quantiles or only plot median? |
quantcol |
Colour of the quantile polygon |
RefYield |
Should yield be relative to long-term optimum ( |
LastYr |
Logical. Include the last historical year in the yield projections? |
ref.lines |
Numeric vector of y-values for horizontal reference lines. Set to NULL to remove lines. |
maxMP |
Maximum number of MPs to plot |
alpha |
Alpha for transparency of lines |
cex.axis |
Size of axis text |
cex.lab |
Size of axis label |
YLab |
Optional label for y-axis |
incMP |
Logical. Include name of MP? |
MPcex |
Size of MP label |
MPcol |
Optional character vector of colors for MP labels |
incLeg |
Logical. Include a legend? |
cex.leg |
Size of legend text |
legPos |
Legend position |
yline |
Optional horizontal lines |
xline |
Optional vertical lines |
parOR |
Logical to over-ride the par parameters |
xaxis |
Logical. Should x-axis labels be displayed? |
yaxis |
Logical. Should y-axis labels be displayed? |
oneIt |
Logical. Should one iteration be plotted on the quantile plot? |
... |
Additional arguments to be passed to plotting functions |
T. Carruthers & A.Hordyk
A NAFO / ICCAT / SSB style MSE performance whisker plot
PWhisker(MSEobj)
PWhisker(MSEobj)
MSEobj |
An object of class MSE |
A box plot of performance
T. Carruthers
Plots quantiles and simulations for a stochastic time-series variable
quantile_plot( datmat, xvals, p = c(0.05, 0.25, 0.5, 0.75, 0.95), tcol, ylim, sims = 1:3, refline = NA, dox = F, doy = F )
quantile_plot( datmat, xvals, p = c(0.05, 0.25, 0.5, 0.75, 0.95), tcol, ylim, sims = 1:3, refline = NA, dox = F, doy = F )
datmat |
Matrix of real values with dimensions (simulation, year) (e.g. SB/SBMSY) |
xvals |
Vector of numerical values of length ncol(datmat). The xaxis labels for datmat. |
p |
Vector of quantiles five positions long. Defaults to c(0.05,0.25,0.5,0.75,0.95) so the 90% and 50% intervals with the median plotted in white. |
tcol |
Color of shaded regions (transparent) |
ylim |
Numerical vector of length 2, lower and upper limits for the yaxis |
sims |
Vector of positive integers, the individual simulations to plot |
refline |
Positive real number, a reference line to plot (on scale of y axis) |
dox |
Logical, should the x axis labels be plotted. |
doy |
Logical, should the y axis labels be plotted. |
T. Carruthers
What MPs do not return NAs from the real data
RealFease(Data = NULL)
RealFease(Data = NULL)
Data |
An object of class 'Data'. Optional. If Data object is included, the returned MPs are both feasible (in terms of management) and possible (sufficient data to run MP) |
a vector of MP names that calculate without errors for the specific data.
T. Carruthers
'Rec'
An object for storing the MP recommendations
TAC
A numeric value with the TAC recommendation
Effort
A numeric value with the effort recommendation as a fraction of current (nyear) fishing effort
Spatial
A boolean vector of length 'nareas' specifying if area is open (1) or closed (0) to fishing
Allocate
A boolean value describing if effort should be re-allocated from close to open areas
LR5
smallest length at 5 per cent retention - in absolute units - i.e same units as Linf and L50
LFR
smallest length at full retention - in absolute units - i.e same units as Linf and L50
HS
upper harvest slot (no retention above this) - in absolute units - i.e same units as Linf and L50
Rmaxlen
retention of the largest size class - fraction between 0 and 1
L5
smallest length at 5 per cent selection - in absolute units - i.e same units as Linf and L50
LFS
smallest length at full selection - in absolute units - i.e same units as Linf and L50
Vmaxlen
selection of the largest size class - fraction between 0 and 1
Fdisc
fraction of discarded fish that die - fraction between 0 and 1
DR
Discard rate - the fraction of caught fish that are discarded
Misc
An empty list that can be used to store information and pass on to MPs in future
Objects can be created by calls of the form
new('Rec')
A. Hordyk
A function that replaces a Stock, Fleet, Obs, or Imp object from an OM with one from another object.
Replace( OM, from, Sub = c("Stock", "Fleet", "Obs", "Imp"), Name = NULL, silent = FALSE )
Replace( OM, from, Sub = c("Stock", "Fleet", "Obs", "Imp"), Name = NULL, silent = FALSE )
OM |
An operating model object (class OM) which will be updated with a sub-model from another OM |
from |
An object of class |
Sub |
A character string specifying what object type to replace (only used if |
Name |
Character. Name for the new OM object ( |
silent |
Should messages be printed? |
An object of class OM
A. Hordyk
# Replace Stock OM <- MSEtool::testOM OM2 <- Replace(OM, Blue_shark) # Replace Fleet OM <- MSEtool::testOM OM2 <- Replace(OM, Generic_DecE) # Replace Fleet from another OM # OM1 <- new("OM", Albacore, Generic_DecE, Perfect_Info, Overages) # OM2 <- new("OM", Blue_shark, Generic_IncE, Generic_Obs, Perfect_Imp) # OM1a <- Replace(OM1, OM2, "Fleet")
# Replace Stock OM <- MSEtool::testOM OM2 <- Replace(OM, Blue_shark) # Replace Fleet OM <- MSEtool::testOM OM2 <- Replace(OM, Generic_DecE) # Replace Fleet from another OM # OM1 <- new("OM", Albacore, Generic_DecE, Perfect_Info, Overages) # OM2 <- new("OM", Blue_shark, Generic_IncE, Generic_Obs, Perfect_Imp) # OM1a <- Replace(OM1, OM2, "Fleet")
Replicates position 1 data to multiple positions for sensitivity testing etc
replic8(Data, nrep)
replic8(Data, nrep)
Data |
A data-limited methods data object |
nrep |
The number of positions to expand the DLM object to |
T. Carruthers
A HTML Data Report is generated and opened in a web browser
Report( Data = NULL, md = NULL, name = "Data-Report", title = "Data Documentation", author = "Author Name", date = Sys.Date(), output_format = c("html_document", "pdf_document"), open = TRUE, quiet = TRUE, dir = NULL, overwrite = FALSE )
Report( Data = NULL, md = NULL, name = "Data-Report", title = "Data Documentation", author = "Author Name", date = Sys.Date(), output_format = c("html_document", "pdf_document"), open = TRUE, quiet = TRUE, dir = NULL, overwrite = FALSE )
Data |
Either an object of class |
md |
Full file path to a valid text file documenting the Data |
name |
Optional. Name of the output file |
title |
Title for the Report. Title in the markdown file will override this value |
author |
Author of the Report. Author in the markdown file will override this value |
date |
Date of the Report. Date in the markdown file will override this value |
output_format |
Output file format: |
open |
Logical. Open the compiled report? |
quiet |
Logical.An option to suppress printing of the pandoc command line. |
dir |
Optional. Directory to save the file. Defaults to |
overwrite |
Logical. Overwrite an existing file with the same name? |
Nothing. A Data Report is generated and saved in dir
A. Hordyk
## Not run: DataInit('Example') # generate example Data Input and Documentation files Report('Example', 'Example.md') ## End(Not run)
## Not run: DataInit('Example') # generate example Data Input and Documentation files Report('Example', 'Example.md') ## End(Not run)
Dataframe with required data slots for built-in MPs
ReqData
ReqData
An object of class data.frame
with 123 rows and 2 columns.
A function that finds all the MPs and searches the function text for slots in the Data object
Required(funcs = NA, noCV = FALSE)
Required(funcs = NA, noCV = FALSE)
funcs |
A character vector of management procedures |
noCV |
Logical. Should the CV slots be left out? |
A matrix of MPs and their required data in terms of slotnames('Data')
,
and broad Data classes for each MP
T. Carruthers
Dedicated functions for MSE run and reporting for COSEWIC (Committee on the Status of Endangered Wildlife in Canada). MSE projects for 6x maximum age using NFref, FMSYref and curE management procedures.
runCOSEWIC(OM, ...) COSEWIC_Pplot( MSEobj, syear = 2017, qcol = "#FFCB62", quants = c(0.05, 0.25, 0.5, 0.75, 0.95) ) COSEWIC_Dplot( MSEobj, syear = 2017, qcol = "#79F48D", quants = c(0.05, 0.25, 0.5, 0.75, 0.95), nGT = 3 ) COSEWIC_Blow( MSEobj, syear = 2017, qcol = rgb(0.4, 0.8, 0.95), quants = c(0.05, 0.25, 0.5, 0.75, 0.95), nGT = 3 ) COSEWIC_Hplot( MSEobj, syear = 2017, qcol = rgb(0.4, 0.8, 0.95), quants = c(0.05, 0.25, 0.5, 0.75, 0.95) ) COSEWIC_report( MSEobj, output_file = NA, author = "Author not specified", title = NA ) COSEWIC_tab(MSEobj, rnd = 0, GTs = c(3, 6), syear = 2017, nGT = 3) COSEWIC_tab_formatted( Ptab1, thresh = c(20, 40, 40, 20, 40, 40, 40, 30, 5), ret_thresh = F )
runCOSEWIC(OM, ...) COSEWIC_Pplot( MSEobj, syear = 2017, qcol = "#FFCB62", quants = c(0.05, 0.25, 0.5, 0.75, 0.95) ) COSEWIC_Dplot( MSEobj, syear = 2017, qcol = "#79F48D", quants = c(0.05, 0.25, 0.5, 0.75, 0.95), nGT = 3 ) COSEWIC_Blow( MSEobj, syear = 2017, qcol = rgb(0.4, 0.8, 0.95), quants = c(0.05, 0.25, 0.5, 0.75, 0.95), nGT = 3 ) COSEWIC_Hplot( MSEobj, syear = 2017, qcol = rgb(0.4, 0.8, 0.95), quants = c(0.05, 0.25, 0.5, 0.75, 0.95) ) COSEWIC_report( MSEobj, output_file = NA, author = "Author not specified", title = NA ) COSEWIC_tab(MSEobj, rnd = 0, GTs = c(3, 6), syear = 2017, nGT = 3) COSEWIC_tab_formatted( Ptab1, thresh = c(20, 40, 40, 20, 40, 40, 40, 30, 5), ret_thresh = F )
OM |
An operating model object of class OM |
... |
Other named arguments to pass to |
MSEobj |
An object of class MSE with |
syear |
Current year, starting year for projections (e.g. 2017) |
qcol |
Color of shaded regions (bars, quantiles) |
quants |
Quantiles of the shaded regions (vector 5 long e.g. 0.1, 0.2, 0.5, 0.8, 0.9) |
nGT |
Number of generation times. For |
output_file |
The directory and filename you wish to use for the report e.g. "C:/temp/myMSEreport.html" |
author |
The person who made this report |
title |
The title of the report |
rnd |
The number of significant figures for rounding. |
GTs |
A vector of mean generation times to evaluate performance metrics over |
Ptab1 |
A COSEWIC performance table made by |
thresh |
A vector of thresholds for each column Health, Yield and Reb are 'greater than threshold' conditions |
ret_thresh |
Logical: if true just the threshold levels are returned |
runCOSEWIC()
: Calls runMSE
with number of projection years for 6x maximum age and
uses NFref
, FMSYref
, and curE
MPs.
COSEWIC_Pplot()
: Projection plots of spawning stock biomass under three scenarios:
no catch, FMSY fishing and status quo fishing effort.
COSEWIC_Dplot()
: Depletion plots evaluate whether significant declines have
occurred over three generation times in both historical and projection years.
COSEWIC_Blow()
: Plots that evaluate the likelihood of declining below Blow
,
by default, biomass that takes 3 generation times to reach half BMSY with zero fishing
COSEWIC_Hplot()
: Plots of historical spawning stock relative to unfished and MSY levels.
COSEWIC_report()
: Create a standard DFO COSEWIC report (provides performance plots
to inform COSEWIC processes in Canadian fish stocks).
COSEWIC_tab()
: Creates a standard COSEWIC performance table:
P_Cr
is the probability of being in the critical zone (less than 20% depletion)
P_Ct
is the probability of being in the cautious zone (between 20% and 40% depletion)
P_H
is the probability of being in the healthy zone (above 40% depletion)
P_Cr_MSY
is the probability of being in the critical zone (less than 40% BMSY)
P_Ct_MSY
is the probability of being in the cautious zone (between 40% and 80% BMSY)
P_H_MSY
is the probability of being in the healthy zone (above 80% BMSY)
Caut
is the probability of being in the cautious zone in the last 10 projected years
P_A1
is the probability of being designated threatened according to COSEWIC Indicator A1 (Spawning biomass less than 70% that three generation times previously)
P_A2
is the probability of being designated threatened according to COSEWIC Indicator A2 (Spawning biomass less than 50% that three generation times previously)
Blow
is the probability that the stock is below the biomass for which it takes 3 generation times to reach 50% BMSY with zero fishing
COSEWIC_tab_formatted()
: A formatted version of the standard COSEWIC performance plot,
color coded by thresholds.
T. Carruthers
https://cosewic.ca/index.php/en/
Function runs a MP (or MPs) of class 'Input' and returns a list: input control recommendation(s) in element 1 and Data object in element 2.
runInMP(Data, MPs = NA, reps = 100)
runInMP(Data, MPs = NA, reps = 100)
Data |
A object of class Data |
MPs |
A vector of MPs of class 'Input' |
reps |
Number of stochastic repetitions - often not used in input control MPs. |
A. Hordyk
Run a Management Procedure
runMP(Data, MPs = NA, reps = 100, perc = 0.5, chkMPs = FALSE, silent = FALSE)
runMP(Data, MPs = NA, reps = 100, perc = 0.5, chkMPs = FALSE, silent = FALSE)
Data |
A MSEtool Data object |
MPs |
The name of the MP to run (or a vector or names) |
reps |
Number of repetitions |
perc |
Percentile to summarize reps (default is median) |
chkMPs |
Logical. Should the MPs be checked before attempting to run them? |
silent |
Logical. Should messages by suppressed? |
invisibly returns the Data object
MMSE@PPD
Select DataList for an MP from MMSE@PPD
select_MP(PPD, MP = 1)
select_MP(PPD, MP = 1)
PPD |
|
MP |
Numeric value indicating the MP to return DataList |
A nested list Data
objects (nstock
by nfleet
)
A function that determines the inputs for a given data-limited method of class Output and then analyses the sensitivity of TAC estimates to marginal differences in each input. The range used for sensitivity is based on the user-specified CV for that input (e.g. CV_Mort, Mort)
Sense(Data, MP, nsense = 6, reps = 100, perc = c(0.05, 0.5, 0.95), ploty = T)
Sense(Data, MP, nsense = 6, reps = 100, perc = c(0.05, 0.5, 0.95), ploty = T)
Data |
A data-limited methods data object |
MP |
A character string representing an MP applied in calculating the TAC recommendations in the DLM object |
nsense |
The number of points over which to calculate the TAC (resolution) |
reps |
The number of samples of the quota taken for the calculation of the TAC |
perc |
The percentile of the sample TAC |
ploty |
A logical switch, (T/F, should a plot be drawn?) |
T. Carruthers
## Not run: Data <- Sense(MSEtool::Cobia, "AvC") ## End(Not run)
## Not run: Data <- Sense(MSEtool::Cobia, "AvC") ## End(Not run)
Sets up parallel processing using the snowfall package
setup(cpus = NULL, logical = FALSE, ...)
setup(cpus = NULL, logical = FALSE, ...)
cpus |
the number of CPUs to use for parallel processing. If left empty
all physical cores will be used, unless |
logical |
Use the logical cores as well? Using the virtual cores may
not lead to any significant decrease in run time.
You can test the optimal number of cores using |
... |
other arguments passed to 'snowfall::sfInit' |
## Not run: setup() # set-up the physical processors setup(6) # set-up 6 processors setup(logical=TRUE) # set-up physical and logical cores ## End(Not run)
## Not run: setup() # set-up the physical processors setup(6) # set-up 6 processors setup(logical=TRUE) # set-up physical and logical cores ## End(Not run)
Briefly prints a couple of lines from str to avoid swamping the console with the contents of very large objects.
## S4 method for signature 'Data' show(object) ## S4 method for signature 'OM' show(object) ## S4 method for signature 'Hist' show(object) ## S4 method for signature 'MSE' show(object) ## S4 method for signature 'MMSE' show(object)
## S4 method for signature 'Data' show(object) ## S4 method for signature 'OM' show(object) ## S4 method for signature 'Hist' show(object) ## S4 method for signature 'MSE' show(object) ## S4 method for signature 'MMSE' show(object)
object |
S4 object from MSEtool |
Show the output of a PM
## S4 method for signature 'PMobj' show(object)
## S4 method for signature 'PMobj' show(object)
object |
object of class MSE |
Show the output of a single MP recommendation
## S4 method for signature 'Rec' show(object)
## S4 method for signature 'Rec' show(object)
object |
object of class Rec |
Create of vector of values that correspond with a slot in a list of objects
SIL(listy, sloty)
SIL(listy, sloty)
listy |
A list of objects |
sloty |
A character vector representing the slot name |
T. Carruthers
CAA generated with either a multinomial or logistic normal observation model from retained catch-at-age array
simCAA(nsim, yrs, n_age, Cret, CAA_ESS, CAA_nsamp)
simCAA(nsim, yrs, n_age, Cret, CAA_ESS, CAA_nsamp)
nsim |
Number of simulations |
yrs |
Number of years |
n_age |
Number of age classes |
Cret |
Retained Catch at age in numbers - array(sim, years, maxage+1) |
CAA_ESS |
CAA effective sample size. If greater than 1, then this is the multinomial distribution sample size. If less than 1, this is the coefficient of variation for the logistic normal distribution (see details). |
CAA_nsamp |
CAA sample size |
The logistic normal generates the catch-at-age sample by first sampling once from a multivariate normal distribution with the mean vector equal to the logarithm of the proportions-at-age and the diagonal of the covariance matrix is the square of the product of the CV and the log proportions (all off-diagonals are zero). The sampled vector is then converted to proportions with the softmax function and expanded to numbers (CAA_nsamp). This method allows for simulating fractional values in the catch-at-age matrix.
CAA array
Simulate CAL and calculate length-at-first capture (LFC), mean length (ML), modal length (Lc), and mean length over modal length (Lbar)
simCAL( nsim, nyears, maxage, CAL_ESS, CAL_nsamp, nCALbins, CAL_binsmid, CAL_bins, vn, retL, Linfarray, Karray, t0array, LenCV )
simCAL( nsim, nyears, maxage, CAL_ESS, CAL_nsamp, nCALbins, CAL_binsmid, CAL_bins, vn, retL, Linfarray, Karray, t0array, LenCV )
nsim |
Number of simulations |
nyears |
Number of years |
maxage |
Maximum age |
CAL_ESS |
CAA effective sample size |
CAL_nsamp |
CAA sample size |
nCALbins |
number of CAL bins |
CAL_binsmid |
mid-points of CAL bins |
CAL_bins |
Boundary of CAL bins |
vn |
Vulnerable numbers-at-age |
retL |
Retention at length curve |
Linfarray |
Array of Linf values by simulation and year |
Karray |
Array of K values by simulation and year |
t0array |
Array of t0 values by simulation and year |
LenCV |
CV of length-at-age#' |
named list with CAL array and LFC, ML, & Lc vectors
A wrapper function for makemov used to generate movement matrices for the operating model. Calculates a movement matrix from user-specified unfished stock biomass fraction in each area and probability of staying in the area in each time step.
simmov( OM, dist = c(0.1, 0.2, 0.3, 0.4), prob = 0.5, distE = 0.1, probE = 0.1, prob2 = NA, figure = TRUE ) plot_mov(mov, age = 1, type = c("matrix", "all"), year = 1, qval = 0.9)
simmov( OM, dist = c(0.1, 0.2, 0.3, 0.4), prob = 0.5, distE = 0.1, probE = 0.1, prob2 = NA, figure = TRUE ) plot_mov(mov, age = 1, type = c("matrix", "all"), year = 1, qval = 0.9)
OM |
Operating model, an object of class OM. |
dist |
A vector of fractions of unfished stock in each area. The length of this vector will determine the
number of areas ( |
prob |
Mean probability of staying across all areas (single value) or a vector of the probability of individuals staying in each area (same length as dist). |
distE |
Logit (normal) St.Dev error for sampling stock fractions from the fracs vector |
probE |
Logit (normal) St.Dev error for sampling desired probability of staying either by area (prob is same length as dist) or the mean probability of staying (prob is a single number). |
prob2 |
Optional vector as long as prob and dist. Upper bounds on uniform sampling of probability of staying, lower bound is prob. |
figure |
Logical to indicate if the movement matrix will be plotted (mean values and range
across |
mov |
A four-dimensional array of dimension |
age |
An age from 0 to maxage for the movement-at-age matrix figure when |
type |
Whether to plot a movement matrix for a single age ( |
year |
If |
qval |
The quantile to plot or report the range of values among simulations. |
The operating model OM
with movement parameters in slot cpars
.
The mov
array is of dimension nsim
, maxage
, nareas
, nareas
.
simmov()
: Estimation function for creating movement matrix.
plot_mov()
: Plotting function.
Array mov
is age-specific, but currently the movement generated by simmov
is
independent of age.
T. Carruthers and Q. Huynh
## Not run: movOM_5areas <- simmov(testOM, dist = c(0.01,0.1,0.2,0.3,0.39), prob = c(0.1,0.6,0.6,0.7,0.9)) movOM_5areas@cpars$mov[1, 1, , ] # sim 1, age 1, movement from areas in column i to areas in row j plot_mov(movOM_5areas@cpars$mov) plot_mov(movOM_5areas@cpars$mov, type = "all") ## End(Not run)
## Not run: movOM_5areas <- simmov(testOM, dist = c(0.01,0.1,0.2,0.3,0.39), prob = c(0.1,0.6,0.6,0.7,0.9)) movOM_5areas@cpars$mov[1, 1, , ] # sim 1, age 1, movement from areas in column i to areas in row j plot_mov(movOM_5areas@cpars$mov) plot_mov(movOM_5areas@cpars$mov, type = "all") ## End(Not run)
A wrapper function for makemov2 used to generate movement matrices for the operating model. Calculates a movement matrix from user-specified relative movement to other areas and probability of staying in the area in each time step.
simmov2( OM, dist = c(0.05, 0.6, 0.35), distE = 0.01, frac_other = matrix(c(NA, 2, 1, 3, NA, 1, 1, 4, NA), nrow = 3, byrow = T), frac_otherE = 0.01, prob = 0.8, probE = 1, figure = TRUE )
simmov2( OM, dist = c(0.05, 0.6, 0.35), distE = 0.01, frac_other = matrix(c(NA, 2, 1, 3, NA, 1, 1, 4, NA), nrow = 3, byrow = T), frac_otherE = 0.01, prob = 0.8, probE = 1, figure = TRUE )
OM |
Operating model, an object of class OM. |
dist |
A vector of fractions of unfished stock in each area. The length of this vector will determine the
number of areas ( |
distE |
Logit (normal) St.Dev error for sampling desired fraction in each area |
frac_other |
A matrix (nareas rows from, nareas columns to) of relative fractions moving to other areas (the positive diagonal (staying) is unspecified). |
frac_otherE |
Logit (normal) St.Dev error for sampling desired fraction moving to other areas. |
prob |
the mean probability of staying in the same area among all areas |
probE |
Logit (normal) St.Dev error for sampling desired probability of staying in each area |
figure |
Logical to indicate if the movement matrix will be plotted (mean values and range
across |
The operating model OM
with movement parameters in slot cpars
.
The mov
array is of dimension nsim
, maxage
, nareas
, nareas
.
simmov2()
: Estimation function for creating movement matrix.
Array mov
is age-specific, but currently the movement generated by simmov
is
independent of age.
T. Carruthers and Q. Huynh
## Not run: movOM_3areas <- simmov2(testOM, frac_other = matrix(c(NA,2,1, 2,NA,1, 1,2,NA), nrow=3, byrow=T), frac_otherE = 0.01, prob = 0.8, probE = 0.3) # sim 1, age 1, movement from areas in column i to areas in row j movOM_3areas@cpars$mov[1, 1, , ] plot_mov(movOM_3areas@cpars$mov) plot_mov(movOM_3areas@cpars$mov, type = "all") ## End(Not run)
## Not run: movOM_3areas <- simmov2(testOM, frac_other = matrix(c(NA,2,1, 2,NA,1, 1,2,NA), nrow=3, byrow=T), frac_otherE = 0.01, prob = 0.8, probE = 0.3) # sim 1, age 1, movement from areas in column i to areas in row j movOM_3areas@cpars$mov[1, 1, , ] plot_mov(movOM_3areas@cpars$mov) plot_mov(movOM_3areas@cpars$mov, type = "all") ## End(Not run)
Functions to run the Management Strategy Evaluation (closed-loop simulation) for a specified operating model
Simulate(OM = MSEtool::testOM, parallel = FALSE, silent = FALSE, nsim = NULL) Project( Hist = NULL, MPs = NA, parallel = FALSE, silent = FALSE, extended = FALSE, checkMPs = FALSE ) runMSE( OM = MSEtool::testOM, MPs = NA, Hist = FALSE, silent = FALSE, parallel = FALSE, extended = FALSE, checkMPs = FALSE )
Simulate(OM = MSEtool::testOM, parallel = FALSE, silent = FALSE, nsim = NULL) Project( Hist = NULL, MPs = NA, parallel = FALSE, silent = FALSE, extended = FALSE, checkMPs = FALSE ) runMSE( OM = MSEtool::testOM, MPs = NA, Hist = FALSE, silent = FALSE, parallel = FALSE, extended = FALSE, checkMPs = FALSE )
OM |
An operating model object (class OM or class |
parallel |
Logical or a named list. Should MPs be run using parallel processing?
For |
silent |
Should messages be printed out to the console? |
nsim |
Optional. numeric value to override |
Hist |
Should model stop after historical simulations? Returns an object of class 'Hist' containing all historical data |
MPs |
A vector of methods (character string) of class MP |
extended |
Logical. Return extended projection results?
if TRUE, |
checkMPs |
Logical. Check if the specified MPs exist and can be run on |
For most MPs, running in parallel can actually lead to an increase in computation time, due to the overhead in sending the
information over to the cores. Consequently, by default the MPs will not be run in parallel if parallel=TRUE
(although other internal code will be run in parallel mode).
To run MPs in parallel, specify a named list with the name of the MP(s) assigned as TRUE. For example,parallel=list(AvC=TRUE
)
will run the AvC
MP in parallel mode.
Additional savings in computation time can be achieved by running the entire simulation in batches. Individual simulations of the operating model
are divided into separate cores using SubCpars, Simulate
and Project
are applied independently for each core via snowfall::sfClusterApplyLB
, and the
output (a list of MSE objects) is stitched back together into a single MSE object using joinMSE.
The ideal number of cores will be determined based on the number of simulations and available cores.
There are several issues to look out for when using this split-apply-combine technique:
Numerical optimization for depletion may fail in individual cores when OM@cpars$qs
is not specified.
Length bins should be specified in the operating model in OM@cpars$CAL_bins
. Otherwise, length bins can vary by core and
create problems when combining into a single object.
Compared to non-parallel runs, sampled parameters in the operating model will vary despite the same value in OM@seed
.
If there is an error in individual cores or while combining the parallel output into a single Hist or MSE object, the list of output (from the cores) will be returned.
Functions return objects of class Hist or MSE
Simulate - An object of class Hist
Project - An object of class MSE
runMSE - An object of class MSE if Hist = TRUE
otherwise a class Hist object
Simulate()
: Run the Historical Simulations from an object of class OM
Project()
: Run the Forward Projections
runMSE()
: Run the Historical Simulations and Forward Projections
from an object of class 'OM
An object of class Data
SimulatedData
SimulatedData
An object of class Data
of length 1.
Functions for running a multi-stock and/or multi-fleet Management Strategy Evaluation (closed-loop simulation) for a specified operating model
SimulateMOM(MOM = MSEtool::Albacore_TwoFleet, parallel = TRUE, silent = FALSE) ProjectMOM( multiHist = NULL, MPs = NA, parallel = FALSE, silent = FALSE, checkMPs = FALSE, dropHist = FALSE, extended = FALSE ) multiMSE( MOM = MSEtool::Albacore_TwoFleet, MPs = list(list(c("AvC", "DCAC"), c("FMSYref", "curE"))), Hist = FALSE, silent = FALSE, parallel = TRUE, checkMPs = FALSE, dropHist = TRUE, extended = FALSE )
SimulateMOM(MOM = MSEtool::Albacore_TwoFleet, parallel = TRUE, silent = FALSE) ProjectMOM( multiHist = NULL, MPs = NA, parallel = FALSE, silent = FALSE, checkMPs = FALSE, dropHist = FALSE, extended = FALSE ) multiMSE( MOM = MSEtool::Albacore_TwoFleet, MPs = list(list(c("AvC", "DCAC"), c("FMSYref", "curE"))), Hist = FALSE, silent = FALSE, parallel = TRUE, checkMPs = FALSE, dropHist = TRUE, extended = FALSE )
MOM |
A multi-fleet multi-stock operating model (class MOM) |
parallel |
Logical or a named list. Should MPs be run using parallel processing? See Details for more information. |
silent |
Should messages be printed out to the console? |
multiHist |
An Historical Simulation object (class |
MPs |
A matrix of methods (nstock x nfleet) (character string) of class MP |
checkMPs |
Logical. Check if the specified MPs exist and can be run on |
dropHist |
Logical. Drop the (very large) |
extended |
Logical. Return extended projection results?
if TRUE, |
Hist |
Should model stop after historical simulations? Returns a list containing all historical data |
For most MPs, running in parallel can actually lead to an increase in computation time, due to the overhead in sending the
information over to the cores. Consequently, by default the MPs will not be run in parallel if parallel=TRUE
(although other internal code will be run in parallel mode).
To run MPs in parallel, specify a named list with the name of the MP(s) assigned as TRUE. For example,parallel=list(AvC=TRUE
)
will run the AvC
MP in parallel mode.
Functions return objects of class MMSE
and multiHist
#'
SimulateMOM - An object of class multiHist
ProjectMOM - An object of class MMSE
multiMSE - An object of class MMSE
SimulateMOM()
: Simulate historical dynamics for multi-OM
ProjectMOM()
: Run Forward Projections for a MOM
object
multiMSE()
: Run a multi-stock, multi-fleet MSE
T. Carruthers and A. Hordyk
Internal function for interactive plot which allows users to specify the relative trajectory and variability in the historical fishing effort.
SketchFun(nyears, Years=NULL)
SketchFun(nyears, Years=NULL)
nyears |
Number of years |
Years |
An optional vector of years. Should be nyears long. |
A. Hordyk
Polynomial smoother (no gradient prediction) applied to a vector that can include NA values. Intended to be rapid for use in management procedures
smoothy(xx, plot = F, enp_mult, plotname = "", xlab = "x", ylab = "y", x = NA)
smoothy(xx, plot = F, enp_mult, plotname = "", xlab = "x", ylab = "y", x = NA)
xx |
Vector of real numbers, data to be smoothed. |
plot |
Logical, should the 'fit' of the smoother be plotted? |
enp_mult |
Fraction, effective number of parameters multiplier. The smoother parameter number is length(xx) x enp_mult. So higher values of enp_mult means less smoothing (more parameters). |
plotname |
Character, in case you want to put a label on the plot (plot = T). |
xlab |
Character, in case you want an xaxis label on the plot (plot = T) |
ylab |
Character, in case you want a yaxis label on the plot (plot = T) |
x |
Numeric vector same length as xx, in case you want to have a custom xaxis (e.g. years) |
T. Carruthers
Plots projections of F/FMSY, SB/SBMSY and Yield
Splot(MSEobj, MPs = 5, p = c(0.05, 0.25, 0.5, 0.75, 0.95))
Splot(MSEobj, MPs = 5, p = c(0.05, 0.25, 0.5, 0.75, 0.95))
MSEobj |
Object of class 'MSE' from runMSE() or Project() |
MPs |
Either a positive integer (the first MPs number of MPs to plot), a character vector (the names of the MPs to plot), or an integer vector (the index of the MPs to plot) |
p |
Vector of quantiles five positions long. Defaults to c(0.05,0.25,0.5,0.75,0.95) so the 90% and 50% intervals with the median plotted in white. |
T. Carruthers
A function that uses the file location of a fitted SS3 model including input files to population the various slots of an Data object.
SS2Data( SSdir, Name = "Imported by SS2Data", Common_Name = "", Species = "", Region = "", min_age_M = 1, gender = 1, comp_fleet = "all", comp_season = "sum", comp_partition = "all", comp_gender = "all", index_season = "mean", silent = FALSE, ... )
SS2Data( SSdir, Name = "Imported by SS2Data", Common_Name = "", Species = "", Region = "", min_age_M = 1, gender = 1, comp_fleet = "all", comp_season = "sum", comp_partition = "all", comp_gender = "all", index_season = "mean", silent = FALSE, ... )
SSdir |
A folder with Stock Synthesis input and output files in it |
Name |
The name for the Data object |
Common_Name |
Character string for the common name of the stock. |
Species |
Scientific name of the species |
Region |
Geographic region of the stock or fishery. |
min_age_M |
Currently, the Data object supports a single value of M for all ages. The argument selects the minimum age for calculating the mean of age-dependent M from the SS assessment. |
gender |
An integer index for the sex for importing biological parameters (1 = female, 2 = male). |
comp_fleet |
A vector of indices corresponding to fleets in the assessment over which to aggregate the composition
(catch-at-length and catch-at-age) data. By default, character string |
comp_season |
Integer, for seasonal models, the season for which the value of the index will be used. By default, |
comp_partition |
Integer vector for selecting length/age observations that are retained (2), discarded (1), or both (0). By default, |
comp_gender |
Integer vector for selecting length/age observations that are female (1), male (2), or both (0), or both scaled to sum to one (3).
By default, |
index_season |
Integer, for seasonal models, the season for which the value of the index will be used. By default, |
silent |
Logical. Suppress all messages? |
... |
Arguments to pass to SS_output |
An object of class Data.
Currently supports the version of r4ss on CRAN (v.1.24) and Github (v.1.34-40). Function may be incompatible with other versions of r4ss.
T. Carruthers and Q. Huynh
A function that uses the file location of a fitted SS3 model including input files to population the various slots of an Data object.
SS2DataMOM(SSdir, age_M = NULL, comp_partition = 2, silent = FALSE, ...)
SS2DataMOM(SSdir, age_M = NULL, comp_partition = 2, silent = FALSE, ...)
SSdir |
A folder with Stock Synthesis input and output files in it. Alternatively, |
age_M |
A vector of ages to average across to calculate a single value of natural mortality.
Currently, the Data object supports a single value of M for all ages. By default, |
comp_partition |
Integer vector for selecting length/age observations that are retained (2), discarded (1), or both (0). By default, only retained comps are used. If multiple codes are used, then comp matrix is the sum over all codes. |
silent |
Logical. Suppress messages? |
... |
Arguments to pass to SS_output |
A nested list of Data objects, with the first index by stock/sex and the second index by fleet.
Currently tested on r4ss version 1.38.1-41 and SS 3.30.14.
Catches in Data@Cat
are the predicted sex-specific catch calculated from the SS output.
Q. Huynh
Functions that uses the file location or the r4ss output list of a fitted SS3 model including input files to populate the
various slots of an MOM or OM object. SS2MOM
and SS2OM
mainly populates the Stock and Fleet components
components of the operating model. SS2MOM
creates a 2-sex model and multiple fleets with discarding behavior.
SS2OM
returns a single sex (either male, female, or averaged biological parameters) and single fleet (aggregate selectivity and mortality,
no explicit discarding modeled). For either, the user still needs to parameterize most of the observation and
implementation portions. SSMOM2OM
is the internal function that simplifies the MOM object to an OM object.
plot_SS2OM
generates a markdown report to compare the OM and SS output.
SS2MOM( SSdir, nsim = 48, proyears = 50, reps = 1, maxF = 3, seed = 1, interval = 1, pstar = 0.5, Obs = MSEtool::Generic_Obs, Imp = MSEtool::Perfect_Imp, silent = FALSE, Name = "MOM generated by SS2MOM", Source = "No Source provided", ... ) plot_SS2MOM( x, SSdir, gender = 1:2, filename = "SS2MOM", dir = tempdir(), open_file = TRUE, silent = FALSE, ... ) SS2OM( SSdir, nsim = 48, proyears = 50, reps = 1, maxF = 3, seed = 1, interval = 1, pstar = 0.5, Obs = MSEtool::Generic_Obs, Imp = MSEtool::Perfect_Imp, import_mov = TRUE, gender = 1:2, seasons_to_years = TRUE, model_discards = TRUE, silent = FALSE, Name = "OM generated by SS2OM function", Source = "No source provided", Author = "No author provided", report = FALSE, filename = "SS2OM", dir = tempdir(), open_file = TRUE, ... ) SSMOM2OM( MOM, SSdir, gender = 1:2, import_mov = TRUE, seed = 1, silent = FALSE, model_discards = TRUE ) plot_SS2OM( x, SSdir, gender = 1:2, filename = "SS2OM", dir = tempdir(), open_file = TRUE, silent = FALSE, ... ) MOM_agg_fleets(MOM)
SS2MOM( SSdir, nsim = 48, proyears = 50, reps = 1, maxF = 3, seed = 1, interval = 1, pstar = 0.5, Obs = MSEtool::Generic_Obs, Imp = MSEtool::Perfect_Imp, silent = FALSE, Name = "MOM generated by SS2MOM", Source = "No Source provided", ... ) plot_SS2MOM( x, SSdir, gender = 1:2, filename = "SS2MOM", dir = tempdir(), open_file = TRUE, silent = FALSE, ... ) SS2OM( SSdir, nsim = 48, proyears = 50, reps = 1, maxF = 3, seed = 1, interval = 1, pstar = 0.5, Obs = MSEtool::Generic_Obs, Imp = MSEtool::Perfect_Imp, import_mov = TRUE, gender = 1:2, seasons_to_years = TRUE, model_discards = TRUE, silent = FALSE, Name = "OM generated by SS2OM function", Source = "No source provided", Author = "No author provided", report = FALSE, filename = "SS2OM", dir = tempdir(), open_file = TRUE, ... ) SSMOM2OM( MOM, SSdir, gender = 1:2, import_mov = TRUE, seed = 1, silent = FALSE, model_discards = TRUE ) plot_SS2OM( x, SSdir, gender = 1:2, filename = "SS2OM", dir = tempdir(), open_file = TRUE, silent = FALSE, ... ) MOM_agg_fleets(MOM)
SSdir |
A folder with Stock Synthesis input and output files in it. |
nsim |
The number of simulations to take for parameters with uncertainty (for OM@cpars custom parameters). |
proyears |
The number of projection years for MSE |
reps |
The number of stochastic replicates within each simulation in the operating model. |
maxF |
The maximum allowable F in the operating model. |
seed |
The random seed for the operating model. |
interval |
The interval at which management procedures will update the management advice in multiMSE, e.g., 1 = annual updates. |
pstar |
The percentile of the sample of the management recommendation for the MP/MMP. |
Obs |
The observation model (class Obs). These functions do not update implementation parameters. |
Imp |
The implementation model (class Imp). These functions do not update implementation parameters. |
silent |
Whether to silence messages to the console. |
Name |
The name of the operating model |
Source |
Reference to assessment documentation e.g. a url |
... |
Arguments to pass to SS_output. |
x |
For |
gender |
An integer that indexes the sex for importing life history parameters (1 = usually female, 2 = usually male, 1:2 = mean across both sexes).
Only used for |
filename |
If |
dir |
If |
open_file |
If |
import_mov |
Logical. Import movement matrix? |
seasons_to_years |
Logical, when season is the time step, whether to convert OM from a seasonal model to annual model. |
model_discards |
Logical, how to simplify a multi-fleet SS model to an OM object. If TRUE, OM will still model discards using the mean retention across fleets (weighted by fleet F). Otherwise, no discards are modeled and all fishing removals are calculated in the OM from the SS F-at-age matrix. |
Author |
Who did the assessment |
report |
Logical, if TRUE, the function will run runMSE to generate the Hist object from the operating model to compare against SS output. A markdown report will be generated. |
MOM |
MOM object |
SS2MOM returns an object of class MOM. SS2OM returns an object of class OM.
MOM_agg_fleets()
: Aggregate all fleets in an MOM object.
Currently tested on r4ss version 1.38.1-40.0 and SS 3.30.14.
Q. Huynh
Plot Spawning stock biomass and reference points for both historical and projected period
SSBrefplot(MSE, simno = 1, ystart = 1, log = F, leg = T)
SSBrefplot(MSE, simno = 1, ystart = 1, log = F, leg = T)
MSE |
An object of class 'MSE' produced by from runMSE() |
simno |
Positive integer, the simulation number you wish to plot |
ystart |
Positive integer, the calendar year corresponding with the first historical year |
log |
Boolean, whether log SSB and reference points should be plotted |
leg |
Boolean, should a legend be included in the plot? |
T. Carruthers
'Stock'
An operating model component that specifies the parameters of the population dynamics model
Name
An identifying name for the Stock object. Single value. Character string.
Common_Name
Common name of the species. Character string.
Species
Scientific name of the species. Genus and species name. Character string.
maxage
The maximum age of individuals that is simulated. There are
maxage+1
(recruitment to age-0) age classes in the storage matrices.
maxage
is the 'plus group' where all age-classes > maxage
are grouped,
unless option switched off with OM@cpars$plusgroup=0
. Single value.
Positive integer.
R0
Initial number of unfished recruits to age-0. This number is used
to scale the size of the population to match catch or data, but does not affect
any of the population dynamics unless the OM has been conditioned with data. As
a result, for a data-limited fishery any number can be used for R0
. In
data-rich stocks R0
may be estimated as part of a stock assessment, but for
data limited stocks users can choose either an arbitrary number (say, 1000) or
choose a number that produces simulated catches in recent historical years that
are similar to real world catch data. Single value. Positive real number.
M
The instantaneous rate of natural mortality. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Uniform distribution lower and upper bounds. Non-negative real numbers.
Msd
Inter-annual variation in M
expressed as a coefficient of
variation of a log-normal distribution. For each simulation a single value is
drawn from a uniform distribution specified by the upper and lower bounds
provided. If this parameter is positive, yearly M
is drawn from a log-normal
distribution with a mean specified by log(M)
drawn for that simulation and a
standard deviation in log space specified by the value of Msd
drawn for that
simulation. Uniform distribution lower and upper bounds. Non-negative real
numbers
h
Steepness of the stock recruit relationship. Steepness governs the proportion of unfished recruits produced when the stock is at 20% of the unfished population size. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This value is the same in all years of a given simulation. Uniform distribution lower and upper bounds. Values from 1/5 to 1.
SRrel
Type of stock-recruit relationship. Use 1 to select a Beverton Holt relationship, 2 to select a Ricker relationship. Single value. Integer
Perr
Recruitment process error, which is defined as the standard deviation of the recruitment deviations in log space. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Uniform distribution lower and upper bounds. Non-negative real numbers.
AC
Autocorrelation in the recruitment deviations in log space. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided, and used to add lag-1 auto-correlation to the log recruitment deviations. Uniform distribution lower and upper bounds. Non-negative real numbers.
Linf
The von Bertalanffy growth parameter Linf, which specifies the
average maximum size that would reached by adult fish if they lived
indefinitely. For each simulation a single value is drawn from a uniform
distribution specified by the upper and lower bounds provided. This value is
the same in all years unless Linfsd
is a positive number. Uniform
distribution lower and upper bounds. Positive real numbers.
Linfsd
Inter-annual variation in Linf. For each simulation a single
value is drawn from a uniform distribution specified by the upper and lower
bounds provided. If this parameter has a positive value, yearly Linf is drawn
from a log-normal distribution with a mean specified by the value of Linf
drawn for that simulation and a standard deviation (in log space) specified by
the value of Linfsd
drawn for that simulation. Uniform distribution lower and
upper bounds. Non-negative real numbers.
K
The von Bertalanffy growth parameter k, which specifies the average
rate of growth. For each simulation a single value is drawn from a uniform
distribution specified by the upper and lower bounds provided. This value is
the same in all years unless Ksd
is a positive number. Uniform distribution
lower and upper bounds. Positive real numbers.
Ksd
Inter-annual variation in K. For each simulation a single value is
drawn from a uniform distribution specified by the upper and lower bounds
provided. If this parameter has a positive value, yearly K is drawn from a
log-normal distribution with a mean specified by the value of K
drawn for
that simulation and a standard deviation (in log space) specified by the value
of Ksd
drawn for that simulation. Uniform distribution lower and upper
bounds. Non-negative real numbers.
t0
The von Bertalanffy growth parameter t0, which specifies the theoretical age at a size 0. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Uniform distribution lower and upper bounds. Non-positive real numbers.
LenCV
The coefficient of variation (defined as the standard deviation divided by mean) of the length-at-age. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided to specify the distribution of observed length-at-age, and the CV of this distribution is constant for all age classes (i.e, standard deviation increases proportionally with the mean). Uniform distribution lower and upper bounds. Positive real numbers.
L50
Length at 50% maturity. For each simulation a single value is
drawn from a uniform distribution specified by the upper and lower bounds
provided. The L50
and L50_95
parameters are converted to ages using the
growth parameters provided and used to construct a logistic curve to determine
the proportion of the population that is mature in each age class. Uniform
distribution lower and upper bounds. Positive real numbers.
L50_95
Difference in lengths between 50% and 95% maturity. For each
simulation a single value is drawn from a uniform distribution specified by the
upper and lower bounds provided. The value drawn is then added to the length at
50% maturity to determine the length at 95% maturity. This parameterization is
used instead
of specifying the size at 95 percent maturity to avoid
situations where the value drawn for the size at 95% maturity is smaller than
that at 50% maturity. The L50
and L50_95
parameters are converted to ages
using the growth parameters provided and used to construct a logistic curve to
determine the proportion of the population that is mature in each age class.
Uniform distribution lower and upper bounds. Positive real numbers.
D
Estimated current level of stock depletion, which is defined as the current spawning stock biomass divided by the unfished spawning stock biomass. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. This parameter is used during model initialization to select a series of yearly historical recruitment values and fishing mortality rates that, based on the information provided, could have resulted in the specified depletion level in the simulated last historical year. Uniform distribution lower and upper bounds. Positive real numbers (typically < 1)
a
The alpha parameter in allometric length-weight relationship. Single
value. Weight parameters are used to determine catch-at-age and
population-at-age from the number of individuals in each age class and the
length of each individual, which is drawn from a normal distribution determined
by the Linf
, K
, t0
, and LenCV
parameters. As a result, they function as
a way to scale between numbers at age and biomass, and are not stochastic
parameters. Single value. Positive real number.
b
The beta parameter in allometric length-weight relationship. Single
value. Weight parameters are used to determine catch-at-age and
population-at-age from the number of individuals in each age class and the
length of each individual, which is drawn from a normal distribution determine
by the Linf
, K
, t0
, and LenCV
parameters. As a result, they function as
a way to scale between numbers at age and biomass, and are not stochastic
parameters. Single value. Positive real number.
Size_area_1
The size of area 1 relative to area 2. The fraction of the unfished biomass in area 1. Please specify numbers between 0 and 1. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. For example, if Size_area_1 is 0.2, then 20% of the total area is allocated to area 1. Fishing can occur in both areas, or can be turned off in one area to simulate the effects of a no take marine reserve. Uniform distribution lower and upper bounds. Positive real numbers.
Frac_area_1
The fraction of the unfished biomass in area 1. Please specify numbers between 0 and 1. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. For example, if Frac_area_1 is 0.5, then 50% of the unfished biomass is allocated to area 1, regardless of the size of area 1 (i.e, size and fraction in each area determine the density of fish, which may impact fishing spatial targeting). In each time step recruits are allocated to each area based on the proportion specified in Frac_area_1. Uniform distribution lower and upper bounds. Positive real numbers.
Prob_staying
The probability of individuals in area 1 remaining in area 1 over the course of one year. Please specify numbers between 0 and 1. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. For example, in an area with a Prob_staying value of 0.95 each fish has a 95% probability of staying in that area in each time step, and a 5% probability of moving to the other area. Uniform distribution lower and upper bounds. Positive fraction.
Fdisc
The instantaneous discard mortality rate the stock experiences when fished using the gear type specified in the corresponding fleet object and discarded. For each simulation a single value is drawn from a uniform distribution specified by the upper and lower bounds provided. Uniform distribution lower and upper bounds. Non-negative real numbers.
Source
A reference to a website or article from which parameters were taken to define the stock object. Single value. Character string.
Objects can be created by calls of the form
new('Stock')
T. Carruthers and A. Hordyk
showClass('Stock')
showClass('Stock')
A data.frame with description of slots for class Stock
StockDescription
StockDescription
An object of class data.frame
with 27 rows and 2 columns.
Subset the MSE object by particular MPs (either MP number or name), or particular simulations, or a subset of the projection years (e.g., 1: < projection years).
Sub(MSEobj, MPs = NULL, sims = NULL, years = NULL)
Sub(MSEobj, MPs = NULL, sims = NULL, years = NULL)
MSEobj |
A MSE object. |
MPs |
A vector MPs names or MP numbers to subset the MSE object. Defaults to all MPs. |
sims |
A vector of simulation numbers to subset the MSE object. Can also be a logical vector. Defaults to all simulations. |
years |
A numeric vector of projection years. Should start at 1 and increase by one to some value equal or less than the total number of projection years. |
A. Hordyk
SubOM for OM components and SubCpars for subsetting by simulation and projection years.
## Not run: MSE <- runMSE() MSE_1 <- Sub(MSE, MPs=1:2) MSE_1@MPs MSE_2 <- Sub(MSE, sims=1:10) MSE_2@nsim ## End(Not run)
## Not run: MSE <- runMSE() MSE_1 <- Sub(MSE, MPs=1:2) MSE_1@MPs MSE_2 <- Sub(MSE, sims=1:10) MSE_2@nsim ## End(Not run)
Subset the custom parameters of an operating model by simulation and projection years
SubCpars(x, ...) ## S4 method for signature 'OM' SubCpars(x, sims = 1:x@nsim, proyears = x@proyears, silent = FALSE) ## S4 method for signature 'MOM' SubCpars(x, sims = 1:x@nsim, proyears = x@proyears, silent = FALSE)
SubCpars(x, ...) ## S4 method for signature 'OM' SubCpars(x, sims = 1:x@nsim, proyears = x@proyears, silent = FALSE) ## S4 method for signature 'MOM' SubCpars(x, sims = 1:x@nsim, proyears = x@proyears, silent = FALSE)
x |
|
... |
Arguments for method. |
sims |
A logical vector of length |
proyears |
If provided, a numeric to reduce the number of projection years (must be less than |
silent |
Logical to indicate if messages will be reported to console. |
Useful function for running multiMSE in batches if running into memory constraints.
An object of class OM or MOM (same class as x
).
T. Carruthers, Q. Huynh
Sub for MSE objects, SubOM for OM components.
A function that strips out a Stock, Fleet, Obs, or Imp object from a complete OM object. Mainly used for internal functions.
SubOM(OM, Sub = c("Stock", "Fleet", "Obs", "Imp"))
SubOM(OM, Sub = c("Stock", "Fleet", "Obs", "Imp"))
OM |
An operating model object (class OM) |
Sub |
A character string specifying what object type to strip out "Stock", "Fleet", "Obs", or "Imp" |
An object of class Stock, Fleet, Obs, or Imp
A. Hordyk
Sub for subsetting MSE output and SubCpars for subsetting by simulation and projection years.
Stock <- SubOM(testOM, "Stock") class(Stock)
Stock <- SubOM(testOM, "Stock") class(Stock)
Summary of Data object
## S4 method for signature 'Data' summary( object, wait = TRUE, x = 1, plots = "all", rmd = FALSE, head = "##", tplot = 25 )
## S4 method for signature 'Data' summary( object, wait = TRUE, x = 1, plots = "all", rmd = FALSE, head = "##", tplot = 25 )
object |
An object of class Data |
wait |
Logical. Wait for key press before next plot? |
x |
iteration number for the Data object. |
plots |
Character. What plots to show? |
rmd |
Logical. Used in a rmd file? |
head |
Character. Heading for rmd file. Default is '##' (second level heading) |
tplot |
Integer. Number of plots per page. Default 25 |
Summary of MMSE object
## S4 method for signature 'MMSE' summary(object, ..., silent = FALSE, Refs = NULL)
## S4 method for signature 'MMSE' summary(object, ..., silent = FALSE, Refs = NULL)
object |
object of class |
... |
a list of names of PM methods |
silent |
Should summary be printed to console? Logical. |
Refs |
An optional named list (matching the PM names) with numeric values to override the default |
Summary of MSE object
## S4 method for signature 'MSE' summary(object, ..., silent = FALSE, Refs = NULL)
## S4 method for signature 'MSE' summary(object, ..., silent = FALSE, Refs = NULL)
object |
object of class MSE |
... |
a list of names of PM methods |
silent |
Should summary be printed to console? Logical. |
Refs |
An optional named list (matching the PM names) with numeric values to override the default |
A function that returns the stochastic TAC recommendations from a vector of output control MPs given a data object Data
TAC(Data, MPs = NA, reps = 100, timelimit = 1, checkMP = TRUE, silent = FALSE)
TAC(Data, MPs = NA, reps = 100, timelimit = 1, checkMP = TRUE, silent = FALSE)
Data |
A data-limited methods data object |
MPs |
optional vector of MP names |
reps |
Number of repetitions |
timelimit |
The maximum time (seconds) taken to complete 10 reps |
checkMP |
Logical. Check if the MP can be run first? |
silent |
Logical. Suppress messages? |
T. Carruthers
## Not run: library(MSEtool) Data <- TAC(MSEtool::Cobia) plot(Data) ## End(Not run)
## Not run: library(MSEtool) Data <- TAC(MSEtool::Cobia) plot(Data) ## End(Not run)
Filters vector of TAC recommendations by replacing negatives with NA and and values beyond five standard deviations from the mean as NA
TACfilter(TAC)
TACfilter(TAC)
TAC |
A numeric vector of TAC recommendations |
T. Carruthers
Database from rfishbase
Taxa_Table
Taxa_Table
An object of class tbl_df
(inherits from tbl
, data.frame
) with 34721 rows and 8 columns.
doi:10.1111/j.1095-8649.2012.03464.x
Carl Boettiger and Duncan Temple Lang and Peter Wainwright 2012. Journal of Fish Biology
Create an indexing grid from just a vector of maximum dimension sizes
TEG(vec)
TEG(vec)
vec |
A vector of maximum array sizes |
T. Carruthers
Example objects of class OM
testOM
testOM
An object of class OM
of length 1.
avail("OM")
avail("OM")
Crit_S is the probability of being in the critical zone in the first 10 projected years Caut_S is the probability of being in the cautious zone in the first 10 projected years Health_S is the probability of being in the healthy zone in the first 10 projected years OvFish_S is the probability of overfishing in the first 10 projected years Yield_S is the mean yield relative to FMSY management over the first 10 projected years Crit is the probability of being in the critical zone in the last 10 projected years Caut is the probability of being in the cautious zone in the last 10 projected years Health is the probability of being in the healthy zone in the last 10 projected years OvFish is the probability of overfishing in the last 10 projected years Yield is the mean yield relative to FMSY management over the last 10 projected years AAVY is the average annual variability in yield over the whole projection phrased as a CV percentage Reb is the probability the stock has rebuilt to over BMSY in 2 mean generation times
Thresh_tab(Ptab1)
Thresh_tab(Ptab1)
Ptab1 |
A DFO performance table made by DFO_tab() |
T. Carruthers
Takes an existing OM object and converts it to one without any observation error, implementation error, very little process error, and/or gradients in life history parameters and catchability.
tinyErr(x, ...) ## S4 method for signature 'OM' tinyErr(x, obs = TRUE, imp = TRUE, proc = TRUE, grad = TRUE, silent = FALSE)
tinyErr(x, ...) ## S4 method for signature 'OM' tinyErr(x, obs = TRUE, imp = TRUE, proc = TRUE, grad = TRUE, silent = FALSE)
x |
An object of class |
... |
Arguments to generic function |
obs |
Logical. Remove observation error? |
imp |
Logical. Remove implementation error? |
proc |
Logical. Remove process error? All |
grad |
Logical. Remove gradients? All |
silent |
Logical. Display messages? |
Useful for debugging and testing that MPs perform as expected under perfect conditions.
An updated object of class OM
OM_noErr <- tinyErr(MSEtool::testOM)
OM_noErr <- tinyErr(MSEtool::testOM)
Generic Trade-Plot Function
TradePlot( MSEobj, ..., Lims = c(0.2, 0.2, 0.8, 0.8), Title = NULL, Labels = NULL, Satisficed = FALSE, Show = "both", point.size = 2, lab.size = 4, axis.title.size = 12, axis.text.size = 10, legend = TRUE, legend.title.size = 12, position = c("right", "bottom"), cols = NULL, fill = "gray80", alpha = 0.4, PMlist = NULL, Refs = NULL, Yrs = NULL ) Tplot(MSEobj, Lims = c(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5), ...) Tplot2(MSEobj, Lims = c(0.2, 0.2, 0.8, 0.8), ...) Tplot3(MSEobj, Lims = c(0.5, 0.5, 0.8, 0.5), ...) NOAA_plot2(MSEobj)
TradePlot( MSEobj, ..., Lims = c(0.2, 0.2, 0.8, 0.8), Title = NULL, Labels = NULL, Satisficed = FALSE, Show = "both", point.size = 2, lab.size = 4, axis.title.size = 12, axis.text.size = 10, legend = TRUE, legend.title.size = 12, position = c("right", "bottom"), cols = NULL, fill = "gray80", alpha = 0.4, PMlist = NULL, Refs = NULL, Yrs = NULL ) Tplot(MSEobj, Lims = c(0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5), ...) Tplot2(MSEobj, Lims = c(0.2, 0.2, 0.8, 0.8), ...) Tplot3(MSEobj, Lims = c(0.5, 0.5, 0.8, 0.5), ...) NOAA_plot2(MSEobj)
MSEobj |
An object of class |
... |
Names of Performance Metrics (PMs), or other arguments to |
Lims |
A numeric vector of acceptable risk/minimum probability thresholds. Recycled if not equal to number of PMs. |
Title |
Optional title for each plot. Character vector of |
Labels |
Optional named list specifying new labels for MPs. For example: |
Satisficed |
Logical. Show only the MPs that meet minimum acceptable thresholds (specified in |
Show |
Character. Show the plots ('plots'), results table ('table'), 'both' (default), or invisibly return objects only ('none') |
point.size |
Numeric. Size of the MP points |
lab.size |
Numeric. Size of MP label. Set to NULL to remove MP labels. |
axis.title.size |
Numeric. Size of axis titles |
axis.text.size |
Numeric. Size of axis text |
legend |
Logical. Include legend? |
legend.title.size |
Numeric. Size of legend title text |
position |
Character. Position of legend - 'right' or 'bottom' |
cols |
Optional character vector of colors for the legend (MP Types) or if |
fill |
Character. Color of the fill |
alpha |
Numeric. Transparency of fill |
PMlist |
Optional list of PM names. Overrides any supplied in ... above |
Refs |
An optional named list (matching the PM names) with numeric values to override the default |
Yrs |
An optional named list (matching the PM names) with numeric values to override the default |
Invisibly returns a list with summary table of MP performance and the ggplot objects for the plots
Tplot()
: A trade-off plot showing probabilities that:
not overfishing (PNOF) against long-term yield is > 50\
spawning biomass is below BMSY (P100) against LTY
spawning biomass is below 0.5BMSY (P50) against LTY
spawning biomass is below 0.1BMSY (P10) against LTY
Tplot2()
: A trade-off plot showing probabilities that:
short-term yield is > 50\
spawning biomass is below 0.1BMSY (P10) against average annual variability in yield is < 20\
Tplot3()
: A trade-off plot showing probabilities that:
not overfishing (PNOF) against long-term yield is > 50\
spawning biomass is below 0.1BMSY (P10) against average annual variability in yield is < 20\
NOAA_plot2()
: A trade-off plot developed for NOAA showing probabilities that:
not overfishing (PNOF) against long-term yield is > 50\
spawning biomass is below 0.5BMSY (P50) against average annual variability in yield is < 15\
A. Hordyk
A generic function that uses optimize to tune a single MP parameter to minimize a user-specified function (e.g. squared distance from a mean yield, PGK = 60%, etc.)
tune_MP(Hist_list, MP, MP_parname, interval, minfunc, tol = 0.01, parallel = F)
tune_MP(Hist_list, MP, MP_parname, interval, minfunc, tol = 0.01, parallel = F)
Hist_list |
A list of objects of class Hist - created by runMSE(..., Hist=T) |
MP |
A character string that is the name of the MP to be tuned |
MP_parname |
A character string that is the argument (parameter) of the MP to be tuned |
interval |
A numeric vector two positions long that is the c(lower.bound, upper.bound) for the parameter to be tuned (MP_parname) |
minfunc |
A function to be minimized (e.g. the squared difference between mean yield obtained by the MP and a desired yield) that takes a list of MSE objects as its first argument. |
tol |
A positive numerical value that is the tolerance for the optimize procedure (default is 1E-2) |
parallel |
Logical: should the MSE projections (over the Hist objects in Hist_list) be calculated in parallel? |
A function of class MP with argument MP_parname tuned by optim to minimize minfunc
T. Carruthers
## Not run: testOM@cpars$Data = new('Data') testOM@cpars$Data@MPrec=2000 Hist_1 = runMSE(testOM,Hist=T) testOM2 = testOM testOM2@D = testOM@D / 2 Hist_2 = runMSE(testOM2,Hist=T) myMP = function(x, Data, reps=1, rate = 1){ CpI = mean(Data@Cat[x,46:50]) / mean(Data@Ind[x,46:50],na.rm=T) I = Data@Ind[x,] recI = mean(I[length(I)-((5-1):0)]) Rec=new('Rec') Rec@TAC = recI * CpI * rate Rec } class(myMP) = "MP" C1000 = function(MSE_list){ mucat = mean(sapply(MSE_list,function(X){mean(X@Catch)})) cat(paste0("mean catch = ",round(mucat,3),"\n")) (mucat - 1000)^2 # try to match 1,250t mean yield } myMP_t = tune_MP(list(Hist_1,Hist_2), MP = "myMP", MP_parname = "rate", interval = c(1,1.5), minfunc = C1000, tol=1E-3, parallel =F) formals(myMP_t)$rate ## End(Not run)
## Not run: testOM@cpars$Data = new('Data') testOM@cpars$Data@MPrec=2000 Hist_1 = runMSE(testOM,Hist=T) testOM2 = testOM testOM2@D = testOM@D / 2 Hist_2 = runMSE(testOM2,Hist=T) myMP = function(x, Data, reps=1, rate = 1){ CpI = mean(Data@Cat[x,46:50]) / mean(Data@Ind[x,46:50],na.rm=T) I = Data@Ind[x,] recI = mean(I[length(I)-((5-1):0)]) Rec=new('Rec') Rec@TAC = recI * CpI * rate Rec } class(myMP) = "MP" C1000 = function(MSE_list){ mucat = mean(sapply(MSE_list,function(X){mean(X@Catch)})) cat(paste0("mean catch = ",round(mucat,3),"\n")) (mucat - 1000)^2 # try to match 1,250t mean yield } myMP_t = tune_MP(list(Hist_1,Hist_2), MP = "myMP", MP_parname = "rate", interval = c(1,1.5), minfunc = C1000, tol=1E-3, parallel =F) formals(myMP_t)$rate ## End(Not run)
Plots the available data in the Data
object together with 5 samples of
historical data from the Operating Model (OM) in a random order. The test is
used to determine if the data generated by the OM is similar to the fishery
data in the Data
object. In a well specified OM the user should not be able
to visually identify which of the 6 plots is the real fishery data and which
are generated by the OM.'
Turing(OM, Data, wait = TRUE) TuringMOM(multiHist, Data, wait = TRUE)
Turing(OM, Data, wait = TRUE) TuringMOM(multiHist, Data, wait = TRUE)
OM |
An object of class |
Data |
An object of class |
wait |
Logical. Wait for key press before next plot? |
multiHist |
An object of class |
In its current form the Turing function does not interpolate missing data in the Data object. Therefore if there are years with missing data, say in the catch time-series, it will be obvious which are the real data and which have been generated by the model. Future versions of the function may include methods to impute missing data for plotting purposes.
The question to ask when examining the plots produced by Turing
: do the plots
of the 6 data samples look like they are all samples from the same underlying distribution?
TuringMOM()
: Turing function for multi-stock, multi-fleet MOMs
The Turing function was suggested by Andre Punt in his review of one of our recent projects. It is named after the Turing test, developed by Alan Turing in 1950, which is designed to see if a human can detect the difference between human and machine generated information.
## Not run: Turing(MSEtool::testOM, MSEtool::SimulatedData, wait=FALSE) ## End(Not run)
## Not run: Turing(MSEtool::testOM, MSEtool::SimulatedData, wait=FALSE) ## End(Not run)
Find the Management Procedures that use a particular data slot
Uses(slot, silent = FALSE)
Uses(slot, silent = FALSE)
slot |
A slot from an object of class |
silent |
Logical. Should messages be printed? |
A character string of MPs that use the slot.
A. Hordyk
Uses("Mort")
Uses("Mort")
Valid custom parameters (cpars)
validcpars( type = c("all", "Stock", "Fleet", "Obs", "Imp", "internal"), valid = TRUE, show = TRUE )
validcpars( type = c("all", "Stock", "Fleet", "Obs", "Imp", "internal"), valid = TRUE, show = TRUE )
type |
What cpars to show? 'all', 'Stock', 'Fleet', 'Obs', 'Imp', or 'internal' |
valid |
Logical. Show valid cpars? |
show |
Logical. Display the table in the Viewer? |
a HTML datatable with variable name, description and type of valid cpars
A named list for control
, for example, OM@cpars$control <- list(TAC = "removals", CAL = "removals")
, can be
specified to override default settings in the MSE simulation. Possible names in the control
list are:
TAC
Character, set to "removals"
so that the TAC is applied to the sum of retained + discarded catch. Default only applies the TAC to the retained catch.
CAL
Character, set to "removals"
to sample the catch-at-length from retained + discarded catch. Default only samples from retained catch.
D
Character, set to "VB"
so that historical depletion OM@D
corresponds to vulnerable biomass depletion (only used when OM@cpars$qs = NULL
).
optVB
Logical, set to TRUE
so that historical depletion OM@D
corresponds to vulnerable biomass depletion. Default sets depletion according to spawning biomasss when OM@cpars$qs = NULL
.
optSBMSY
Logical, set to TRUE
such that OM@D
corresponds to the ratio of spawning biomass to MSY. Default uses according to spawning biomass depletion (biomass relative to unfished levels).
Depletion
Character, set to "end"
such that historical depletion OM@D
corresponds to the biomass at the end of the last projection year. Default corresponds to the value at the beginning of the last projection year.
ntrials
Integer, set the number of iterations to sample the operating model to match the depletion to OM@D
. Default is 50.
fracD
Numeric, the maximum allowable proportion of simulations allowed to hit the bounds of the depletion parameter (simulation returns an error if exceeded). Default is 0.05.
checks
Logical. If TRUE
, plots depletion and SB/SBMSY figures and prints values to the R console to diagnose issues with operating model configuration with regards to depletion.
unfished
Logical. If TRUE
, returns historical simulations with F = 0.
progress
Logical. If TRUE
, updates progress bar through shiny::incProgress
. Used in conjunction with Shiny apps.
maxiterF
Integer, the number of iterations to solve for F in the projections from the specified TAC. Default is 300.
tolF
Numeric, the tolerance for the catch relative to the TAC when solving for F in the projections. Default is 1e-4.
HZN
Integer, the number of generations to solve for B_low. Default is 2. See getBlow()
.
Bfrac
Numeric, proportion of SBMSY to solve for B_low. Default is 0.5. See getBlow()
.
skipdata
Logical. If TRUE
, skips conditioning on data in MOM@cpars[[p]][[f]]$Data
. Only used in multiMSE()
.
HermEq
Logical, whether the equilibrium population age structures in the multi-OM is generated from the hermaphroditism vector (intended for use in salmonMSE). Default is TRUE. Only used in multiMSE()
.
HistRel
Logical, whether to perform the historical reconstruction with inter-stock relationships in MOM@Rel
. Default is TRUE. Only used in multiMSE()
.
## Not run: validcpars() # all valid cpars validcpars("Obs", FALSE) # invalid Obs cpars ## End(Not run)
## Not run: validcpars() # all valid cpars validcpars("Obs", FALSE) # invalid Obs cpars ## End(Not run)
A function that relates operating model parameters and parameters of the observation model to yield (by default). A user can also specific their own utility values (Ut) which is arranged in a matrix of nsim rows and nMP columns.
VOI( MSEobj, ncomp = 6, nbins = 8, maxrow = 8, Ut = NA, Utnam = "Utility", plot = TRUE )
VOI( MSEobj, ncomp = 6, nbins = 8, maxrow = 8, Ut = NA, Utnam = "Utility", plot = TRUE )
MSEobj |
An object of class MSE |
ncomp |
Maximum number of variables to examine per MP |
nbins |
Number of percentile bins for sampled parameters of the operating model or observation model, which is used for calculating variability in utility across the sampled range of each parameter |
maxrow |
maximum number of MPs per plot |
Ut |
A matrix of user-specified utility values of nsim rows and nMPs columns |
Utnam |
The name of the utility measure for plotting |
plot |
Logical. Show the plot? |
T. Carruthers
A function that relates operating model parameters and parameters of the observation model to relative yield (yield over last 5 years of projection relative to a 'best F' scenario that maximizes yield).
VOI2(MSEobj, ncomp = 6, nbins = 4, Ut = NA, Utnam = "yield", lay = F)
VOI2(MSEobj, ncomp = 6, nbins = 4, Ut = NA, Utnam = "yield", lay = F)
MSEobj |
An object of class MSE |
ncomp |
Maximum number of observation variables to examine per MP |
nbins |
Number of bins for sampled observation variables used for calculating variability in utility across the sampled range of each parameter |
Ut |
A matrix of user-specified utility values of nsim rows and nMPs columns |
Utnam |
The name of the utility measure for plotting |
lay |
Controls whether labels are in lay terms or not |
VOI2 assumes that relative cost for each type of improvement in data is linearly related to the number of samples (e.g. nCAAobs) or square function of improved precision and bias e.g.: relative cost= 1/(newCV/oldCV)^2
T. Carruthers
A function that relates parameters of the observation model and the operating model parameters to yield.
VOIplot( MSEobj, MPs = NA, nvars = 5, nMP = 4, Par = c("Obs", "OM"), YVar = c("Y", "B"), doPlot = TRUE, incStat = FALSE, availMP = NULL, acceptMP = NULL, incNames = TRUE, labcex = 0.8, quants = c(0.05, 0.95) )
VOIplot( MSEobj, MPs = NA, nvars = 5, nMP = 4, Par = c("Obs", "OM"), YVar = c("Y", "B"), doPlot = TRUE, incStat = FALSE, availMP = NULL, acceptMP = NULL, incNames = TRUE, labcex = 0.8, quants = c(0.05, 0.95) )
MSEobj |
An object of class MSE |
MPs |
The MPs to plot. If NA it will plot the first nMP from MSEobj |
nvars |
The number of observation or operating model parameters to plot (number of columns) |
nMP |
The maximum number of MPs to plot (number of rows) |
Par |
Plot Operating Model (OM) or Observation (Obs) parameters? |
YVar |
Variable for Y-Axis: Yield (Y) or Biomass (B) (relative to BMSY) |
doPlot |
Output the plot? |
incStat |
Include a print out of statistic describing the curviness of the line? |
availMP |
Optional character string of MPs that are available. These names are colored black |
acceptMP |
Optional character string of MPs that are acceptable. These names are colored green if they are also in availMP |
incNames |
Include the names? |
labcex |
Character size of the label |
quants |
Quantiles to calculate |
A list of all the information included in the plot
A. Hordyk
Takes a fitted SAM model and samples historical population and fishing dynamics from the MLE fit and variance-covariance matrix. Maturity-at-age-year, Mortality-at-age-year and weight-at-age-year are identical among simulations and are a direct copy of the matrices in the WHAM fitting object.
WHAM2OM( obj, nsim = 3, proyears = 30, interval = 2, Name = NULL, WLa = 1, WLb = 3, WAAind = 1, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, nyr_par_mu = 3, LowerTri = 2, plusgroup = T, altinit = 0, fixq1 = T, report = FALSE, silent = FALSE, ... )
WHAM2OM( obj, nsim = 3, proyears = 30, interval = 2, Name = NULL, WLa = 1, WLb = 3, WAAind = 1, Obs = MSEtool::Imprecise_Unbiased, Imp = MSEtool::Perfect_Imp, nyr_par_mu = 3, LowerTri = 2, plusgroup = T, altinit = 0, fixq1 = T, report = FALSE, silent = FALSE, ... )
obj |
a SAM output object |
nsim |
Positive integer. The number of simulations. |
proyears |
Positive integer. The number of projection years for MSE. |
interval |
Positive integer. The interval at which management procedures will update the management advice in runMSE, e.g., 1 = annual updates. |
Name |
Character string. The name of the operating model. |
WLa |
positive real number or array |
WLb |
positive real number or array |
WAAind |
positive integer. The index of the WHAM weight-at-age array input$data$waa to be assumed as the weight-at-age for the operating model |
Obs |
The observation model (class Obs). This function only updates the catch and index observation error. |
Imp |
The implementation model (class Imp). This function does not update implementation parameters. |
nyr_par_mu |
Positive integer. The number of recent years that natural mortality, age vulnerability, weight, length and maturity parameters are averaged over for defining future projection conditions. |
LowerTri |
Integer. The number of recent years for which model estimates of recruitment are ignored (not reliably estimated by the assessment) |
plusgroup |
Logical. Does the assessment assume that the oldest age class is a plusgroup? |
altinit |
Integer. Various assumptions for how to set up the initial numbers. 0: standard, 1: no plus group, 2: temporary fix for MSEtool plus group initialization |
fixq1 |
Logical. Should q be fixed (ie assume the F-at-age array faa is accurate? |
report |
Logical, if TRUE, a diagnostic will be reported showing the matching of the OM reconstructed numbers at age vs the assessment. |
silent |
Whether to silence messages to the console. |
... |
Additional arguments, including R0 (unfished recruitment), phi0 (unfished spawners per recruit associated with R0 and h for calculating stock recruit parameters), |
Use a seed for the random number generator to sample future recruitment.
An object of class OM.
T. Carruthers
A worm plot for plotting the likelihood of meeting biomass targets in future years.
wormplot(MSEobj, Bref = 0.5, LB = 0.25, UB = 0.75)
wormplot(MSEobj, Bref = 0.5, LB = 0.25, UB = 0.75)
MSEobj |
Object of class MSE, output of the runMSE function |
Bref |
The reference fraction of BMSY (to evaluate the probability of exceeding this level) |
LB |
The lower bound probability that separates red (bad) and yellow (O.K.) colored segments |
UB |
The upper bound probability that separates yellow (O.K.) and green (good) colored segments |
Returns a matrix of nMPs rows and proyears columns which is the fraction of simulations for which biomass was above Bref.
T. Carruthers
Used internally in the DLMtool package to write CSV files from an existing DLMtool object
writeCSV( inobj, tmpfile = NULL, objtype = c("Stock", "Fleet", "Obs", "Imp", "Data", "OM") )
writeCSV( inobj, tmpfile = NULL, objtype = c("Stock", "Fleet", "Obs", "Imp", "Data", "OM") )
inobj |
A object of class Stock, Fleet, Obs, Imp, Data, or OM |
tmpfile |
The full file path and name for the saved CSV file |
objtype |
The class corresonding to the |
A. Hordyk
Import a Data object from Excel file
XL2Data(name, dec = c(".", ","), sheet = 1, silent = FALSE)
XL2Data(name, dec = c(".", ","), sheet = 1, silent = FALSE)
name |
Name of the data file, with or without file extension. Include full file path if not in working directory |
dec |
the character used in the file for decimal points. |
sheet |
Sheet number if importing Data from XL file |
silent |
Logical. Hide messages? |
An object of class 'Data'
A. Hordyk
## Not run: MyData <- XL2Data("MyData.xlsx") ## End(Not run)
## Not run: MyData <- XL2Data("MyData.xlsx") ## End(Not run)
Imports a Fleet Object from a correctly formatted Excel file.
XL2Fleet(name = NULL, cpars = NULL, msg = TRUE)
XL2Fleet(name = NULL, cpars = NULL, msg = TRUE)
name |
Name of the OM Excel file. Provide full file path if not in current directory. |
cpars |
An optional list of custom parameters (single parameters are a vector nsim long, time series are a matrix nsim rows by nyears columns) |
msg |
Should messages be printed? |
An error message will alert if any slots are missing values, or if the Excel file is missing the required tabs.
An object of class Fleet
A. Hordyk
Imports an OM from a correctly formatted Excel file. Create the Excel spreadsheet template
using OMinit
and document each slot in the corresponding text file.
XL2OM(name = NULL, cpars = NULL, msg = TRUE)
XL2OM(name = NULL, cpars = NULL, msg = TRUE)
name |
Name of the OM Excel file. Provide full file path if not in current directory. |
cpars |
An optional list of custom parameters (single parameters are a vector nsim long, time series are a matrix nsim rows by nyears columns) |
msg |
Should messages be printed? |
An error message will alert if any slots are missing values, or if the Excel file is missing the required tabs.
An object of class OM
A. Hordyk
## Not run: OMinit('myOM', templates=list(Stock='Herring', Fleet='Generic_Fleet', Obs='Generic_Obs', Imp='Perfect_Imp'), overwrite=TRUE) myOM <- XL2OM('myOM.xlsx') ## End(Not run)
## Not run: OMinit('myOM', templates=list(Stock='Herring', Fleet='Generic_Fleet', Obs='Generic_Obs', Imp='Perfect_Imp'), overwrite=TRUE) myOM <- XL2OM('myOM.xlsx') ## End(Not run)
Imports a Stock Object from a correctly formatted Excel file.
XL2Stock(name = NULL, cpars = NULL, msg = TRUE)
XL2Stock(name = NULL, cpars = NULL, msg = TRUE)
name |
Name of the OM Excel file. Provide full file path if not in current directory. |
cpars |
An optional list of custom parameters (single parameters are a vector nsim long, time series are a matrix nsim rows by nyears columns) |
msg |
Should messages be printed? |
An error message will alert if any slots are missing values, or if the Excel file is missing the required tabs.
An object of class Stock
A. Hordyk