Learn R Programming

Sim.DiffProc (version 2.8)

snssde2d: Simulation of 2-Dim Stochastic Differential Equation

Description

The (S3) generic function snssde2d of simulation of solutions to 2-dim stochastic differential equations of Ito or Stratonovich type, with different methods.

Usage

snssde2d(N, ...)
## S3 method for class 'default':
snssde2d(N = 1000, M = 1, x0 = 0, y0 = 0, t0 = 0, T = 1, Dt, 
   driftx, diffx, drifty, diffy, alpha = 0.5, mu = 0.5, 
   type = c("ito", "str"), method = c("euler", "milstein", 
   "predcorr", "smilstein", "taylor", "heun", "rk1", "rk2",
   "rk3"), ...)
						   
						   
## S3 method for class 'snssde2d':
summary(object, \dots)
## S3 method for class 'snssde2d':
time(x, \dots)
## S3 method for class 'snssde2d':
mean(x, \dots)
## S3 method for class 'snssde2d':
median(x, \dots)
## S3 method for class 'snssde2d':
quantile(x, \dots)
## S3 method for class 'snssde2d':
kurtosis(x, \dots)
## S3 method for class 'snssde2d':
skewness(x, \dots)
## S3 method for class 'snssde2d':
moment(x, order = 2, \dots)
## S3 method for class 'snssde2d':
bconfint(x, level=0.95, \dots)
## S3 method for class 'snssde2d':
plot(x, \dots)
## S3 method for class 'snssde2d':
lines(x, \dots)
## S3 method for class 'snssde2d':
points(x, \dots)
## S3 method for class 'snssde2d':
plot2d(x, \dots)
## S3 method for class 'snssde2d':
lines2d(x, \dots)
## S3 method for class 'snssde2d':
points2d(x, \dots)

Arguments

N
number of simulation steps.
M
number of trajectories.
x0, y0
initial value of the process $X_{t}$ and $Y_{t}$ at time t0.
t0
initial time.
T
final time.
Dt
time step of the simulation (discretization). If it is missing a default $\Delta t = \frac{T-t_{0}}{N}$.
driftx, drifty
drift coefficient: an expression of three variables t, x and y for process $X_t$ and $Y_t$.
diffx, diffy
diffusion coefficient: an expression of three variables t, x and y for process $X_t$ and $Y_t$.
alpha, mu
weight of the predictor-corrector scheme; the default alpha = 0.5 and mu = 0.5.
type
if type="ito" simulation sde of Ito type, else type="str" simulation sde of Stratonovich type; the default type="ito".
method
numerical methods of simulation, the default method = "euler".
x, object
an object inheriting from class "snssde2d".
order
order of moment.
level
the confidence level required.
...
further arguments for (non-default) methods.

Value

  • snssde2d returns an object inheriting from class "snssde2d".
  • X, Yan invisible mts (2-dim) object (X(t),Y(t)).
  • driftx, driftydrift coefficient of X(t) and Y(t).
  • diffx, diffydiffusion coefficient of X(t) and Y(t).
  • typetype of sde.
  • methodthe numerical method used.

newcommand

\CRANpkg

href

http://CRAN.R-project.org/package=#1

pkg

#1

Details

The function snssde2d returns a mts x of length N+1; i.e. solution of the 2-dim sde $(X_{t},Y_{t})$ of Ito or Stratonovich types; If Dt is not specified, then the best discretization $\Delta t = \frac{T-t_{0}}{N}$. The 2-dim Ito stochastic differential equation is: $$dX(t) = a(t,X(t),Y(t)) dt + b(t,X(t),Y(t)) dW_{1}(t)$$ $$dY(t) = a(t,X(t),Y(t)) dt + b(t,X(t),Y(t)) dW_{2}(t)$$ 2-dim Stratonovich sde : $$dX(t) = a(t,X(t),Y(t)) dt + b(t,X(t),Y(t)) \circ dW_{1}(t)$$ $$dY(t) = a(t,X(t),Y(t)) dt + b(t,X(t),Y(t)) \circ dW_{2}(t)$$ $W_{1}(t), W_{2}(t)$ two standard Brownian motion independent. 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 method of simulation can be one among: Euler-Maruyama Order 0.5, Milstein Order 1, Milstein Second-Order, Predictor-Corrector method, Ito-Taylor Order 1.5, Heun Order 2 and Runge-Kutta Order 1, 2 and 3. For more details see vignette("SDEs").

References

Friedman, A. (1975). Stochastic differential equations and applications. Volume 1, ACADEMIC PRESS. Henderson, D. and Plaschko,P. (2006). Stochastic differential equations in science and engineering. World Scientific. Allen, E. (2007). Modeling with Ito stochastic differential equations. Springer-Verlag. Jedrzejewski, F. (2009). Modeles aleatoires et physique probabiliste. Springer-Verlag. Iacus, S.M. (2008). Simulation and inference for stochastic differential equations: with R examples. Springer-Verlag, New York. Kloeden, P.E, and Platen, E. (1989). A survey of numerical methods for stochastic differential equations. Stochastic Hydrology and Hydraulics, 3, 155--178. Kloeden, P.E, and Platen, E. (1991a). Relations between multiple ito and stratonovich integrals. Stochastic Analysis and Applications, 9(3), 311--321. Kloeden, P.E, and Platen, E. (1991b). Stratonovich and ito stochastic taylor expansions. Mathematische Nachrichten, 151, 33--50. Kloeden, P.E, and Platen, E. (1995). Numerical Solution of Stochastic Differential Equations. Springer-Verlag, New York. Oksendal, B. (2000). Stochastic Differential Equations: An Introduction with Applications. 5th edn. Springer-Verlag, Berlin. Platen, E. (1980). Weak convergence of approximations of ito integral equations. Z Angew Math Mech. 60, 609--614. Platen, E. and Bruti-Liberati, N. (2010). Numerical Solution of Stochastic Differential Equations with Jumps in Finance. Springer-Verlag, New York Saito, Y, and Mitsui, T. (1993). Simulation of Stochastic Differential Equations. The Annals of the Institute of Statistical Mathematics, 3, 419--432.

See Also

snssde1d for 1-dim sde. sde.sim in package sde. simulate in package yuima.

Examples

Run this code
## Example 1: Ito sde
## dX(t) = 4*(-1-X(t))*Y(t) dt + 0.2 dW1(t)
## dY(t) = 4*(1-Y(t))*X(t) dt + 0.2 dW2(t)

fx <- expression(4*(-1-x)*y)
gx <- expression(0.2)
fy <- expression(4*(1-y)*x)
gy <- expression(0.2)

res <- snssde2d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,x0=1,y0=-1,M=50)
res
summary(res)
plot(res)
dev.new()
plot2d(res) ## in plane (O,X,Y)

## Example 2: Stratonovich sde
## dX(t) = Y(t) dt + 0 o dW1(t)
## dY(t) = (4*(1-X(t)^2)*Y(t) - X(t) ) dt + 0.2 o dW2(t)

fx <- expression( y )
gx <- expression( 0 )
fy <- expression( (4*( 1-x^2 )* y - x) )
gy <- expression( 0.2)

res1 <- snssde2d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,type="str",T=100,
                 ,N=10000)
res1
plot(res1,pos=2)
dev.new()
plot(res1,union = FALSE)
dev.new()
plot2d(res1,type="n") ## in plane (O,X,Y)
points2d(res1,col=rgb(0,100,0,50,maxColorValue=255), pch=16)

Run the code above in your browser using DataLab