Learn R Programming

Sim.DiffProc (version 2.8)

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

Arguments

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

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: Ito sde 3-dim
## 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 <- rsde3d(driftx=fx,diffx=gx,drifty=fy,diffy=gy,driftz=fz,diffz=gz,
               x0=2,y0=-2,z0=0,tau=0.3,M=50)
res
summary(res)
plot(res,union=TRUE)
dev.new()
plot(res,union=FALSE)
X <- cbind(res$x,res$y,res$z)
## library(sm)
## sm.density(X,display="rgl")

Run the code above in your browser using DataLab