Learn R Programming

Sim.DiffProc (version 2.8)

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 = 1000, M = 100, 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)
## S3 method for class 'rsde2d':
plot(x, \dots)

Arguments

N
size of sde.
M
number of random numbers to be geneated.
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}$.
tau
moment (time) between t0 and T. Random number generated at time=tau.
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
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

rsde1d simulation RNs in sde 1-dim. rng random number generators in yuima package. rcBS, rcCIR, rcOU and rsOU in package sde.

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)
res1
summary(res1)
X <- cbind(res1$x,res1$y)
## library(sm)
## sm.density(X,display="persp")

## Example 2: 
## dX(t) = 5*(-1-Y(t))*X(t) * dt + 0.5 * dW1(t)          
## dY(t) = 5*(-1-X(t))*Y(t) * dt + 0.5 * dW2(t)
## W1(t) and W2(t) two independent Brownian motion

fx <- expression(5*(-1-y)*x)
gx <- expression(0.5)
fy <- expression(5*(-1-x)*y)
gy <- expression(0.5)
res2 <- rsde2d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,tau=0.4876
               ,x0=2,y0=-2,M=50)
res2
summary(res2)
plot(res2,union=TRUE)
dev.new()
plot(res2,union=FALSE)
X <- cbind(res2$x,res2$y)
## sm.density(X,display="persp")

Run the code above in your browser using DataLab