Skip to contents

Set species interaction matrix

Usage

setInteraction(params, interaction = NULL)

interaction_matrix(params)

interaction_matrix(params) <- value

Arguments

params

MizerParams object

interaction

Optional interaction matrix of the species (predator species x prey species). By default all entries are 1. See "Setting interaction matrix" section below.

value

An interaction matrix

Value

setInteraction: A MizerParams object with updated interaction matrix

interaction_matrix(): The interaction matrix (predator species x prey species)

Setting interaction matrix

You do not need to specify an interaction matrix. If you do not, then the predator-prey interactions are purely determined by the size of predator and prey and totally independent of the species of predator and prey.

The interaction matrix \(\theta_{ij}\) modifies the interaction of each pair of species in the model. This can be used for example to allow for different spatial overlap among the species. The values in the interaction matrix are used to scale the encountered food and predation mortality (see on the website the section on predator-prey encounter rate and on predation mortality). The first index refers to the predator species and the second to the prey species.

The interaction matrix is used when calculating the food encounter rate in getEncounter() and the predation mortality rate in getPredMort(). Its entries are dimensionless numbers. If all the values in the interaction matrix are equal then predator-prey interactions are determined entirely by size-preference.

This function checks that the supplied interaction matrix is valid and then stores it in the interaction slot of the params object.

The order of the columns and rows of the interaction argument should be the same as the order in the species params data frame in the params object. If you supply a named array then the function will check the order and warn if it is different. One way of creating your own interaction matrix is to enter the data using a spreadsheet program and saving it as a .csv file. The data can then be read into R using the command read.csv().

The interaction of the species with the resource are set via a column interaction_resource in the species_params data frame. By default this column is set to all 1s.

Examples

params <- newTraitParams(no_sp = 3)
inter <- getInteraction(params)
#> Warning: `getInteraction()` was deprecated in mizer 2.4.0.
#>  Please use `interaction_matrix()` instead.
inter[1, 2:3] <- 0
params <- setInteraction(params, interaction = inter)
getInteraction(params)
#>         prey
#> predator 1 2 3
#>        1 1 0 0
#>        2 1 1 1
#>        3 1 1 1