[R] Error in eco-model
roelvhoolst
roelvhoolst at hotmail.com
Fri May 14 15:50:03 CEST 2010
Hello,
I am working on a paper of ecological modelling in R. I have made a Lotka
Volterra model for tree animal species. I was trying to get the model in R
but there are some errors. Since i am not so experienced with R i can't find
the bugs in my script.
I hope if there is someone who can help me handle this problem.
Greetz
Roel
This is the script i wrote:
library(odesolve)
LotVmod <- function (Time, State, Pars) {
with(as.list(c(State, Pars)), {
dx = x*(alpha - beta*y)
dy = -y*(gamma - delta*z)
dz = z*( Iota – kappa*y)
return(list(c(dx, dy, dz)))
})
}
Pars <- c(alpha = .405, beta = .81, gamma = 1.5, delta = .125, Iota = 0.35,
kappa = 0.75)
State <- c(x = 100, y = 100, z = 100)
Time <- seq(0, 100, by = 1)
out <- as.data.frame(lsoda(func = LotVmod, y = State, parms = Pars, times =
Time))
matplot(out[,-1], type = "l", xlab = "time", ylab = "population")
legend("topright", c("leeuw", "wildebeest",”zebra”), lty = c(1,2,3), col =
c(1,2,3), box.lwd = 0)
--
View this message in context: http://r.789695.n4.nabble.com/Error-in-eco-model-tp2216605p2216605.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list