Learn R Programming

Sim.DiffProc (version 2.5)

snssde2D: Numerical Solution of Two-Dimensional SDE

Description

Different methods of simulation of solutions to stochastic differential equations Two-dimensional.

Usage

snssde2D(N, T = 1, t0, x0, y0, Dt, driftx, drifty, diffx, diffy, 
        Step = FALSE, Output = FALSE, Methods = c("SchEuler", 
        "SchMilstein", "SchMilsteinS", "SchTaylor", "SchHeun", 
        "SchRK3"), ...)

Arguments

N
size of process.
T
final time.
t0
initial time.
x0
initial value of the process X(t) at time t0.
y0
initial value of the process Y(t) at time t0.
Dt
time step of the simulation (discretization).
driftx
drift coefficient of process X(t): an expression of three variables t , x and y.
drifty
drift coefficient of process Y(t): an expression of three variables t , x and y.
diffx
diffusion coefficient of process X(t): an expression of three variables t , x and y.
diffy
diffusion coefficient of process Y(t): an expression of three variables t , x and y.
Step
if Step = TRUE ploting step by step.
Output
if output = TRUE write a output to an Excel (.csv).
Methods
method of simulation ,see details.
...

Value

  • data.frame(time,X(t),Y(t)) and plot of process 2-D.

Details

the system for stochastic differential equation Two dimensional is :$$dX(t) = ax(t,X(t),Y(t))* dt + bx(t,X(t),Y(t))* dW1(t)$$ $$dY(t) = ay(t,X(t),Y(t))* dt + by(t,X(t),Y(t))* dW2(t)$$ with driftx=ax(t,X(t),Y(t)), drifty=ay(t,X(t),Y(t)) and diffx=bx(t,X(t),Y(t)), diffy=by(t,X(t),Y(t)). dW1(t) and dW2(t) are brownian motions independent. Simulation methods are usually based on discrete approximations of the continuous solution to a stochastic differential equation. The methods of approximation are classified according to their different properties. Mainly two criteria of optimality are used in the literature: the strong and the weak (orders of) convergence. The methods of simulation can be one among: Euler Order 0.5 , Milstein Order 1 , Milstein Second-Order , Ito-Taylor Order 1.5 , Heun Order 2 , Runge-Kutta Order 3.

See Also

diffBridge Creating Diffusion Bridge Models. snssde numerical solution of one-dimensional SDE. PredCorr predictor-corrector method for one-dimensional SDE. PredCorr2D predictor-corrector method for Two-dimensional SDE.

Examples

Run this code
## Example 1 
 driftx <- expression(cos(t*x))
 drifty <- expression(cos(t*y))
 diffx <- expression(sin(t*x))
 diffy <- expression(sin(t*y))
 snssde2D(N=1000, T = 1, t0=0, x0=0, y0=0, Dt=0.001, driftx, 
          drifty, diffx, diffy, Step = FALSE, Output = FALSE,
          Methods="SchTaylor")

## Example 2
 driftx <- expression(cos(t*x*y))
 drifty <- expression(sin(t*y*y))
 diffx <- expression(atan2(y, x))
 diffy <- expression(atan2(y, x))
 snssde2D(N=5000, T = 1, t0=0, x0=1, y0=1, Dt=0.001, driftx, 
          drifty, diffx, diffy, Step = FALSE, Output = FALSE,
          Methods="SchHeun")

Run the code above in your browser using DataLab