snssde2d: Simulation of 2-D Stochastic Differential Equation

View source: R/snssde.R

snssde2dR Documentation

Simulation of 2-D Stochastic Differential Equation

Description

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

Usage

snssde2d(N, ...)
## Default S3 method:
snssde2d(N = 1000, M = 1, x0 = c(0,0),t0 = 0, T = 1, Dt, 
   drift, diffusion, corr = NULL, type = c("ito", "str"), alpha = 0.5, mu = 0.5, 
   method = c("euler", "milstein", "predcorr", "smilstein", "taylor", 
   "heun", "rk1", "rk2","rk3"), ...)	
   
## S3 method for class 'snssde2d'
summary(object, at, digits=NULL,...)
## S3 method for class 'snssde2d'
time(x, ...)
## S3 method for class 'snssde2d'
mean(x, at, ...)
## S3 method for class 'snssde2d'
Median(x, at, ...)
## S3 method for class 'snssde2d'
Mode(x, at, ...)
## S3 method for class 'snssde2d'
quantile(x, at, ...)
## S3 method for class 'snssde2d'
kurtosis(x, at, ...)
## S3 method for class 'snssde2d'
skewness(x, at, ...)
## S3 method for class 'snssde2d'
min(x, at, ...)
## S3 method for class 'snssde2d'
max(x, at, ...)
## S3 method for class 'snssde2d'
moment(x, at, ...)
## S3 method for class 'snssde2d'
cv(x, at, ...)
## S3 method for class 'snssde2d'
bconfint(x, at, ...)

## S3 method for class 'snssde2d'
plot(x, ...)
## S3 method for class 'snssde2d'
lines(x, ...)
## S3 method for class 'snssde2d'
points(x, ...)
## S3 method for class 'snssde2d'
plot2d(x, ...)
## S3 method for class 'snssde2d'
lines2d(x, ...)
## S3 method for class 'snssde2d'
points2d(x, ...)

Arguments

N

number of simulation steps.

M

number of trajectories (Monte-Carlo).

x0

initial values x0=(x,y) of the process X_{t} and Y_{t} at time t0.

t0

initial time.

T

ending time.

Dt

time step of the simulation (discretization). If it is missing a default \Delta t = \frac{T-t_{0}}{N}.

drift

drift coefficient: an expression of three variables t, x and y for process X_t and Y_t.

diffusion

diffusion coefficient: an expression of three variables t, x and y for process X_t and Y_t.

corr

the correlation structure of two Brownian motions W1(t) and W2(t); must be a real symmetric positive-definite square matrix of dimension 2.

type

if type="ito" simulation sde of Itô type, else type="str" simulation sde of Stratonovich type; the default type="ito".

alpha, mu

weight of the predictor-corrector scheme; the default alpha = 0.5 and mu = 0.5.

method

numerical methods of simulation, the default method = "euler".

x, object

an object inheriting from class "snssde2d".

at

time between t0 and T. Monte-Carlo statistics of the solutions (X_{t},Y_{t}) at time at. The default at = T.

digits

integer, used for number formatting.

...

potentially further arguments for (non-default) methods.

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) are two standard Brownian motion independent if corr=NULL.

In the correlation case, currently we can use only the Euler-Maruyama and Milstein scheme.

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, Itô-Taylor Order 1.5, Heun Order 2 and Runge-Kutta Order 1, 2 and 3.

An overview of this package, see browseVignettes('Sim.DiffProc') for more informations.

Value

snssde2d returns an object inheriting from class "snssde2d".

X, Y

an invisible mts (2-dim) object (X(t),Y(t)).

driftx, drifty

drift coefficient of X(t) and Y(t).

diffx, diffy

diffusion coefficient of X(t) and Y(t).

type

type of sde.

method

the numerical method used.

Author(s)

A.C. Guidoum, K. Boukhetala.

References

Guidoum AC, Boukhetala K (2020). "Performing Parallel Monte Carlo and Moment Equations Methods for Itô and Stratonovich Stochastic Differential Systems: R Package Sim.DiffProc". Journal of Statistical Software, 96(2), 1–82. doi:10.18637/jss.v096.i02

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

snssde3d for 3-dim sde.

simulate in package "yuima".

Examples


## 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)
set.seed(1234)

fx <- expression(4*(-1-x)*y , 4*(1-y)*x )
gx <- expression(0.25*y,0.2*x)

mod2d1 <- snssde2d(drift=fx,diffusion=gx,x0=c(x0=1,y0=-1),M=1000)
mod2d1
summary(mod2d1)
##
dev.new()
plot(mod2d1,type="n")
mx <- apply(mod2d1$X,1,mean)
my <- apply(mod2d1$Y,1,mean)
lines(time(mod2d1),mx,col=1)
lines(time(mod2d1),my,col=2)
legend("topright",c(expression(E(X[t])),expression(E(Y[t]))),lty=1,inset = .01,col=c(1,2),cex=0.95)
##
dev.new()
plot2d(mod2d1) ## in plane (O,X,Y)
lines(my~mx,col=2)

## Now W1(t) and W2(t) are correlated.

set.seed(1234)
Sigma <- matrix(c(0.9,0.3,0.3,0.4),nrow=2,ncol=2) # correlation structure
mod2d1 <- snssde2d(drift=fx,diffusion=gx,corr=Sigma,x0=c(x0=1,y0=-1),M=1000)
mod2d1
summary(mod2d1)
##
dev.new()
plot(mod2d1,type="n")
mx <- apply(mod2d1$X,1,mean)
my <- apply(mod2d1$Y,1,mean)
lines(time(mod2d1),mx,col=1)
lines(time(mod2d1),my,col=2)
legend("topright",c(expression(E(X[t])),expression(E(Y[t]))),lty=1,inset = .01,col=c(1,2),cex=0.95)
##
dev.new()
plot2d(mod2d1) ## in plane (O,X,Y)
lines(my~mx,col=2)

## 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)
set.seed(1234)

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

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

Sim.DiffProc documentation built on May 29, 2024, 8:09 a.m.