R/LW_project_alpha_pairwise_lambdacov_none_alphacov_none.R

Defines functions LW_project_alpha_pairwise_lambdacov_none_alphacov_none

Documented in LW_project_alpha_pairwise_lambdacov_none_alphacov_none

#' Law-Watkinson model for projecting abundances,
#' with specific alpha values and no covariate effects
#'
#' @param lambda numeric lambda value.
#' @param alpha_intra included for compatibility, not used in this model.
#' @param alpha_inter single numeric value.
#' @param lambda_cov included for compatibility, not used in this model.
#' @param alpha_cov included for compatibility, not used in this model.
#' @param abundance named numeric vector of abundances in the previous timestep.
#' @param covariates included for compatibility, not used in this model.
#'
#' @return numeric abundance projected one timestep
#' @export
LW_project_alpha_pairwise_lambdacov_none_alphacov_none <- function(lambda,
                                                                   alpha_intra,
                                                                   alpha_inter,
                                                                   lambda_cov,
                                                                   alpha_cov,
                                                                   abundance,
                                                                   covariates){
  
  spnames <- names(abundance)
  
  alpha <- c(alpha_intra,alpha_inter)
  alpha <- alpha[spnames]
  
  numsp <- length(abundance)
  expected_abund <- NA_real_
  
  num <- lambda
  term <- 1
  for(i.sp in 1:numsp){
    term <- term + abundance[i.sp]^alpha[i.sp]
  }# for each sp
  
  expected_abund <- (lambda/term)* abundance[names(lambda)]
  expected_abund
}

Try the cxr package in your browser

Any scripts or data that you put into this service are public.

cxr documentation built on Oct. 27, 2023, 1:08 a.m.