Build Status local release CRAN Status CRAN Downloads License-blue.svg)

knitr::opts_chunk$set(eval = TRUE) # set to FALSE locally if you don't want to build when developing

msy

The msy R package is a collection of methods to estimate equilibrium reference points for fish stocks

Contact

You are welcome to:

Preamble

This document is as much as the msy-package itself a living document.

The origin of this package is from an intial coding by John Simmonds which was restructured by Colin Millar into an R-package with additional development, including coding the Buckland method. Einar Hjörleifsson compartmentalized the structure of the code as well as providing the output of the analysis in a more structured format. Further contributions have been made by Carmen Fernandez, Max Cardinale, Martin Pastoors and Niels Hintzen.

The package is currently being maintianed by the ICES secretariat.

Installation

The developmental repository for the msy package is located on github, more specifically on github.com/ices-tools-prod/msy

The easiest way to install the msy package is to use the function install_github in the devtools package. Since the input into the msy is in the form of a FLStock object it is advised to obtain the latest release of FLCore from the same site.

The Rtools.exe software is needed for building packages under Microsoft Windows.

Run the following lines to install the latest versions of msy and FLCore.

# install.packages("devtools")
install.packages("FLCore", repo = "http://flr-project.org/R")
library(devtools)
install_github("ices-tools-prod/msy")
devtools::install("D:/projects/git/ices-tools-prod/msy", quiet = TRUE)
set.seed(305934095)

The above is equivalent to install.packages and hence need only to be performed once. However, since the msy package is currently under development (including bug-fixing) one may expect more frequent code updating in the package than what one may be familiar with for packages on CRAN. Once installed the msy packages is simply loaded via the familiar:

library(msy)

Besides functions the package comes with the following data:

These are all stored in the icesStocks list object.

The current version of the msy implements two methods that go under the working names eqsim and plotMSY. Only usage of functions for the eqsim approaches are described in the following sections.

eqsim

eqsim is a stochastic equilibrium software that may be used to explore MSY reference points. Productivity parameters (i.e. year vectors for natural mortality, weights-at-age and maturities) as well as selection are re-sampled at random from user specified range of years from the assessment. Fixing these parameters to an average over specified years can also be set by the user. Recruitments are re-sampled from their predictive distribution. Uncertainty in the stock-recruitment model is taken into account by applying model averaging using smooth AIC weights (Buckland et al. 1997). In addition assessment errors can be emulated by applying a user-specified error (CV and autocorrelation) to the intended target fishing mortality.

The current version of eqsim only takes FLStock objects as inputs.

A quick start

In the following subsections we will simulate the north sea cod stock into the future under some basic assumptions. For the simulations we need to choose which years we will use to generate noise in the quantities: weight at age, maturity at age, natural mortality at age, and selection pattern. We also need to choose a set of Fbar values to simulate over in order estimate F reference points.

The eqsim approach consists of three components:

  1. Estimate the stock recruitment relationship
  2. Simulate a stock to equilibrium and continue simulating for some years
  3. Calculate reference points from the simulated stock at equilibrium (last 50 years of the runs are used)

This can be done in one go with the following code:

FIT <- eqsr_fit(icesStocks$saiNS,
  nsamp = 1000,
  models = c("Ricker", "Segreg")
)
SIM <- eqsim_run(FIT,
  bio.years = c(2004, 2013),
  sel.years = c(2004, 2013),
  Fcv = 0.24,
  Fphi = 0.42,
  Blim = 106000,
  Bpa = 200000,
  Fscan = seq(0, 1.2, len = 40),
  verbose = FALSE
)

The stock recruitment function can be plotted by:

eqsr_plot(FIT,n=2e4)

Summary of the key results can be obtained by:

SIM$Refs

Summary plots conditioned on maximizing catch are obtained by:

eqsim_plot(SIM,catch=TRUE)

Summary plots of Fmsy range (WKMSYREF3) are obtained by:

eqsim_plot_range(SIM, type="mean")
eqsim_plot_range(SIM, type="median")
eqsim_plot_range(SIM, type="ssb")

The recruitment model

Model fitting is done by maximum likelihood using the nlminb optimiser in R. By refitting to non-parametric bootstrap resamples of the stock and recruit pairs, samples from the approximate joint distribution of the model parameters can be made. This is done by invoking the eqrs_fit function. The function first sets up the stock and recruit pairs based on the information in the FLStock object and removes any incomplete pairs, before dispatching on the model fitting / averaging algorithm chosen. Currently only a bootstrap based model averaging method called smooth AIC is implemented fully. The details can be found in eqrs_Buckland function. The algorithm implemented is:

  1. Take a resample with replacement from the stock and recruit pairs
  2. Fit every stock-recruit model under consideration and store the AIC of each
  3. Retain the parameter estimates from the best model
  4. Repeat

This process provides a robust way to average over several models, as long as the bootstrap resampling procedure provides an adequate approximation to the empirical distribution of the stock and recruit pairs.

The arguments to the fitting function are

args(eqsr_fit)

Here:

The results from the fitting process are returned to the user as a list:

str(FIT, 2, give.attr=FALSE)

where:

The contribution of each of the models can be obtained by printing out the sr.det:

FIT$sr.det

Here the a, b and cv are the estimated parameters from the deterministic fit for each model. The n and prop is a summary of the number and proportion that each model contributes to the final fit.

Again to obtain a plot one simply calls:

eqsr_plot(FIT,n=2e4)

The n supplied to the eqsr_plot stands here for the number of stochastic recruitment points desired to include in the plot. The various black dashed lines represent the best fit of the different recruitment models and the yellow and blue lines the median and 5% and 95% percentiles of the distributions of the stochastic recruits drawn from the models. The input data are represented by red points.

An alternative to the base plot is a ggplot2 version (with too many fancy colours :-):

eqsr_plot(FIT,n=2e4,ggPlot=TRUE,Scale=1e3)

Here the model fits are represented in different colours with the yellow lines indicating the 5%, 50% and 95% percentiles of the stochastic recruitment distribution. The input data are represented by text indicating year class. The weight of each model in the final stochastic recruitment draw is indicated as a proportion in the legends and by different colours for the stochastic draws.

The simulation

Simulating forward is done using the eqsim_run function. The function takes as input the output from the eqsr_fit function. Simulations are run independently for each sample from the distribution of model and parameters. This is done for a range of $F_{advisory}$ values. For example if we scanned over 10 values of $F_{advisory}$ and had taken 2000 samples from the stock-recruit relationship then 20000 simulations would be run in total. These simulations are run for 200 years (default, specified with Nrun), and the last 50 years are retained to calculate summaries, like the proportion of times the stock crashes at a given $F_{advisory}$. It is important to note that each simulation is conditioned on a single stock recruit relationship with fixed parameters and cv.

Error is introduced within the simulations by generating process error about the constant stock-recruit fit, and by using variation in maturity, natural mortality, weight at age and selection estimates. Note that if there is no variability in these quantities in the stock object then no variability will be taken in to the simulations. The user can also specify using average values for these parameters.

The arguments to the simulation function are:

args(eqsim_run)

where:

The results from the simulation process are returned to the user as a list

str(SIM, 2, give.attr = FALSE)

where

The calculation associated with the $F_{msy}$ range values can be accessed simply by:

t(SIM$refs_interval)


ices-tools-prod/msy documentation built on Nov. 3, 2022, 6:41 p.m.