Stock {AMPLE} | R Documentation |
R6 Class representing a stock
Description
A stock object has life history parameters, fields and methods for a biomass dynamic model.
Details
A stock has biomass, effort, catch and hcr_ip and hcr_op fields as well as the life history parameters. The population dynamics are a simple biomass dynamic model. The Stock class is used for the Shiny apps in the AMPLE package.
Public fields
biomass
Array of biomass
catch
Array of catches
effort
Array of fishing effort
hcr_ip
Array of HCR input signals
hcr_op
Array of HCR output signals
msy
MSY (default = 100).
r
Growth rate (default = 0.6). Set by the user in the app.
k
Carrying capacity (default = NULL - set by msy and r when object is initialised).
p
Shape of the production curve (default = 1).
q
Catchability (default = 1).
lrp
Limit reference point, expressed as depletion (default = 0.2).
trp
Target reference point, expressed as depletion (default = 0.5).
b0
Virgin biomass (default = NULL - set by msy and r when object is initialised).
current_corrnoise
Stores the current values of the correlated noise (by iteration).
biol_sigma
Standard deviation of biological variability (default = 0).
last_historical_timestep
The last historical timestep of catch and effort data.
Methods
Public methods
Method new()
Create a new stock object, with fields of the right dimension and NA values (by calling the reset()
method.
See the reset()
method for more details.
Usage
Stock$new(stock_params, mp_params, niters = 1)
Arguments
stock_params
A list of stock parameters with essential elements: r (growth rate, numeric), stock_history (string: "fully", "over", "under") initial_year (integer), last_historical_timestep (integer), nyears (integer), biol_sigma (numeric).
mp_params
A list of the MP parameters. Used to fill HCR ip and op.
niters
The number of iters in the stock (default = 1).
Returns
A new Stock object.
Method reset()
Resets an existing stock object, by remaking all fields (possibly with different dimensions for the array fields) .
Fills up the catch, effort and biomass fields in the historical period based on the stock history and
life history parameters in the stock_params
argument.
This is a reactive method which invalidates a reactive instance of this class after it is called.
Usage
Stock$reset(stock_params, mp_params, niters)
Arguments
stock_params
A list with essential elements: r (growth rate, numeric, default=6), stock_history (string: "fully", "over", "under", default="fully") initial_year (integer, default=2000), last_historical_timestep (integer, default=10), nyears (integer, default=30), biol_sigma (numeric, default = 0).
mp_params
A list of the MP parameters. Used to fill HCR ip and op.
niters
The number of iters in the stock (default = 1).
Returns
A new Stock object.
Method reactive()
Method to create a reactive instance of a Stock.
Usage
Stock$reactive()
Returns
a reactiveExpr.
Method fill_history()
Fills the historical period of the stock
Usage
Stock$fill_history(stock_params, mp_params)
Arguments
stock_params
Named list with last_historical_timestep and stock_history elements.
mp_params
A list of the MP parameters. Used to fill HCR ip and op.
Method fill_catch_history()
Fill up the historical period of catches with random values to simulate a catch history
Usage
Stock$fill_catch_history(stock_params)
Arguments
stock_params
A list with essential elements: r (growth rate, numeric), stock_history (string: "fully", "over", "under") initial_year (integer), last_historical_timestep (integer), nyears (integer).
stock_history
Character string of the exploitation history (default = "fully", alternatives are "under" or "over").
Method fill_biomass()
Fills the biomass in the next timestep based on current biomass and catches
The surplus production model has the general form:
Bt+1 = Bt + f(Bt) - Ct
Where the production function f() is a Pella & Tomlinson model with shape
f(Bt) = r/p Bt * (1 - (Bt/k)^p)
Here p is fixed at 1 to give a Schaefer model
cpue = Ct / Et = qBt
Usage
Stock$fill_biomass(ts, iters = 1:dim(self$biomass)[1])
Arguments
ts
The biomass time step to be filled (required catch etc in ts - 1).
iters
The iterations to calculate the biomass for (optional - default is all of them).
Method as_data_frame()
Produces a data.frame of some of the array-based fields, like biomass. Just used for testing purposes.
Usage
Stock$as_data_frame()
Method project()
Projects the stock over the time steps given and updates the biomass, HCR ip / op and catches It uses a simple biomass dynamic model where the catches or fishing effort are set every time step by the harvest control rule.
Usage
Stock$project(timesteps, mp_params, iters = 1:dim(self$biomass)[1])
Arguments
timesteps
The timesteps to project over. A vector of length 2 (start and end).
mp_params
A vector of management procedure parameters.
iters
A vector of iterations to be projected. Default is all the iterations in the stock
Returns
A stock object (a reactiveValues object with bits for the stock)
Method relative_cpue()
The catch per unit effort (CPUE, or catch rate) relative to the CPUE in the last historical period.
Usage
Stock$relative_cpue()
Returns
An array of same dims as the catch and effort fields.
Method relative_effort()
The effort relative to the effort in the last historical period.
Usage
Stock$relative_effort()
Returns
An array of same dims as the effort field.
Method replicate_table()
Summarises the final year of each iteration. Only used for the Measuring Performance app.
Usage
Stock$replicate_table(iters = 1, quantiles = c(0.05, 0.95))
Arguments
iters
The iterations to calculate the table values for (default is iteration 1).
quantiles
Numeric vector of the quantile range. Default values are 0.05 and 0.95.
Method time_periods()
Calculates the short, medium and long term periods to calculate the performance indicators over, based on the last historic year of data and the number of years in the projection.
Usage
Stock$time_periods()
Method performance_indicators()
Gets the performance indicators across all indicators, for three time periods. Used in the Measuring Performance and Comparing Performance apps.
Usage
Stock$performance_indicators( iters = 1:dim(self$biomass)[1], quantiles = c(0.05, 0.95) )
Arguments
iters
The iterations to calculate the table values for (default is all of them).
quantiles
Numeric vector of the quantile range. Default values are 0.05 and 0.95.
Returns
A data.frame
Method pi_table()
Makes a table of the performance indicators.
Usage
Stock$pi_table(iters = 1:dim(self$biomass)[1], quantiles = c(0.05, 0.95))
Arguments
iters
The iterations to calculate the table values for (default is all of them).
quantiles
Numeric vector, length 2, of the low and high quantiles.
Method clone()
The objects of this class are cloneable with this method.
Usage
Stock$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.