This is the master function for running metafolio
simulations. It runs a single iteration of a simulation.
The arguments can be manipulated with other functions in
the package to use this function as part of a portfolio
analysis.
Rate that straying
(exponentially) decays with distance.
stray_fraction
Fraction of fish that stray from
natal streams.
b
Ricker density-dependent parameter. A vector
with one numeric value per population.
spawners_0
A vector of spawner abundances at the
start of the simulation. Length of the vector should
equal the number of populations.
sigma_v
Stock-recruit residual standard deviation
of the log-deviations.
v_rho
AR1 serial correlation of stock-recruit
residuals.
a_width_param
Width of the thermal curves by
population.
optim_temp
Optimal temperatures by population.
max_a
Maximum Ricker productivity parameters (a)
by population. The value obtained at the optimum
temperature. Note how the default argument uses the
thermal_integration function.
env_type
The type of environmental time series to
generate. One of "sine", "arma",
"regime", "linear", or "constant".
See generate_env_ts.
env_params
Parameters to pass on to
generate_env_ts. You must provide the
appropriate list given your chosen type of environmental
signal.
start_assessment
Generation to start estimating
the stock recruit relationship for escapement targets.
The assessment is carried out using
fit_ricker.
a_lim
A vector of length two giving the lower and
upper limits for Ricker a values. If a value is estimated
beyond these limits it will be set to the limit value.
b_lim
A vector of length two giving the lower and
upper limits for the estimated Ricker b values *as
fractions* of the previously assessed value. If a value
is estimated beyond these limits it will be set to the
limit value.
silence_warnings
Should the warnings be skipped if
the Ricker a or b values exceed their specified bounds?
meta_sim will still print other warnings
regardless of this argument value.
sigma_impl
Implementation standard deviation for
the implementation error beta distribution.
assess_freq
How many generations before
re-assessing Ricker a and b parameters.
use_cache
Use the stochastically generated values
(stock-recruit residuals and possibly environmental time
series) from the previous run? See the Details section
below.
cache_env
Logical: Should the environmental time
series be cached? If use_cache = TRUE then this
will automatically happen. But, you could set
cache_env = TRUE and use_cache = FALSE to
only cache the environmental time series. See the Details
section below.
add_straying
Implement straying between
populations?
add_impl_error
Add implementation error?
Implementation error is derived using
impl_error.
decrease_b
A numeric value to decrease all streams
by each generation. This is intended to be used to
simulate habitat loss, for example though stream flow
reduction with climate change.
skip_saving_cache
Logical: if TRUE then no
data will be cached for the next iteration. This will
save time when running many simulations.
debug
Logical: if TRUE then meta_sim
will print a number of debugging statements while it
runs.
Details
To use either of the caching options, you must have run
meta_sim at least once in the current session with
both caching arguments set to FALSE to generate the
cached values first. If you're running many iterations of
meta_sim and you want to cache, then the first
iteration should have both cache arguments set to
FALSE, and subsequent runs can set one or both to
TRUE. Internally, meta_sim caches by writing
the appropriate data to an .rda file in a temporary
directory.
Value
A list is returned that contains the following elements.
All matrices that are returned (except the straying matrix)
feature populations along the columns and generations/years
along the rows.
A
A matrix of
abundances.
F
A matrix of fishing mortality
in numbers.
E
A matrix of realized
escapement.
Eps
A matrix of (log)
spawner-return residuals. These have been log-normal bias
corrected so their expected value after exponentiation will
be one.
A_params
A matrix of actual Ricker a
parameters.
Strays_leaving
A matrix of
strays leaving.
Strays_joining
A matrix of
strays joining.
env_ts
A vector of the
environmental time series.
stray_mat
The
straying matrix. These fractions are constant across
generations/years. Rows and columns are populations.
n_pop
The total possible populations as input
in the simulation.
n_t
The number of
generations/years the simulation was run for.