Learn R Programming

aae.pop (version 0.2.0)

masks: Isolate elements of population dynamics models

Description

Helper functions to isolate particular components of a population dynamics model, such as the reproduction terms, transition/growth terms, or particular life stages from an abundance vector, such as pre- or post-reproductive stages.

Usage

reproduction(matrix, dims = NULL)

survival(matrix, dims = NULL)

transition(matrix, dims = NULL)

all_cells(matrix, dims = NULL)

all_classes(matrix, dims = NULL)

combine(...)

Value

mask object used to define the cells affected by a process included in dynamics

Arguments

matrix

a population dynamics matrix for which a particular mask is required. Only used to determine mask dimensions, so can be any matrix with appropriate dimensions

dims

a numeric value or vector identifying subsets of cells to include in a given mask

...

a set of masks or masking functions to be combined into a single mask by one of the combine methods

Examples

Run this code
# define a population
nclass <- 5
popmat <- matrix(0, nrow = nclass, ncol = nclass)
popmat[reproduction(popmat, dims = 4:5)] <- c(10, 20)
popmat[transition(popmat)] <- c(0.25, 0.3, 0.5, 0.65)

# pull out reproductive elements
reproduction(popmat)

# what if only 4 and 5 year olds reproduce?
reproduction(popmat, dims = 4:5)

# define survival elements
survival(popmat)

# what if 1 and 2 year olds always transition?
survival(popmat, dims = 3:5)

# and transitions
transition(popmat)

# combine transitions and reproduction of 4 and 5 year olds
combine(reproduction(popmat, dims = 4:5), transition(popmat))

# can also mask the population vector in this way
# pull out all classes
all_classes(popmat)

# and just 3-5 year olds
all_classes(popmat, dims = 3:5)

Run the code above in your browser using DataLab