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

Jinsong Zhao j@zh@o @end|ng |rom ye@h@net
Sun Aug 2 16:59:30 CEST 2020


Hi there,

I try to solve a simple ODE model:

logistic <- function(time, state, params) {
    with(as.list(c(state, params)), {
            K <- K.mean + runif(1, -10, 10)
            dPOP <- rate * POP * (1 - POP / K)
            list(c(dPOP),
                 c(K = K))
    })
}

params <- c(rate = 0.1,
             K.mean = 100)
state <- c(POP = 10)
time <- seq(0,120)
out <- ode(state, time, logistic, params, method = "euler")
plot(out)

However, if I remove `method = "euler"`, i.e., using the default 
integrator, the output is very different.

I don't know when I should use "euler" or any other integrator. Any 
suggestion? Thanks a lot.

Best,
Jinsong



More information about the R-sig-dynamic-models mailing list