Description Usage Format Details References See Also Examples
simecol example: basic Lotka-Volterra predator prey-model.
1 |
An S4 object according to the odeModel
specification.
The object contains the following slots:
main
Lotka-Volterra equations for predator and prey.
parms
Vector with the named parameters of the model:
k1
growth rate of the prey population,
k2
encounter rate of predator and prey,
k3
death rate of the predator population.
times
Simulation time and integration interval.
init
Vector with start values for predator and prey.
To see all details, please have a look into the implementation.
Lotka, A. J. 1925. Elements of physical biology. Williams and Wilkins, Baltimore.
Volterra, V. (1926). Variazionie fluttuazioni del numero d'individui in specie animali conviventi. Mem. Acad.Lincei, 2, 31-113.
simecol-package
,
sim
,
parms
,
init
,
times
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ##============================================
## Basic Usage:
## explore the example
##============================================
data(lv)
print(lv)
plot(sim(lv))
parms(lv) <- c(k1=0.5, k2=0.5, k3=0.5)
plot(sim(lv))
##============================================
## Implementation:
## The code of the Lotka-Volterra-model
##============================================
lv <- new("odeModel",
main = function (time, init, parms) {
x <- init
p <- parms
dx1 <- p["k1"] * x[1] - p["k2"] * x[1] * x[2]
dx2 <- - p["k3"] * x[2] + p["k2"] * x[1] * x[2]
list(c(dx1, dx2))
},
parms = c(k1=0.2, k2=0.2, k3=0.2),
times = c(from=0, to=100, by=0.5),
init = c(prey=0.5, predator=1),
solver = "rk4"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.