Learn R Programming

Sim.DiffProc (version 2.7)

rsde3d: Random Number Generators for 3-Dim SDE

Description

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

Usage

rsde3d(N, ...)
## S3 method for class 'default':
rsde3d(N = 100, M = 10, x0 = 0, y0 = 0, z0 = 0, t0 = 0, T = 1, Dt, tau = 0.5,
   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 'rsde3d':
summary(object, \dots)
## S3 method for class 'rsde3d':
mean(x, \dots)
## S3 method for class 'rsde3d':
median(x, \dots)
## S3 method for class 'rsde3d':
quantile(x, \dots)
## S3 method for class 'rsde3d':
kurtosis(x, \dots)
## S3 method for class 'rsde3d':
skewness(x, \dots)
## S3 method for class 'rsde3d':
moment(x, order = 2, \dots)
## S3 method for class 'rsde3d':
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.
z0
initial value of the process $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}$.
tau
moment (time) between t0 and T. Random number generated at time=tau.
driftx
drift coefficient: an expression of four variables t, x, y and z for process $X_t$.
diffx
diffusion coefficient: an expression of four variables t, x, y and z for process $X_t$.
drifty
drift coefficient: an expression of four variables t, x, y and z for process $Y_t$.
diffy
diffusion coefficient: an expression of four variables t, x, y and z for process $Y_t$.
driftz
drift coefficient: an expression of four variables t, x, y and z for process $Z_t$.
diffz
diffusion coefficient: an expression of four variables t, x, y and z for process $Z_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 snssde3d.
x, object
an object inheriting from class "rsde2d".
order
order of moment.
level
the confidence level required.
...
further arguments for (non-default) methods.

Value

  • rsde3d returns an object inheriting from class "rsde3d".
  • x, y, za vector of random numbers of 3-dim sde realize at time time $t=\tau$, the triplet $(x_{\tau},y_{\tau},z_{\tau})$.

newcommand

\CRANpkg

href

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

pkg

#1

Details

The function rsde3d returns a three random variables $(x_{\tau},y_{\tau},z_{\tau})$ realize at time $t=\tau$ defined by : $$x_{\tau} = { t \geq 0 ; x = X_{\tau} }$$ $$y_{\tau} = { t \geq 0 ; y = Y_{\tau} }$$ $$z_{\tau} = { t \geq 0 ; z = Z_{\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: Ito sde 3-dim
## dX(t) = 2*(3-X(t))* dt + (Y(t)+Z(t)) * dW1(t)          
## dY(t) = 2*(3-Y(t))* dt + (X(t)+Z(t)) * dW2(t)
## dZ(t) = 2*(3-Z(t))* dt + (X(t)+Y(t)) * dW3(t)

fx <- expression(2*(3-x))
gx <- expression(y+z)
fy <- expression(2*(3-y))
gy <- expression(x+z)
fz <- expression(2*(3-z))
gz <- expression(x+y)

res1 <- rsde3d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,driftz=fz,diffz=gz,N=500,M=30,
               Dt=0.05,tau=10)
res1
summary(res1)
bconfint(res1,level=0.95)
moment(res1,order=c(2,3,4,5))
X <- cbind(res1$x,res1$y,res1$z)
## library(sm)
## sm.density(X,display="rgl")

## Example 1: Stratonovich sde 3-dim
## dX(t) = W2(t) dt + W3(t) o dW1(t) 
## dY(t) = dW2(t) and dZ(t) = dW3(t) 

fx <- expression(y)
gx <- expression(z)
fy <- expression(0)
gy <- expression(1)
fz <- expression(0)
gz <- expression(1)
res2 <- rsde3d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,driftz=fz,diffz=gz,N=500,M=30,
               Dt=0.05,tau=1,type="str")
res2
summary(res2)
bconfint(res2,level=0.95)
moment(res2,order=c(2,3,4,5))
X <- cbind(res2$x,res2$y,res2$z)
## sm.density(X,display="rgl")

Run the code above in your browser using DataLab