collapse_stage.vector: Reduce number of stages in MPM simulation output

Description Usage Arguments Value Examples

View source: R/utils.R

Description

This is designed to make it easy to collapse simulation output from an age-structured model into stages for ease in plotting. It works well with the output provided by pop.projection in the popbio package.

Usage

1
collapse_stage.vector(stage.vectors, stages = NULL)

Arguments

stage.vectors

A matrix, with each row being a class in the MPM and each column being a time step. The stage.vectors element of pop.projection satisfies this.

stages

An optional vector, specifying the stage associated with each class of the MPM. Should be the same length as the number of rows of stage.vectors. If the matrix was produced using a Leslie matrix created using make_stage4age_matrix, then this can be left unspecified.

Value

A matrix similar to the input stage.vectors, but with the rows collapsed into the reduced number of stages.

Examples

1
2
3
4
5
6
7
# Leslie matrix version of the same data of the loggerhead population
A2 <- make_stage4age_matrix(loggerhead[[2]])
N0 <- rep(10, nrow(A2))
library(popbio)
pop.sim <- pop.projection(A2, N0)
sv <- collapse_stage.vector(pop.sim$stage.vector)
stage.vector.plot(sv)

BruceKendall/mpmtools documentation built on May 21, 2019, 1:42 a.m.