Lotka-Volterra model ~ intro

March 30, 2010

(This article was first published on mind of a Markov chain » R, and kindly contributed to R-bloggers)

So many know about the Lotka-Volterra model (i.e. the predator-prey model) in ecology. This model portrays two species, the predator (y) and the prey (x), interacting each other in limited space.

frac{dx}{dt} = x(alpha - beta y)\ frac{dy}{dt}=-y(gamma - delta x)

The prey grows at a linear rate (alpha) and gets eaten by the predator at the rate of (beta). The predator gains a certain amount vitality by eating the prey at a rate (delta), while dying off at another rate (gamma).

Given this base, we can ask questions like, what parameterizations can we expect to find a coexistence between the fox and the hare (for example)?

Let’s choose some values for the model: alpha = 2, beta = .5, gamma = .2, delta = .6. These values assume a weaker growth of the rabbits relative to the strength of the death of foxes. Below, I simulated these values in R.

And we get coexistence, they live happily forever after. With this simple model, we can play around by generalizing (logistic growth of prey, etc.). I will put up some posts doing so.

The way to do this in R is as follows (just use the deSolve package, which will supersede the odesolve package):


LotVmod <- function (Time, State, Pars) {
	with(as.list(c(State, Pars)), {
		dx = x*(alpha - beta*y)
		dy = -y*(gamma - delta*x)
		return(list(c(dx, dy)))

Pars <- c(alpha = 2, beta = .5, gamma = .2, delta = .6)
State <- c(x = 10, y = 10)
Time <- seq(0, 100, by = 1)

out <- as.data.frame(ode(func = LotVmod, y = State, parms = Pars, times = Time))

matplot(out[,-1], type = "l", xlab = "time", ylab = "population")
legend("topright", c("Cute bunnies", "Rabid foxes"), lty = c(1,2), col = c(1,2), box.lwd = 0)

Filed under: deSolve, Food Web, ODEs, R

To leave a comment for the author, please follow the link and comment on their blog: mind of a Markov chain » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: , , ,

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



CRC R books series

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)