The predation kernel determines the distribution of prey sizes that a
predator feeds on. It is used in getEncounter
when calculating
the rate at which food is encountered and in getPredRate
when
calculating the rate at which a prey is predated upon. The predation kernel
can be a function of the predator/prey size ratio or it can be a function of
the predator size and the prey size separately. Both types can be set up with
this function.
setPredKernel(params, pred_kernel = NULL)
params | A MizerParams object |
---|---|
pred_kernel | Optional. An array (species x predator size x prey size) that holds the predation coefficient of each predator at size on each prey size. If not supplied, a default is set as described in section "Setting predation kernel". |
A MizerParams object
Kernel dependent on predator to prey size ratio
If the pred_kernel
argument is not supplied, then this function sets a
predation kernel that depends only on the ratio of predator mass to prey
mass, not on the two masses independently. The shape of that kernel is then
determined by the pred_kernel_type
column in species_params.
The default pred_kernel_type is "lognormal". This will call the function
lognormal_pred_kernel
to calculate the predation kernel.
An alternative pred_kernel type is "box", implemented by the functions
box_pred_kernel
. These functions require certain species
parameters in the species_params data frame. For the lognormal kernel these
are beta
and sigma
, for the box kernel they are
ppmr_min
and ppmr_max
. They are explained in the help pages
for the kernel functions. No defaults are set for these parameters. If they
are missing from the species_params data frame then mizer will issue an
error message.
You can use any other string as the type. If for example you choose "my" then
you need to define a function my_pred_kernel
that you can model on the
existing functions like lognormal_pred_kernel
.
When using a kernel that depends on the predator/prey size ratio only, mizer
does not need to store the entire three dimensional array in the MizerParams
object. Such an array can be very big when there is a large number of size
bins. Instead, mizer only needs to store two two-dimensional arrays that hold
Fourier transforms of the feeding kernel function that allow the encounter
rate and the predation rate to be calculated very efficiently. However, if
you need the full three-dimensional array you can calculate it with the
getPredKernel
function.
Kernel dependent on both predator and prey size
If you want to work with a feeding kernel that depends on predator mass and prey mass independently, you can specify the full feeding kernel as a three-dimensional array (predator species x predator size x prey size). The dimensions are thus (no_sp, no_w, no_w_full).
You should use this option only if a kernel dependent only on the predator/prey mass ratio is not appropriate. Using a kernel dependent on predator/prey mass ratio only allows mizer to use fast Fourier transform methods to significantly reduce the running time of simulations.
The order of the predator species in pred_kernel
should be the same
as the order in the species params dataframe in the `params` object. If you
supply a named array then the function will check the order and warn if it is
different.
Other functions for setting parameters:
setBMort()
,
setFishing()
,
setInitial()
,
setIntakeMax()
,
setInteraction()
,
setMetab()
,
setParams()
,
setPlankton()
,
setReproduction()
,
setSearchVolume()
if (FALSE) { ## Set up a MizerParams object data(NS_species_params_gears) data(inter) params <- newMultispeciesParams(NS_species_params_gears, inter) ## If you change predation kernel parameters after setting up a model, you # need to call setPredKernel params@species_params["Cod", "beta"] <- 200 params <- setPredKernel(params) ## You can change to a different predation kernel type params@species_params$pred_kernel_type <- "box" params@species_params$ppmr_min <- 2 params@species_params$ppmr_max <- 4 params <- setPredKernel(params) ## If you need a kernel that depends also on prey size you need to define # it yourself. pred_kernel <- getPredKernel(params) pred_kernel["Herring", , ] <- sweep(pred_kernel["Herring", , ], 2, params@w_full, "*") params<- setPredKernel(params, pred_kernel = pred_kernel) }