Skip to contents

Returns the rate at which a predator of species \(i\) and weight \(w\) encounters food (grams/year).

Usage

getEncounter(
  params,
  n = initialN(params),
  n_pp = initialNResource(params),
  n_other = initialNOther(params),
  t = 0,
  ...
)

Arguments

params

A MizerParams object

n

A matrix of species abundances (species x size).

n_pp

A vector of the resource abundance by size

n_other

A list of abundances for other dynamical components of the ecosystem

t

The time for which to do the calculation (Not used by standard mizer rate functions but useful for extensions with time-dependent parameters.)

...

Unused

Value

An ArraySpeciesBySize object (predator species x predator size) with the encounter rates.

Predation encounter

The encounter rate \(E_i(w)\) at which a predator of species \(i\) and weight \(w\) encounters food has contributions from the encounter of fish prey and of resource. This is determined by summing over all prey species and the resource spectrum and then integrating over all prey sizes \(w_p\), weighted by predation kernel \(\phi(w,w_p)\): $$ E_i(w) = \gamma_i(w) \int \left( \theta_{ip} N_R(w_p) + \sum_{j} \theta_{ij} N_j(w_p) \right) \phi_i(w,w_p) w_p \, dw_p. $$ Here \(N_j(w)\) is the abundance density of species \(j\) and \(N_R(w)\) is the abundance density of resource. The overall prefactor \(\gamma_i(w)\) determines the predation power of the predator. It could be interpreted as a search volume and is set with the setSearchVolume() function. The predation kernel \(\phi(w,w_p)\) is set with the setPredKernel() function. The species interaction matrix \(\theta_{ij}\) is set with setInteraction() and the resource interaction vector \(\theta_{ip}\) is taken from the interaction_resource column in params@species_params.

Details

The encounter rate is multiplied by \(1-f_0\) to obtain the consumption rate, where \(f_0\) is the feeding level calculated with getFeedingLevel(). This is used by the project() function for performing simulations.

The function returns values also for sizes outside the size-range of the species. These values should not be used, as they are meaningless.

If your model contains additional components that you added with setComponent() and for which you specified an encounter_fun function then the encounters of these components will be included in the returned value.

Extension hook

projectEncounter() is the S3 generic used by extension-aware projections. Extension packages can add methods for their marker classes and call NextMethod() to compose encounter-rate changes. The MizerParams method contains the standard mizer calculation and is also exported as mizerEncounter() for compatibility.

Your own encounter function

By default getEncounter() calls mizerEncounter() on models without extensions. However you can replace this with your own alternative encounter function. If your function is called "myEncounter" then you register it in a MizerParams object params with

params <- setRateFunction(params, "Encounter", "myEncounter")

Your function will then be called instead of mizerEncounter(), with the same arguments.

Examples

encounter <- getEncounter(NS_params)
str(encounter)
#>  'ArraySpeciesBySize' num [1:12, 1:100] 0.299 0.453 0.502 0.575 0.492 ...
#>  - attr(*, "dimnames")=List of 2
#>   ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>  - attr(*, "value_name")= chr "Encounter rate"
#>  - attr(*, "units")= chr "g/year"
#>  - attr(*, "params")=Formal class 'MizerParams' [package "mizer"] with 46 slots
#>   .. ..@ metadata               : list()
#>   .. ..@ mizer_version          :Classes 'package_version', 'numeric_version'  hidden list of 1
#>   .. .. ..$ : int [1:4] 2 5 4 9126
#>   .. ..@ extensions             : chr(0) 
#>   .. ..@ time_created           : POSIXct[1:1], format: "2021-09-03 20:29:38"
#>   .. ..@ time_modified          : POSIXct[1:1], format: "2026-05-09 08:16:12"
#>   .. ..@ w                      : num [1:100] 0.001 0.00119 0.00142 0.0017 0.00203 ...
#>   .. ..@ dw                     : num [1:100] 0.000193 0.000231 0.000275 0.000329 0.000392 ...
#>   .. ..@ w_full                 : num [1:226] 2.12e-13 2.53e-13 3.02e-13 3.61e-13 4.30e-13 ...
#>   .. ..@ dw_full                : num [1:226] 4.10e-14 4.90e-14 5.84e-14 6.97e-14 8.32e-14 ...
#>   .. ..@ w_min_idx              : Named num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..- attr(*, "names")= chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. ..@ maturity               : num [1:12, 1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ psi                    : num [1:12, 1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ initial_n              : num [1:12, 1:100] 1.84e+13 6.86e+12 1.44e+14 1.45e+13 1.71e+11 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ intake_max             : num [1:12, 1:100] 0.182 0.275 0.328 0.35 0.307 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ search_vol             : num [1:12, 1:100] 1.27e-13 6.00e-14 3.44e-13 4.49e-14 1.86e-13 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ metab                  : num [1:12, 1:100] 0.0289 0.0437 0.0522 0.0557 0.0487 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ pred_kernel            : logi [1(1d)] NA
#>   .. ..@ ft_pred_kernel_e       : cplx [1:12, 1:226] 11.3+0i 26.9+0i 20.8+0i ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ k : chr [1:226] "1" "2" "3" "4" ...
#>   .. ..@ ft_pred_kernel_p       : cplx [1:12, 1:226] 11.3+0i 26.9+0i 20.8+0i ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ k : chr [1:226] "1" "2" "3" "4" ...
#>   .. ..@ mu_b                   : num [1:12, 1:100] 0.1871 0.1817 0.1293 0.0865 0.0874 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ ext_encounter          : num [1:12, 1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ ext_diffusion          : num [1:12, 1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ sp: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ rr_pp                  : Named num [1:226] 167660 158066 149021 140494 132455 ...
#>   .. .. ..- attr(*, "names")= chr [1:226] "2.12e-13" "2.53e-13" "3.02e-13" "3.61e-13" ...
#>   .. ..@ cc_pp                  : Named num [1:226] 1.09e+38 7.46e+37 5.11e+37 3.51e+37 2.41e+37 ...
#>   .. .. ..- attr(*, "names")= chr [1:226] "2.12e-13" "2.53e-13" "3.02e-13" "3.61e-13" ...
#>   .. ..@ resource_dynamics      : chr "resource_semichemostat"
#>   .. ..@ resource_params        :List of 5
#>   .. .. ..$ kappa      : num 1e+11
#>   .. .. ..$ lambda     : num 2.13
#>   .. .. ..$ r_pp       : num 10
#>   .. .. ..$ n          : num 0.667
#>   .. .. ..$ w_pp_cutoff: num 9.82
#>   .. ..@ other_dynamics         : list()
#>   .. ..@ other_params           : list()
#>   .. ..@ other_encounter        : list()
#>   .. ..@ other_mort             : list()
#>   .. ..@ rates_funcs            :List of 14
#>   .. .. ..$ Rates          : chr "mizerRates"
#>   .. .. ..$ Encounter      : chr "mizerEncounter"
#>   .. .. ..$ FeedingLevel   : chr "mizerFeedingLevel"
#>   .. .. ..$ EReproAndGrowth: chr "mizerEReproAndGrowth"
#>   .. .. ..$ PredRate       : chr "mizerPredRate"
#>   .. .. ..$ PredMort       : chr "mizerPredMort"
#>   .. .. ..$ FMort          : chr "mizerFMort"
#>   .. .. ..$ Mort           : chr "mizerMort"
#>   .. .. ..$ ERepro         : chr "mizerERepro"
#>   .. .. ..$ EGrowth        : chr "mizerEGrowth"
#>   .. .. ..$ ResourceMort   : chr "mizerResourceMort"
#>   .. .. ..$ RDI            : chr "mizerRDI"
#>   .. .. ..$ RDD            : chr "BevertonHoltRDD"
#>   .. .. ..$ Diffusion      : chr "mizerDiffusion"
#>   .. ..@ sc                     : num [1:100] 0.001 0.00119 0.00142 0.0017 0.00203 ...
#>   .. ..@ initial_n_pp           : Named num [1:226] 1.09e+38 7.46e+37 5.11e+37 3.51e+37 2.41e+37 ...
#>   .. .. ..- attr(*, "names")= chr [1:226] "2.12e-13" "2.53e-13" "3.02e-13" "3.61e-13" ...
#>   .. ..@ initial_n_other        : list()
#>   .. ..@ species_params         :'data.frame':	12 obs. of  34 variables:
#>   .. .. ..$ species             : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. ..$ w_max               : num [1:12] 33 36 100 334 324 ...
#>   .. .. ..$ w_mat               : int [1:12] 13 4 23 99 21 75 78 39 105 165 ...
#>   .. .. ..$ beta                : int [1:12] 51076 398849 22 280540 191 22 381 283 113 558 ...
#>   .. .. ..$ sigma               : num [1:12] 0.8 1.9 1.5 3.2 1.9 1.5 1.9 1.8 1.6 2.1 ...
#>   .. .. ..$ k_vb                : num [1:12] 0.681 1 0.849 0.606 0.536 0.323 0.284 0.266 0.122 0.271 ...
#>   .. .. ..$ gear                : chr [1:12] "Industrial" "Industrial" "Industrial" "Pelagic" ...
#>   .. .. ..$ w_min               : num [1:12] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 ...
#>   .. .. ..$ alpha               : num [1:12] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 ...
#>   .. .. ..$ pred_kernel_type    : chr [1:12] "lognormal" "lognormal" "lognormal" "lognormal" ...
#>   .. .. ..$ h                   : num [1:12] 18.2 27.5 32.8 35 30.7 ...
#>   .. .. ..$ k                   : num [1:12] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..$ ks                  : num [1:12] 3.64 5.5 6.57 7.01 6.14 ...
#>   .. .. ..$ z0                  : num [1:12] 0.1871 0.1817 0.1293 0.0865 0.0874 ...
#>   .. .. ..$ gamma               : num [1:12] 3.20e-11 1.51e-11 8.63e-11 1.13e-11 4.67e-11 ...
#>   .. .. ..$ m                   : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ erepro              : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ R_max               : num [1:12] 7.38e+11 4.10e+11 1.05e+13 1.11e+12 1.12e+10 ...
#>   .. .. ..$ sel_func            : chr [1:12] "knife_edge" "knife_edge" "knife_edge" "knife_edge" ...
#>   .. .. ..$ knife_edge_size     : int [1:12] 13 4 23 99 21 75 78 39 105 165 ...
#>   .. .. ..$ catchability        : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ p                   : num [1:12] 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 ...
#>   .. .. ..$ q                   : num [1:12] 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 ...
#>   .. .. ..$ n                   : num [1:12] 0.667 0.667 0.667 0.667 0.667 ...
#>   .. .. ..$ f0                  : num [1:12] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 ...
#>   .. .. ..$ interaction_resource: num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ w_inf               : num [1:12] 33 36 100 334 324 ...
#>   .. .. ..$ w_mat25             : num [1:12] 11.65 3.58 20.61 88.7 18.82 ...
#>   .. .. ..$ w_repro_max         : num [1:12] 33 36 100 334 324 ...
#>   .. .. ..$ is_background       : logi [1:12] FALSE FALSE FALSE FALSE FALSE FALSE ...
#>   .. .. ..$ z_ext               : num [1:12] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..$ d                   : num [1:12] -0.333 -0.333 -0.333 -0.333 -0.333 ...
#>   .. .. ..$ E_ext               : num [1:12] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..$ D_ext               : num [1:12] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. ..@ given_species_params   :'data.frame':	12 obs. of  27 variables:
#>   .. .. ..$ species             : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. ..$ w_max               : num [1:12] 33 36 100 334 324 ...
#>   .. .. ..$ w_mat               : int [1:12] 13 4 23 99 21 75 78 39 105 165 ...
#>   .. .. ..$ beta                : int [1:12] 51076 398849 22 280540 191 22 381 283 113 558 ...
#>   .. .. ..$ sigma               : num [1:12] 0.8 1.9 1.5 3.2 1.9 1.5 1.9 1.8 1.6 2.1 ...
#>   .. .. ..$ k_vb                : num [1:12] 0.681 1 0.849 0.606 0.536 0.323 0.284 0.266 0.122 0.271 ...
#>   .. .. ..$ gear                : chr [1:12] "Industrial" "Industrial" "Industrial" "Pelagic" ...
#>   .. .. ..$ w_min               : num [1:12] 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 0.001 ...
#>   .. .. ..$ alpha               : num [1:12] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 ...
#>   .. .. ..$ pred_kernel_type    : chr [1:12] "lognormal" "lognormal" "lognormal" "lognormal" ...
#>   .. .. ..$ h                   : num [1:12] 18.2 27.5 32.8 35 30.7 ...
#>   .. .. ..$ k                   : num [1:12] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..$ ks                  : num [1:12] 3.64 5.5 6.57 7.01 6.14 ...
#>   .. .. ..$ z0                  : num [1:12] 0.1871 0.1817 0.1293 0.0865 0.0874 ...
#>   .. .. ..$ gamma               : num [1:12] 3.20e-11 1.51e-11 8.63e-11 1.13e-11 4.67e-11 ...
#>   .. .. ..$ m                   : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ erepro              : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ R_max               : num [1:12] 7.38e+11 4.10e+11 1.05e+13 1.11e+12 1.12e+10 ...
#>   .. .. ..$ sel_func            : chr [1:12] "knife_edge" "knife_edge" "knife_edge" "knife_edge" ...
#>   .. .. ..$ knife_edge_size     : int [1:12] 13 4 23 99 21 75 78 39 105 165 ...
#>   .. .. ..$ catchability        : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ p                   : num [1:12] 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 0.7 ...
#>   .. .. ..$ q                   : num [1:12] 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 ...
#>   .. .. ..$ n                   : num [1:12] 0.667 0.667 0.667 0.667 0.667 ...
#>   .. .. ..$ f0                  : num [1:12] 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 ...
#>   .. .. ..$ interaction_resource: num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. .. ..$ w_inf               : num [1:12] 33 36 100 334 324 ...
#>   .. ..@ interaction            : num [1:12, 1:12] 0.7291 0.0341 0.0635 0.2742 0.3624 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ predator: chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ prey    : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. ..@ gear_params            :'data.frame':	12 obs. of  5 variables:
#>   .. .. ..$ gear           : chr [1:12] "Industrial" "Industrial" "Industrial" "Pelagic" ...
#>   .. .. ..$ species        : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. ..$ sel_func       : chr [1:12] "knife_edge" "knife_edge" "knife_edge" "knife_edge" ...
#>   .. .. ..$ knife_edge_size: int [1:12] 13 4 23 99 21 75 78 39 105 165 ...
#>   .. .. ..$ catchability   : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. ..@ selectivity            : num [1:4, 1:12, 1:100] 0 0 0 0 0 0 0 0 0 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 3
#>   .. .. .. ..$ gear: chr [1:4] "Industrial" "Pelagic" "Beam" "Otter"
#>   .. .. .. ..$ sp  : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. .. .. ..$ w   : chr [1:100] "0.001" "0.00119" "0.00142" "0.0017" ...
#>   .. ..@ catchability           : num [1:4, 1:12] 1 0 0 0 1 0 0 0 1 0 ...
#>   .. .. ..- attr(*, "dimnames")=List of 2
#>   .. .. .. ..$ gear: chr [1:4] "Industrial" "Pelagic" "Beam" "Otter"
#>   .. .. .. ..$ sp  : chr [1:12] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. ..@ initial_effort         : Named num [1:4] 0 1 0.5 0.5
#>   .. .. ..- attr(*, "names")= chr [1:4] "Industrial" "Pelagic" "Beam" "Otter"
#>   .. ..@ A                      : num [1:12] 1 1 1 1 1 1 1 1 1 1 ...
#>   .. ..@ linecolour             : Named chr [1:17] "#815f00" "#6237e2" "#8da600" "#de53ff" ...
#>   .. .. ..- attr(*, "names")= chr [1:17] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. ..@ linetype               : Named chr [1:16] "solid" "solid" "solid" "solid" ...
#>   .. .. ..- attr(*, "names")= chr [1:16] "Sprat" "Sandeel" "N.pout" "Herring" ...
#>   .. ..@ ft_mask                : logi [1:12, 1:226] TRUE TRUE TRUE TRUE TRUE TRUE ...
#>   .. ..@ use_predation_diffusion: logi FALSE