Hello,
I am an R newbie, trying to use lsoda to solve standard Lotka-Volterra competition equations. My question is: how do I pass a parameter that varies with time, like say, phix <- 0.7 + runif(tmax) in the example below.
# defining function
lotvol <- function(t,n,p){
x <- n[1]; y <- n[2]
rx <- p["rx"]; ry <- p["ry"]
Kx <- p["Kx"]; Ky <- p["Ky"]
phix <- p["phix"]; phiy <- p["phiy"]
dx.dt <- rx*x*(1 - x/Kx) - phix*x*y
dy.dt <- ry*y*(1 - y/Ky) - phiy*x*y
list(c(dx.dt, dy.dt))
}# running lsoda nstart <- c(x=0.5, y=0.5) parms <- c(rx=1, ry=1, Kx=1, Ky=1, phix=1.2, phiy=0.8) tmax <- 100 times <- seq(0,tmax) require(odesolve) out <- as.data.frame(lsoda(nstart, times, lotvol, parms))
Thanks, Manojit
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
