Skip to content
Prev 659 / 696 Next

[R-sig-dyn-mod] how to select the integrator in ode?

Thanks a lot for the suggestions and the deSolve package.

The help package of "forcings" solve my question. And it also solve the 
question I encountered in your book "A practical guide to ecological 
modelling":

outtimes <- seq(1,365,by=1)
Carbon <- meanDepo*optpar$par[2]/optpar$par[1]
names(Carbon) <-"Carbon"
out <- as.data.frame(ode(Carbon,outtimes,minmod, optpar$par))
names(out) <- c("time","Carbon","minrate")

when I print out, I found the last row of the out is NA.

 > tail(out)
    time    Carbon   minrate
360  360  99.51982 0.9179177
361  361  99.80277 0.9205274
362  362 100.14148 0.9236516
363  363 100.53546 0.9272854
364  364 100.98419 0.9314243
365  365        NA        NA

I learned that "euler" is fixed time step, and I am familiar with the 
method because it always used as an demo in most introduction materials 
of numerical analysis. The reason that I asked this question is 
sometimes the "euler" method could be replaced by "lsoda", and produce 
same results, and sometimes they can not be used interchangeably.

Thanks again for the explanation and suggestions.

Best,
Jinsong
On 2020/8/3 3:09, Thomas Petzoldt wrote: