
Encounter rate by food source in a mizerReef model
Source:R/reef-rates.R
getEncounterByPrey.mizerReef.RdExtends mizer::getEncounterByPrey() with the predation refuge, so that
the encounter rate is split between food sources the way mizerReef
computes it when it projects the model. Predators blocked by refuge
(blocked_pred = TRUE) only encounter the prey that are not hidden in
refuge, getVulnerable() * n, as in the model's encounter rate. Summed
over food sources, the result equals getEncounter(), unless another
extension or a custom rate function changes the encounter rate.
Usage
# S3 method for class 'mizerReef'
getEncounterByPrey(
params,
n = initialN(params),
n_pp = initialNResource(params),
n_other = initialNOther(params),
t = 0,
...
)Arguments
- params
A
mizerReefparams object.- n
A matrix of species abundances (species x size). Defaults to the initial abundances.
- n_pp
A vector of the resource abundance by size. Defaults to the initial resource abundance.
- n_other
A list of abundances for other dynamical components, such as algae and detritus. Defaults to the initial values.
- t
The time (a single year) at which the refuge is calculated. It matters when refuge degradation is switched on (see
setDegradation()). Give the time ast: atime_rangeargument is an error, as ingetDiet.mizerReef(), rather than being ignored.- ...
Passed on to
mizer::getEncounterByPrey().
Value
An array (predator species x predator size x food source), as
returned by mizer::getEncounterByPrey().
Details
You would not usually call this function yourself. mizer's
getDiet(), plotDiet() and getTrophicLevel() use it to work out how
much each food source contributes, so with this method their diets
include the refuge: blocked predators eat only prey outside refuge.
Predators that are not blocked by refuge encounter the whole prey population, as in mizer. For blocked predators, every food source is evaluated with the prey outside refuge, including other components whose encounter depends on the fish abundances, as in the model.
Examples
params <- caribbean_3_model
by_prey <- getEncounterByPrey(params)
# Summed over food sources, this is the model's encounter rate
all.equal(rowSums(by_prey, dims = 2), unclass(getEncounter(params)),
check.attributes = FALSE)
#> [1] TRUE
# getDiet() uses it, so the diet includes the refuge
diet <- getDiet(params)
diet["predators", 100, ]
#> predators herbivores inverts Resource External algae
#> 0.269659326 0.002969802 0.724195652 0.003175220 0.000000000 0.000000000
#> detritus
#> 0.000000000