Skip to content
Prev 658 / 696 Next

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

Hi,

thanks for considering deSolve. Before answering your question, I want 
to emphasize that an ordinary differential equation system (ODE) is 
deterministic by definition. Never use a stochastic component like 
runif() inside of the model function of an ODE, especially not when 
using an automatic step-size solver like "lsoda". If you want to 
simulate stochastic forcing, use the "forcing" mechanism instead, see 
the ?forcings help page.

So first of all: remove the runif() component from the model!

The question which solver to use is best understood by reading a book 
about differential equations or even better by attending a course in 
numerical mathematics. Methods "euler" and the default solver "lsoda" 
are fundamentally different, so (besides your random element in the 
model) differences are completely natural.

In short: with a relatively large time step, "euler" solves a difference 
equation using a given fixed time step while "lsoda" approximates a 
differential equation with variable internal time step.

ThPe



Am 02.08.2020 um 16:59 schrieb Jinsong Zhao: