[R] lsoda

Martin Henry H. Stevens hstevens at rci.rutgers.edu
Fri May 11 15:45:36 CEST 2001

I am running R 1.2.3 with ESS5.1.18 with Windows 98.

I am trying to use lsoda in the odesolve apckage and am having problems.
The return value of the function of the system of ode's has to be a list
that includes first, the ode's and second, "a vector
          (possibly with a `names' attribute) of global values that are
required at each point in `times'."
I didn't understand from the example why the massbalance = sum(y) was needed
for that system of equations. Why is it needed?

For my function below ('lvcomp2'), I don't know what global values lsoda
needs at each point in time (see???), other than the previous time step's
values of y and the parms. Any help?

Also, any rule of thumb advice regarding rtol and atol would be appreciated.

p <- c(r1=.01, r2=.01, a12=0.5, a21=0.6, k1=1,k2=1)
t <- 1:20
lvcomp2 <- function(y, t, p)
{ # Lotka - Volterra model of two competing populations
dN1.dt <- p["r1"] * y[1] * (1-(y[1] + p["a12"]*y[2])/p["k1"])
dN2.dt <- p["r2"] * y[2] * (1-(y[2] + p["a21"]*y[1])/p["k2"])
outlv <- lsoda(c(.1,.1),t, lvcomp2, p,rtol=1e-4, atol=1e-6)


Dr. M. Henry H. Stevens
Postdoctoral Associate
Department of Ecology, Evolution, & Natural Resources
14 College Farm Road
Cook College, Rutgers University
New Brunswick, NJ 08901-8551

email: hstevens at rci.rutgers.edu
phone: 732-932-9631
fax: 732-932-8746

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list