add_stage: Add a New Stage to an Existing LefkoMat Object

View source: R/RcppExports.R

add_stageR Documentation

Add a New Stage to an Existing LefkoMat Object

Description

Function add_stage() adds a new stage to an existing lefkoMat object. In addition to altering the ahstages object within the MPM, it alters the hstages and agestages objects and adds the appropriate number of new rows and columns depending on the kind of MPM input.

Usage

add_stage(mpm, add_before = 0L, add_after = 0L, stage_name = NULL)

Arguments

mpm

The lefkoMat object to add a stage to.

add_before

The index of the stage to insert a new stage before. This index should be derived from the ahstages of the input mpm. Cannot be set if add_after is to be used.

add_after

The index of the stage to insert a new stage after. This index should be derived from the ahstages of the input mpm. Cannot be set if add_before is to be used.

stage_name

The name of the new stage to add. Defaults to new_stage.

Value

A new copy of the original MPM edited to include new rows and columns in the associated matrices, and with ahstages, agestages, and hstages objects edited to include the new stage.

See Also

edit_lM()

Examples

data(cypdata)

cyp_lesl_data <- 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", 
  stagesize = "sizeadded", NAas0 = TRUE, age_offset = 2)

cyp_lesl_vital <- modelsearch(cyp_lesl_data, historical = FALSE,
  approach = "mixed", suite = "cons", bestfit = "AICc&k", age = "obsage",
  vitalrates = c("surv", "fec"), fecdist = "poisson", indiv = "individ",
  year = "year2", year.as.random = TRUE, patch.as.random = TRUE,
  show.model.tables = TRUE, fec.zero = TRUE, global.only = TRUE,
  test.age = TRUE, quiet = "partial")

germination <- 0.08
protocorm_to_seedling <- 0.10
seeding_to_adult <- 0.20
seeds_per_fruit <- 8000

cyp_lesl_supp <- supplemental(historical = FALSE, stagebased = FALSE,
  agebased = TRUE, age2 = c(1, 2), type = c(1, 1),
  givenrate = c(protocorm_to_seedling, seeding_to_adult))

cyp_lesl_fb_mpm <- fleslie(data = cyp_lesl_data,
  modelsuite = cyp_lesl_vital, last_age = 7, fecage_min = 3,
  fecmod = (germination * seeds_per_fruit), supplement = cyp_lesl_supp)

altered1 <- add_stage(cyp_lesl_fb_mpm, add_before = 1, stage_name = "DS")


lefko3 documentation built on Oct. 14, 2023, 1:07 a.m.