R/dlvcomp2.R

#' Discrete Logistic Competition
#'
#' A function to simulate discrete 2 species Lotka-Volterra competition.
#'
#'
#' @param N a vector of length two, containing N[t] for both species.
#' @param alpha a 2 x 2 matrix of the magnitudes of the per capita (negative)
#' effects (i.e., positive value results in a negative effect).
#' @param rd a vector of length 2 containing the discrete growth increments for
#' 2 species.
#' @return Returns a vector of length 2, containing N[t+1] for both species.
#' @author Hank Stevens (HStevens@@muohio.edu)
#' @seealso \code{\link{dlogistic}}, \code{\link{lvcomp2}},
#' \code{\link{lvcomp3}}, \code{\link{lvcompg}}
#' @references Stevens. M.H.H. (2009) \emph{A Primer of Ecology with R}. Use R!
#' Series. Springer.
#' @keywords methods
#' @export
#' @examples
#'
#' alphs <- matrix(c( .01, .005,
#'                   .008, .01), ncol=2, byrow=TRUE)
#' t <- 20
#' N <- matrix(NA, nrow=t+1, ncol=2)
#' N[1,] <- c(10,10)
#' for(i in 1:t) N[i+1,] <- dlvcomp2(N[i,], alphs)
#' matplot(0:t, N, type='l', col=1, ylim=c(0,110))
#' abline(h=1/alphs[1,1], lty=3)
#' text(0, 1/alphs[1,1], "K", adj=c(0,0))
#' legend("right", c(expression("Sp.1 "*(alpha[21]==0.008)),
#'                   expression("Sp.2 "*(alpha[12]==0.005))), lty=1:2, bty='n')
#'
`dlvcomp2` <-
function (N, alpha, rd = c(1, 1))
{
    N1.t1 <- N[1] + rd[1] * N[1] * (1 - alpha[1, 1] * N[1] -
        alpha[1, 2] * N[2])
    N2.t1 <- N[2] + rd[2] * N[2] * (1 - alpha[2, 1] * N[1] -
        alpha[2, 2] * N[2])
    c(N1.t1, N2.t1)
}

Try the primer package in your browser

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

primer documentation built on Jan. 7, 2021, 1:07 a.m.