Learn R Programming

Sim.DiffProc (version 2.8)

snssde3d: Simulation of 3-Dim Stochastic Differential Equation

Description

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

Usage

snssde3d(N, ...)
## S3 method for class 'default':
snssde3d(N = 1000, M =1, x0 = 0, y0 = 0, z0 = 0, t0 = 0, T = 1, Dt, 
   driftx, diffx, drifty, diffy, driftz, diffz, 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 'snssde3d':
summary(object, \dots)
## S3 method for class 'snssde3d':
time(x, \dots)
## S3 method for class 'snssde3d':
mean(x, \dots)
## S3 method for class 'snssde3d':
median(x, \dots)
## S3 method for class 'snssde3d':
quantile(x, \dots)
## S3 method for class 'snssde3d':
kurtosis(x, \dots)
## S3 method for class 'snssde3d':
skewness(x, \dots)
## S3 method for class 'snssde3d':
moment(x, order = 2, \dots)
## S3 method for class 'snssde3d':
bconfint(x, level=0.95, \dots)
## S3 method for class 'snssde3d':
plot(x, \dots)
## S3 method for class 'snssde3d':
lines(x, \dots)
## S3 method for class 'snssde3d':
points(x, \dots)
## S3 method for class 'snssde3d':
plot3D(x, display = c("persp","rgl"), ...)

Arguments

N
number of simulation steps.
M
number of trajectories.
x0, y0, z0
initial value of the process $X_{t}$, $Y_{t}$ and $Z_{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, driftz
drift coefficient: an expression of four variables t, x, y and z for process $X_t$, $Y_t$ and $Z_t$.
diffx, diffy, diffz
diffusion coefficient: an expression of four variables t, x, y and z for process $X_t$, $Y_t$ and $Z_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 "snssde3d".
order
order of moment.
level
the confidence level required.
display
"persp" perspective or "rgl" plots.
...
further arguments for (non-default) methods.

Value

  • snssde3d returns an object inheriting from class "snssde3d".
  • X, Y, Zan invisible mts (3-dim) object (X(t),Y(t),Z(t)).
  • driftx, drifty, driftzdrift coefficient of X(t), Y(t) and Z(t).
  • diffx, diffy, diffzdiffusion coefficient of X(t), Y(t) and Z(t).
  • typetype of sde.
  • methodthe numerical method used.

newcommand

\CRANpkg

href

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

pkg

#1

Details

The function snssde3d returns a mts x of length N+1; i.e. solution of the 3-dim sde $(X_{t},Y_{t},Z_{t})$ of Ito or Stratonovich types; If Dt is not specified, then the best discretization $\Delta t = \frac{T-t_{0}}{N}$. The 3-dim Ito stochastic differential equation is: $$dX(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) dW_{1}(t)$$ $$dY(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) dW_{2}(t)$$ $$dZ(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) dW_{3}(t)$$ 3-dim Stratonovich sde : $$dX(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) \circ dW_{1}(t)$$ $$dY(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) \circ dW_{2}(t)$$ $$dZ(t) = a(t,X(t),Y(t),Z(t)) dt + b(t,X(t),Y(t),Z(t)) \circ dW_{3}(t)$$ $W_{1}(t), W_{2}(t), W_{3}(t)$ three 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 and snssde2d for 1- and 2-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) 
## dZ(t) = 4*(1-Z(t)) *Y(t) dt + 0.2 * dW3(t)        
## W1(t), W2(t) and W3(t) three independent Brownian motion

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

res <- snssde3d(x0=2,y0=-2,z0=-2,driftx=fx,diffx=gx,drifty=fy,diffy=gy,
                driftz=fz,diffz=gz,N=1000,M=50)
res
summary(res)
dev.new()
plot(res,pos=2)
dev.new()
plot(res,union = FALSE)
dev.new()
plot3D(res,display="persp") ## in space (O,X,Y,Z)

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

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

res <- snssde3d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,driftz=fz,diffz=gz,
                ,N=5000,T=50,type="str")
res
dev.new()
plot(res,pos=2)
dev.new()
plot(res,union = FALSE)
dev.new()
plot3D(res,display="persp") ## in space (O,X,Y,Z)

Run the code above in your browser using DataLab