matrix_interp {lefko3}R Documentation

Arranges Matrix Elements in Order of Magnitude for Interpretation

Description

Function matrix_interp summarizes matrices from lefkoMat, lefkoSens, lefkoElas, and lefkoLTRE objects in terms of the magnitudes of their elements. It can also create ordered summaries of standard matrices and sparse matrices.

Usage

matrix_interp(object, mat_chosen = 1L, part = 1L, type = 3L)

Arguments

object

A list object in one of lefko3's output formats, or a standard matrix or sparse matrix in dgCMatrix format. Standard lefko3 output formats include lefkoMat, lefkoSens, lefkoElas, and lefkoLTRE objects.

mat_chosen

The number of the matrix to assess, within the appropriate matrix list. See Notes for further details.

part

An integer noting whether to provide assessments of which of the main types of matrices to analyze. In a standard lefkoMat object, the integers 1, 2, and 3 correspond to the A, U, and F lists, respectively. In lefkoSens and lefkoElas objects, the integers 1 and 2 correspond to the ahistorical matrix sets and the historical matrix sets, respectively. In deterministic and stochastic lefkoLTRE objects, the integers 1 and 2 correspond to the cont_mean and cont_sd lists, respectively.

type

An integer corresponding to the type of order summary, including most to least positive (1), most to least negative (2), and greatest to lowest absolute magnitude (3). Defaults to type 3.

Value

A data frame arranging all elements in the matrix chosen from greatest and smallest. This can be a data frame of only positive elements, of only negative elements, or all elements in order of absolute magnitude.

Notes

Argument mat_chosen refers to the number of the matrix within the list that it is held in. For example, if the function is applied to the cont_sd portion of a stochastic LTRE, and there are four LTRE matrices within that list element corresponding to three patch LTRE matrices and one overall population-level LTRE matrix, then setting this value to 4 would focus the function on the overall population-level LTRE matrix associated with contributions of the standard deviations of elements. This argument should be left blank if a standard matrix or sparse matrix is input.

Huge sparse matrices may take more time to process than small, dense matrices.

Examples

data(cypdata)

sizevector <- c(0, 0, 0, 0, 0, 0, 1, 2.5, 4.5, 8, 17.5)
stagevector <- c("SD", "P1", "P2", "P3", "SL", "D", "XSm", "Sm", "Md", "Lg",
  "XLg")
repvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
obsvector <- c(0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1)
matvector <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
immvector <- c(0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0)
propvector <- c(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
indataset <- c(0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1)
binvec <- c(0, 0, 0, 0, 0, 0.5, 0.5, 1, 1, 2.5, 7)

cypframe_raw <- sf_create(sizes = sizevector, stagenames = stagevector,
  repstatus = repvector, obsstatus = obsvector, matstatus = matvector,
  propstatus = propvector, immstatus = immvector, indataset = indataset,
  binhalfwidth = binvec)

cypraw_v1 <- verticalize3(data = cypdata, noyears = 6, firstyear = 2004,
  patchidcol = "patch", individcol = "plantid", blocksize = 4,
  sizeacol = "Inf2.04", sizebcol = "Inf.04", sizeccol = "Veg.04",
  repstracol = "Inf.04", repstrbcol = "Inf2.04", fecacol = "Pod.04",
  stageassign = cypframe_raw, stagesize = "sizeadded", NAas0 = TRUE,
  NRasRep = TRUE)

cypsupp2r <- supplemental(stage3 = c("SD", "P1", "P2", "P3", "SL", "D", 
    "XSm", "Sm", "SD", "P1"),
  stage2 = c("SD", "SD", "P1", "P2", "P3", "SL", "SL", "SL", "rep",
    "rep"),
  eststage3 = c(NA, NA, NA, NA, NA, "D", "XSm", "Sm", NA, NA),
  eststage2 = c(NA, NA, NA, NA, NA, "XSm", "XSm", "XSm", NA, NA),
  givenrate = c(0.10, 0.20, 0.20, 0.20, 0.25, NA, NA, NA, NA, NA),
  multiplier = c(NA, NA, NA, NA, NA, NA, NA, NA, 0.5, 0.5),
  type =c(1, 1, 1, 1, 1, 1, 1, 1, 3, 3),
  stageframe = cypframe_raw, historical = FALSE)

cypmatrix2r <- rlefko2(data = cypraw_v1, stageframe = cypframe_raw, 
  year = "all", patch = "all", stages = c("stage3", "stage2", "stage1"),
  size = c("size3added", "size2added"), supplement = cypsupp2r,
  yearcol = "year2", patchcol = "patchid", indivcol = "individ")

aaa <- ltre3(cypmatrix2r, stochastic = TRUE)

matrix_interp(aaa, mat_chosen = 1, part = 2, type = 3)


[Package lefko3 version 6.2.1 Index]