| sizeIntegral | R Documentation |
\int_{w_{min}}^{w_{max}} N_i(w)\, K_i(w)\, dw
for each species i, using the quadrature scheme that the model is
actually using. This is the recommended way to write your own summary or
indicator function: it selects the size range, applies the bin-averaging
appropriate to the model's second_order_w() setting and wraps the result in
the appropriate mizer array class, so that none of those rules need to be
remembered. The built-in summary functions like getBiomass(), getN(),
getSSB() and getYield() are all implemented with it.
sizeIntegral(
object,
weighting = 1,
n = NULL,
...,
value_name = NULL,
units = NULL
)
object |
A |
weighting |
The weighting factor |
n |
The abundance density. Either a species x size matrix or a time x
species x size array. Defaults to the initial abundance |
... |
Arguments passed to |
value_name |
A string giving a human-readable name for the value, used when the result is wrapped in a mizer array class. |
units |
A string giving the units of the result, used when the result is wrapped in a mizer array class. |
The value of the integral, see the section "Shape of the result" above.
The weighting factor K(w) is supplied already evaluated on the size
grid. It can be
a single number (the default weighting = 1 integrates the abundance
density itself, giving numbers),
a vector with one value for each size bin, which is then used for all species,
a matrix (species x size), for example params@maturity,
an array with further dimensions in front, for example the gear x
species x size array returned by getFMortGear() or the time x species x
size array returned by getFMort(sim). Those extra dimensions are
carried through to the result.
If the weighting factor is a product of several size-dependent factors, pass the whole product: bin-averaging is applied to the product as a single weighting factor, which is not the same as averaging the factors separately.
Do not include the bin widths params@dw in the weighting factor and do
not bin-average it yourself; sizeIntegral() does both.
The size dimension is integrated out. The remaining dimensions are those of
n together with any extra dimensions of weighting, so
with a MizerParams object and a species x size weighting the result is
a named vector with one value per species,
with a MizerSim object it is an ArrayTimeBySpecies object (time x
species),
with a gear x species x size weighting the extra gear dimension is
kept, giving a gear x species array (or time x gear x species for a
MizerSim).
Dimensions of weighting other than the last two are matched to the dimensions
of n by the names of their dimnames, so a weighting whose first dimension is
named "time" is lined up with the times of the simulation rather than
producing an outer product.
get_size_range_array(), bin_average_weight(),
second_order_w()
# The biomass of each species, i.e. what getBiomass() does
sizeIntegral(NS_params, weighting = NS_params@w)
# ... restricted to a size range
sizeIntegral(NS_params, weighting = NS_params@w, min_w = 10, max_w = 1000)
# The numbers of individuals larger than 10g
sizeIntegral(NS_params, min_w = 10)
# Spawning stock biomass: the weighting is the product maturity * w
K <- sweep(NS_params@maturity, 2, NS_params@w, "*")
sizeIntegral(NS_params, weighting = K)
# An indicator through time, ready to plot
biomass <- sizeIntegral(NS_sim, weighting = NS_params@w,
value_name = "Biomass", units = "g")
biomass[c("1972", "2010"), c("Herring", "Cod")]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.