Learn R Programming

primer (version 0.1)

lvcompg: A general Lotka-Volterra competition model

Description

A general Lotka-Volterra competition model, for any number of species. For use with ode in the deSolve package. This function uses a vector and matrix within the list of parameters.

Usage

lvcompg(t, n, parms)

Arguments

t
the time point for a realization of the integration.
n
the vector of populations, at each time t.
parms
a LIST containing a vector of growth rates (r), and a matrix of interaction coefficients (a).

Value

  • Returns a list of length one which is the vector of the rates of increase (required by ode).

References

A.J. Lotka. Elements of Mathematical Biology. Dover Publications, Inc., 1956.

M.H.H. Stevens. A Primer of Ecology with R. Use R! Series. Springer, 2009.

See Also

igp, scheffer

Examples

Run this code
## Specify the number of species
S <- 10
alpha <- .01
r <- runif(S)*2
a <- matrix(rnorm(S^2, m=alpha, sd=alpha/10), nrow=S, ncol=S)
parms <- list(r,a)
t=seq(0,40, by=.1)
N0 <- runif(S)/(S*alpha)
library(deSolve)
lvout <- ode(N0, t, lvcompg, parms)
matplot(t, lvout[,-1], type="l", ylab="N", log='y')

Run the code above in your browser using DataLab