Learn R Programming

Sim.DiffProc (version 2.6)

rsde2d: Random Number Generators for 2-Dim SDE

Description

The (S3) generic function rsde2d for simulate random number generators to generate 2-dim sde.

Usage

rsde2d(N, ...)
## S3 method for class 'default':
rsde2d(N = 100, M = 10, x0 = 0, y0 = 0, t0 = 0, T = 1, Dt, tau = 0.5, 
   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 'rsde2d':
summary(object, \dots)
## S3 method for class 'rsde2d':
mean(x, \dots)
## S3 method for class 'rsde2d':
median(x, \dots)
## S3 method for class 'rsde2d':
quantile(x, \dots)
## S3 method for class 'rsde2d':
kurtosis(x, \dots)
## S3 method for class 'rsde2d':
skewness(x, \dots)
## S3 method for class 'rsde2d':
moment(x, order = 2, \dots)
## S3 method for class 'rsde2d':
bconfint(x, level=0.95, \dots)

Arguments

N
size of sde.
M
number of random numbers to be geneated.
x0
initial value of the process $X_{t}$ at time t0.
y0
initial value of the process $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}$.
tau
moment (time) between t0 and T. Random number generated at time=tau.
driftx
drift coefficient: an expression of three variables t, x and y for process $X_t$.
diffx
diffusion coefficient: an expression of three variables t, x and y for process $X_t$.
drifty
drift coefficient: an expression of three variables t, x and y for process $Y_t$.
diffy
diffusion coefficient: an expression of three variables t, x and y for process $Y_t$.
alpha
weight alpha of the predictor-corrector scheme; the default alpha = 0.5.
mu
weight mu of the predictor-corrector scheme; the default mu = 0.5.
type
sde of the type Ito or Stratonovich.
method
numerical methods of simulation, the default method = "euler"; see snssde2d.
x, object
an object inheriting from class "rsde2d".
order
order of moment.
level
the confidence level required.
...
further arguments for (non-default) methods.

Value

  • rsde2d returns an object inheriting from class "rsde2d".
  • x, ya vector of random numbers of 2-dim sde realize at time time $t=\tau$, the couple $(x_{\tau},y_{\tau})$.

newcommand

\CRANpkg

href

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

pkg

#1

Details

The function rsde2d returns a two random variables $(x_{\tau},y_{\tau})$ realize at time $t=\tau$ defined by : $$x_{\tau} = { t \geq 0 ; x = X_{\tau} }$$ $$y_{\tau} = { t \geq 0 ; y = Y_{\tau} }$$ with $\tau$ is a fixed time between t0 and T.

See Also

see rng random number generators in yuima package. rsde1d simulation RNs in sde 1-dim.

Examples

Run this code
## Example 1:
## random numbers of two standard Brownian motion W1(t) and W2(t) at time = 1

fx <- expression(0)
gx <- expression(1)
fy <- expression(0)
gy <- expression(1)
res1 <- rsde2d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,tau=1,M=30,N=1000)
res1
summary(res1)
bconfint(res1,level=0.95)
moment(res1,order=c(2,3,4,5))
X <- cbind(res1$x,res1$y)
## library(sm)
## sm.density(X,display="persp")

## Example 2: Stratonovich sde 2-dim
## dX(t) = 4*(-2-X(t))*t * dt + 0.4*Y(t) o dW1(t)          
## dY(t) = (0*(Y(t) > 0)- 2*(Y(t) <= 0)) * dt + X(t) o dW2(t)

fx <- expression(4*(-2-x)*t)
gx <- expression(0.4*y)
fy <- expression(0*(y>0)-2*(y<=0))
gy <- expression(x)
res2 <- rsde2d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,tau=1,M=30,N=1000,type="str")
res2
summary(res2)
bconfint(res2,level=0.95)
moment(res2,order=c(2,3,4,5))
X <- cbind(res2$x,res2$y)
## sm.density(X,display="persp")

Run the code above in your browser using DataLab