# Numeric solvers for stochastic differential equations in R: are there any?

I'm looking for a general, clean and fast (i.e. using C++ routines) R package for simulating paths from a non-homogeneous nonlinear diffusion like (1) using the Euler-Maruyama scheme, the Milstein scheme (or any other). This is destined to be embedded into a larger estimation code and therefore deserves to be optimized.

$$dX_t = f(\theta, t, X_t)\, dt + g(\theta, t, X_t)\, dW_t, \tag{1}$$

with $W_t$ the standard Brownian motion.

• (+1) Interesting question. It is important to notice that the solution to this sort of SDE does not always exist or it may not be unique. In addition, simulation of diffusion processes can be quite difficult (it is actually a hot topic at the moment). – user10525 Oct 9 '12 at 14:37
• It is. Analytic solutions are indeed rare and the existence of a solution is to be demonstrated but you are always able to simulate though...I will end-up recoding my R programs in C if nobody comes up with a ready made tool...most general analysis software generally have an all-purpose solver funny R seems to provide only specific simulators, or I may have overlooked the right package – julien stirnemann Oct 9 '12 at 22:19
• Here is a good place (and people) to start with: web.warwick.ac.uk/statsdept/user-2011/tutorials/Soetaert.html – JohnRos Feb 12 '13 at 7:27

## 2 Answers

CRAN is your friend: http://cran.r-project.org/web/views/DifferentialEquations.html

### Stochastic Differential Equations (SDEs)

In a stochastic differential equation, the unknown quantity is a stochastic process.

• The package sde provides functions for simulation and inference for stochastic differential equations. It is the accompanying package to the book by Iacus (2008).
• The package pomp contains functions for statistical inference for partially observed Markov processes.
• The Sim.DiffProc package simulates diffusion processes and has functions for numerical solution of stochastic differential equations.
• Package GillespieSSA implements Gillespie's exact stochastic simulation algorithm (Direct method) and several approximate methods.

There is a R package for SDE: http://cran.r-project.org/web/packages/sde/sde.pdf But I am not sure if it works for non-homogeneous SDE