Learn R Programming

mizer (version 1.0.1)

getM2: getM2 method for the size based model

Description

Calculates the total predation mortality rate \(\mu_{p,i}(w_p)\) on each prey species by prey size. This method is used by the project method for performing simulations.

Usage

getM2(object, n, n_pp, pred_rate, ...)

# S4 method for MizerParams,missing,missing,array getM2(object, pred_rate)

# S4 method for MizerParams,matrix,numeric,missing getM2(object, n, n_pp)

# S4 method for MizerSim,missing,missing,missing getM2(object, time_range = dimnames(object@n)$time, drop = TRUE, ...)

Arguments

object

A MizerParams or MizerSim object.

n

A matrix of species abundance (species x size). Only used if object argument is of type MizerParams.

n_pp

A vector of the background abundance by size. Only used if object argument is of type MizerParams.

pred_rate

An array of predation rates of dimension no. sp x no. community size bins x no. of size bins in whole spectra (i.e. community + background, the w_full slot). The array is optional. If it is not provided it is calculated by the getPredRate() method.

...

Other arguments (currently unused).

time_range

Subset the returned fishing mortalities by time. The time range is either a vector of values, a vector of min and max time, or a single value. Default is the whole time range. Only used if the object argument is of type MizerSim.

drop

Only used when object is of type MizerSim. Should dimensions of length 1 in the output be dropped, simplifying the output. Defaults to TRUE

Value

If a MizerParams object is passed in, the method returns a two dimensional array (prey species x prey size) based on the abundances also passed in. If a MizerSim object is passed in, the method returns a three dimensional array (time step x prey species x prey size) with the predation mortality calculated at every time step in the simulation.

See Also

getPredRate and project.

Examples

Run this code
# NOT RUN {
data(NS_species_params_gears)
data(inter)
params <- MizerParams(NS_species_params_gears, inter)
# With constant fishing effort for all gears for 20 time steps
sim <- project(params, t_max = 20, effort = 0.5)
# Get M2 at one time step
n <- sim@n[21,,]
n_pp <- sim@n_pp[21,]
getM2(params,n,n_pp)
# Get M2 at all saved time steps
getM2(sim)
# Get M2 over the time 15 - 20
getM2(sim, time_range = c(15,20))
# }

Run the code above in your browser using DataLab