R/lambda_matrix.R

Defines functions lambda_matrix

Documented in lambda_matrix

# Quick stage based population projection matrix

lambda_matrix <- function(r.stage, b, stages, S, terminal){
  if(missing(terminal)) {terminal=FALSE} else {terminal=terminal}

    Fec <- c(rep(0,r.stage -1),rep(b,stages-(r.stage-1)))
    Fec <- S * Fec
    Sur <- diag(S)
    mat <-rbind(Fec,Sur)
    rownames(mat) <- c("Fecundity", rep("Survival", length(S)))
    if(terminal==FALSE){
       mat [stages,stages] <- S[stages]} else {
         mat [stages,stages] <- 0
       }
    mat <- mat[-(stages+1),]
    pop.matrix <<- mat
    return(list("Transition matrix" = mat,"Lambda:"=lambda(mat)))

}
NathanWhitmore/harvest documentation built on Feb. 15, 2023, 2:28 p.m.