These functions allow you to get or set the species-specific parameters stored in a MizerParams object.
Usage
species_params(object, ...)
species_params(object, recalculate = TRUE) <- value
is.species_params(x)
given_species_params(object, ...)
is.given_species_params(x)
given_species_params(object) <- value
calculated_species_params(params)Arguments
- object
A MizerParams object, a MizerSim object or a data frame
- ...
Other arguments passed to methods.
- recalculate
Whether
species_params<-()should re-derive the calculated species parameters and recalculate all the rates that depend on the species parameters. Defaults toTRUE. See the section "Setting species parameters without recalculation" below before setting it toFALSE.- value
A data frame with the new species parameters.
- x
An object to test with
is.species_params()oris.given_species_params().- params
A MizerParams object.
Value
species_params(): Data frame containing all species parameters
currently stored in the model.
species_params<-(): Updates the given_species_params with any
parameters you have changed, and then recalculates the full species
parameter table and the model parameters. With recalculate = FALSE it
only does the recording and stores the parameters you supplied, see the
section "Setting species parameters without recalculation" below.
given_species_params(): Data frame containing the species parameter
values that were supplied explicitly by the user.
given_species_params<-(): An alternative to species_params<-() that
also triggers a recalculation of other parameters. The only difference is
that given_species_params<-() issues warnings when a parameter is
changed whose effect is overridden by another parameter that has already
been given. This is especially useful during interactive use.
calculated_species_params(): Data frame containing only those species
parameter entries that are not explicit user input. Columns that would
consist entirely of NA values are dropped.
is.species_params() returns TRUE if x is a species_params
object, FALSE otherwise.
is.given_species_params() returns TRUE if x is a
given_species_params object, FALSE otherwise.
Details
There are a lot of species parameters and we will list them all below, but
most of them have sensible default values. The only required columns are
species for the species name and w_inf for its von Bertalanffy
asymptotic size. However if you have information about the values of other
parameters then you should provide them.
Three species parameters describe maximum sizes and play distinct roles:
w_infis the von Bertalanffy asymptotic size of an average individual. It is the required maximum-size parameter and is used to set default values forw_max,w_repro_maxandw_mat.w_repro_maxis the size at which a typical mature individual invests all of its available energy into reproduction, seesetReproduction(). It is not a hard ceiling on size and defaults tow_inf.w_maxis purely a computational boundary: it sets the upper end of the size grid and the range of plots. It defaults to1.5 * w_inf. For backwards compatibility, ifw_infis not supplied it is taken fromw_repro_maxorw_maxinstead.
Mizer distinguishes between the species parameters that you have given
explicitly and the species parameters that have been calculated by mizer or
set to default values. You can retrieve the given species parameters with
given_species_params() and the calculated ones with
calculated_species_params(). You get all species_params with
species_params().
When you change species parameters with species_params<-(), mizer
automatically detects which parameters you have changed. It records these
changed parameters in given_species_params so that they are protected
against being overwritten by future recalculations. It then triggers a
re-calculation of the calculated species parameters.
There are some species parameters that are used to set up the size-dependent parameters that are used in the mizer model:
gammaandqare used to set the search volume, seesetSearchVolume().handnare used to set the maximum intake rate, seesetMaxIntakeRate().k,ksandpare used to set activity and basic metabolic rate, seesetMetabolicRate().z0,z_extanddare used to set the external mortality rate, seesetExtMort().E_extandnare used to set the external encounter rate, seesetExtEncounter().D_extandnare used to set the external diffusion rate, seesetExtDiffusion().w_mat,w_mat25,w_repro_maxandmare used to set the allocation to reproduction, seesetReproduction().pred_kernel_typespecifies the shape of the predation kernel. The default is a "lognormal", for other options see the "Setting predation kernel" section in the help forsetPredKernel().betaandsigmaare parameters of the lognormal predation kernel, seelognormal_pred_kernel(). There will be other parameters if you are using other predation kernel functions.
When you change one of the above species parameters using
species_params<-() or given_species_params<-(), the new value will be
used to update the corresponding size-dependent rates automatically, unless
you have set those size-dependent rates manually, in which case the
corresponding species parameters will be ignored.
There are some species parameters that are used directly in the model rather than being used for setting up size-dependent parameters:
alphais the assimilation efficiency, the proportion of the consumed biomass that can be used for growth, metabolism and reproduction, see the help forgetEReproAndGrowth().w_minis the egg size.interaction_resourcesets the interaction strength with the resource, see "Predation encounter" section in the help forgetEncounter().ereprois the reproductive efficiency, the proportion of the energy invested into reproduction that is converted to egg biomass, seegetRDI().R_maxis the parameter in the Beverton-Holt density dependence added to the reproduction, seesetBevertonHolt(). There will be other such parameters if you use other density dependence functions, see the "Density dependence" section in the help forsetReproduction().
Two parameters are used only by functions that need to convert between weight and length:
aandbare the parameters in the allometric weight-length relationship \(w = a l ^ b\).
If you have supplied the a and b parameters, then you can replace weight
parameters like w_inf, w_max, w_mat, w_mat25, w_repro_max and
w_min by their corresponding length parameters l_inf, l_max, l_mat,
l_mat25, l_repro_max and l_min.
You can also keep both, and change either of them later. Mizer keeps the two
consistent by the rule that the one you gave last wins, and if you gave both
at the same time the weight wins. So on a model set up with lengths you can
still set w_mat with species_params<-() and mizer will update l_mat to
match, and if you set l_mat it will update w_mat as always. When you
supply a length and a weight together that do not agree, mizer uses the
weight and warns you that it has changed the length to match.
The rule is applied when a species parameter data frame is put into a model.
A data frame that you have taken out of a model and are editing on its own
is left exactly as you write it: no conversions, no checks and no warnings
until you assign it back with species_params<-(), which is when mizer can
tell which values you changed. A data frame that was never in a model, for
example one you pass to validSpeciesParams(), carries no such history, so
a length and a weight that disagree there count as given at the same time
and the weight wins.
The parameters that are only used to calculate default values for other parameters are:
f0is the feeding level and is used to get a default value for the coefficient of the search volumegamma, seeget_gamma_default().fcis the critical feeding level below which the species can not maintain itself. This is used to get a default value for the coefficientksof the metabolic rate, seeget_ks_default().age_matis the age at maturity and is used to get a default value for the coefficienthof the maximum intake rate, seeget_h_default().If
age_matis not supplied, mizer used the von Bertalanffy parametersk_vb,w_infandt0as well as the weight-length exponentbto determine it. This is unreliable and is therefore not recommended.
Changing these parameters with species_params<-() will trigger a
recalculation of the downstream parameters, provided they are not protected
by being explicitly given.
There are other species parameters that are used in tuning the model to observations:
biomass_observedandbiomass_cutoffallow you to specify for each species the total observed biomass above some cutoff size. This is used bycalibrateBiomass()andmatchBiomasses().yield_observedallows you to specify for each species the total annual fisheries yield. This is used bycalibrateYield()andmatchYields().
Finally there are two species parameters that control the way the species are represented in plots:
linecolourspecifies the colour and can be any valid R colour value.linetypespecifies the line type ("solid", "dashed", "dotted", "dotdash", "longdash", "twodash" or "blank")
Other species-specific information that is related to how the species is
fished is specified in a gear parameter data frame, see gear_params().
However in the case where each species is caught by only a single gear,
this information can also optionally be provided as species parameters and
newMultispeciesParams() will transfer them to the gear_params data frame.
However changing these parameters later in the species parameter data frames
will have no effect.
You are allowed to include additional columns in the species parameter data frames. They will simply be ignored by mizer but will be stored in the MizerParams object, in case your own code makes use of them.
Setting species parameters without recalculation
species_params(params, recalculate = FALSE) <- value records the values you
changed among the given species parameters, so that they are not calculated
away later, and stores value as the species parameters. It then stops
there: the calculated species parameters are not re-derived from the given
ones, no missing parameters are filled in with their default values, and none
of the size-dependent rates are recalculated. Your species parameters are
stored as you supplied them, after the same checks and length-to-weight
conversions that writing into the species_params slot would trigger.
This is for code that has worked out a species parameter together with the
rate array that the parameter determines, for example an optimiser that fits
ks and the matching metab, or z_ext and the matching mu_b. There the
recalculation is not just wasted work but would overwrite the rates the
caller has just set.
The object you get back is only as consistent as you make it. Mizer will not
check that the species parameters you supplied agree with the rate arrays in
the object, nor that they agree with the other species parameters that are
normally derived from them. Unless you are setting the affected rates
yourself, use the default recalculate = TRUE.
See also
validSpeciesParams(), setParams()
Other functions for setting parameters:
gear_params(),
setExtDiffusion(),
setExtEncounter(),
setExtMort(),
setFishing(),
setInteraction(),
setMaxIntakeRate(),
setMetabolicRate(),
setParams(),
setPredKernel(),
setReproduction(),
setSearchVolume(),
use_predation_diffusion()
