Skip to contents

Set species interaction matrix


setInteraction(params, interaction = NULL)




MizerParams object


Optional interaction matrix of the species (predator species x prey species). Entries should be numbers between 0 and 1. By default all entries are 1. See "Setting interaction matrix" section below.


setInteraction: A MizerParams object with updated interaction matrix

getInteraction(): 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}\) describes the interaction of each pair of species in the model. This can be viewed as a proxy for spatial interaction e.g. to model predator-prey interaction that is not size based. 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.

It is used when calculating the food encounter rate in getEncounter() and the predation mortality rate in getPredMort(). Its entries are dimensionless numbers.The values are between 0 (species do not overlap and therefore do not interact with each other) to 1 (species overlap perfectly). If all the values in the interaction matrix are set to 1 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 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. Again the entries have to be numbers between 0 and 1. By default this column is set to all 1s.


params <- newTraitParams(no_sp = 3)
inter <- getInteraction(params)
inter[1, 2:3] <- 0
params <- setInteraction(params, interaction = inter)
#>         prey
#> predator 1 2 3
#>        1 1 0 0
#>        2 1 1 1
#>        3 1 1 1